Grafana table - the-code-camp/hpe-sre GitHub Wiki

Grafana - Showing Data in a Table

Sometimes you may want to show the latest value for multiple time series in a table. For example, we could be interested in seeing the top three current request rates, broken up by path, method, and status code. Let's see how we can achieve this in Grafana.

Creating a table panel

Add a new panel as you did previously. Then, click on the visualization type picker at the top of the right-hand-side menu:

In the visualization type selector, choose "Table":

Setting a PromQL query

Now set the PromQL query to the following expression:

topk(3, sum by (path, method, status) (rate(demo_api_request_duration_seconds_count[5m])))

This selects the top three request rates as described above.

You will get a table that doesn't quite do what we want yet: it shows a range of data for a single series at a time, with a dropdown selector at the bottom that allows you to choose which of the time series to display

Configuring the table view

What we would like to display instead is a table that shows the latest value for each of the returned time series, all in one view. We will need to configure a few more table options to achieve this.

First, tell Prometheus to only query the latest value for each of the output series by turning on the "Instant" toggle in the "Query" pane:

Then, set the "Format" field for the query to "Table":

Now head to the "Transform" tab (next to the "Query" tab). The options under this tab allow you to apply various kinds of transformations to the returned query data before it is displayed in the table. In our case, we want to remove the "Time" column, since we know it always shows the latest timestamp. For this, pick the "Organize fields" transformation option:

Click the eye icon next to the "Time" column to hide that column:

Finally, set the title of the panel to "Top 3 request rates". The table will now show a clean view of the top three request rates:

Apply the panel again and save the dashboard to persist your changes.