Run Prometheus in Docker and query with DataStation
This tutorial walks through running Prometheus in Docker, loading it with data, and finally querying it in DataStation using PromQL.
Database initialization [Optional]
If you want to follow along with this tutorial verbatim, in your terminal create a simple Prometheus config that will tell Prometheus to scrape itself:
$ mkdir prometheus $ echo " global: scrape_interval: 15s scrape_configs: - job_name: 'prometheus' scrape_interval: 5s static_configs: - targets: ['localhost:9090']" > prometheus/prometheus.yml
Then start up Prometheus in Docker:
$ docker run -p 9090:9090 -v $(pwd)/prometheus:/etc/prometheus prom/prometheus
Data source setup
Now inside DataStation create a new data source in the left sidebar.
Give it a nice name so you easily can find it later. And select Prometheus in the Vendor dropdown.
If you are connecting to
localhost:8080 (the default), you can
leave the host field blank. If your port is 8080 then you can always
omit the colon and port and just specify the address.
Next fill in the username and authentication fields if necessary. Leaving these fields blank is ok too.
SSH Proxy [Optional]
If you want connect to a Prometheus database on a remote server through an SSH proxy, you will need to set up the SSH connection to that server first. Once you do, you can select that connection in the "Via Server" dropdown within the data source editor.
Now create a new panel and select the Database type.
Run a query
Enter your query and hit play!
Note: Ctrl-r is a shortcut for hitting the play button when you are focused on one panel.
You can always download the results of a panel by hitting the download button. Or you can reference the results in other panels.
Graph the results
After running the query, a graph button will appear below the panel next to the New Panel button. Click it to generate a graph based on this panel.
DataStation tries to guess which columns to graph but it doesn't always get it right. Select the name and age columns for the x and y dimensions respectively.
About this page
See an error or want to add a clarification? This page is
generated from this file on Github.
Last edited Apr 06, 2022.