Optimizing Grafana and Prometheus rendering performance using Trickster

Optimizing Grafana and Prometheus rendering performance using Trickster

Trickster is a reverse proxy cache for the Prometheus HTTP APIv1 that dramatically accelerates dashboard rendering times for any series queried from Prometheus. See our previous post about Why we Love Grafana and Prometheus. We are always super impatient so love cool things like Trickster. Dashboards that automatically refresh should now load on average 90% faster. Oh yeah!

Installation

Let’s walk through a quick installation for an existing Grafana/Prometheus setup.

Get the latest release (at time of writing):

Download trickster

   
  
mkdir /opt/trickster/
cd /opt/trickster/
wget https://github.com/Comcast/trickster/releases/download/v0.1.1/trickster-0.1.1.linux-amd64.gz
gunzip trickster-0.1.1.linux-amd64.gz
ln -s trickster-0.1.1.linux-amd64 trickster
  

Setup the config file for trickster as follows:

/opt/trickster/trickster.conf

   
  
\[main]
\[proxy_server]



\#Note: Since we already have Prometheus running on port 9090, we change this to 9089 (or some other free port).



 listen_port = 9089

\[cache]
cache_type = 'memory'
compression = true
\[origins]
    \[origins.default]
    # Note: This points to your Prometheus installation, not Grafana!
    origin_url = 'http://prometheus.my-domain.tld:9090/prometheus'
    api_path = '/api/v1'
    default_step = 300
    max_value_age_secs = 86400
\[metrics]
listen_port = 8082
\[logging]
log_level = 'info'
  

Create a systemd service file:

/etc/systemd/system/trickster.service

   
  
[Unit]
Description=Prometheus Trickster Service
[Service]
ExecStart=/opt/trickster/trickster -config /opt/trickster/trickster.conf
StandardOutput=null
[Install]
WantedBy=multi-user.target
Alias=prometheus-trickster.service
  

Enable and start the service:

   
  
systemctl enable trickster.service
systemctl start trickster.service
  

IMPLEMENTATION IN GRAFANA

To get Grafana to use trickster is very easy.

  • Log into Grafana

  • Hit the gear icon for “Configuration”, then select “Data Sources”

  • Edit your existing Prometheus data source entry.

  • Simply change the HTTP URL port from 9090 to 9089.

    • 
      
  • “Save and Test” your configuration.

That’s it! If everything worked out you should now be using the Trickster cache for rendering graphs.

Dashboards that auto-refresh should now load on average 90% faster.

Categories: Development, DevOps, Training

By Rob Hartzenberg

October 30, 2018

Rob Hartzenberg
Author: Rob Hartzenberg

Linux Engineer

PREVIOUS

Basic Kubernetes Architecture – Video

NEXT

SQL data, time series, and awesome graphs using Grafana and Prometheus