Mixed datasource does not work with panel

  • What Grafana version and what operating system are you using?
    Grafana v10.1.0 (838218ba20) on Ubuntu server 20.04.6

  • What are you trying to achieve?
    I’m trying to offset data from a query with a single button. Lets say at some point in the the latest value from the query is 12.4. When the button is pressed, this value is subtracted from the query results so that they are offset with 12.4.

  • How are you trying to achieve it?

I figured I would use the Button panel plugin, have it run a psql query upon clicking and subtract this value from another query. The button works and gives the proper value, but I see no way of subtracting a panel value from a query.

I thought I would create another panel, select – Dashboard – as value, then add the psql query, then do some transformation. However, when I select Mixed datasource, there is no dashboard option anymore, only my psql datasource and the standard Grafana datasource.

Is this even possible? Perhaps here are other/better ways to do this? Any help is appreciated.

@bumptop I would use dashboard variable to subtract values from the query. It can be an input value or select with a list of values. You can use variables in the query directly.

There is a variable panel which allows to input value or display buttons to select a predefined value:

Yes, I have found those. Unfortunately they do not do what I want: Click a button and set a variable based on that query.

I managed to do them separately, but I haven’t found a way to bring these things together. I have a button that gets a value from a query, I have variables, but there is no obvious way to link these.

  • Edit

I have solved my challenge in a somewhat dirty way: The button panel pretty much takes any query like grafana. First I made another datasource with a different user for my psql database. This user has read access, but also write access to a specific table with offsets.

Now when I click the button, a psql query fetches the most recent value in table X and inserts it into the offsets table.

Then, I create a panel for displaying data. Here I use a query that fetches the appropriate offset from the offsets table, fetches the data from Table X and subtracts the offset from all values of X. Presto: A fully offset dataset with 1 press of a button. A nice side effect: The database has stored all offset entries for later review.

This wont wont be a suitable solution for everyone as it requires write access to a table, but this is not a problem for my use case.