Referencing value from one query to another

Hi Folks,

I am using Grafana for visualizing some data stored in InfluxDB. I want to reference one query to another query. Here is what I mean.

Query A shows the Error Code and Query B shows the Error text. You will notice that in Query B the value “12832” has been written manually. I want it to reference it from the result of Query A. How can I do it?

Cheers,
SD

I think you can do this using the “Dashboard” datasource.

Hi @svetb ,

How exactly? I tried but couldn’t really figure out how to do this. Some screenshots would be helpful!

In the drop down where you’ve currently selected “Mixed” can you select “Dashboard”? If the option doesn’t exist then you probably need to upgrade. Sorry I can’t take a screenshot since I’m on my phone. (Docs)

Hi @svetb,

I share a screenshot. Maybe you can guide me with the next steps.

I do not get any options to use this value to refer to the table with the error strings. This does not allow me to write any queries to query into the required table to get the corresponding string.

Cheers,
SD

Hi @sahebdatta1996 I think I misunderstood your original question. I thought it was about feeding the result of a query in one panel into another panel. I took a closer look at your first screenshot and think I understand your issue better now. Sorry to lead you astray initially.

There may be a direct way to do this also, but I can’t think of it right now. What should definitely work is to set up your first query (A) as a template variable. That would allow you to use its output as the template variable, and set up query B as you need it in the panel. Let me know if I’m making sense?

1 Like

Hi @svetb,

I tried it that way. The problem is template variables reload on refreshing the dashboard. That is not desirable I won’t be getting continuous data on the graph.

Regards,
SD

@svetb, If you can address this, it will also solve the problem.

Yeah good point. Can you see if you get the desired behavior if you set the template variable to refresh “on time range change”? I know it’s not super intuitive, but I just did a quick test (on v7.5.4) and it looks like with that setting the template variable will also get refreshed along with auto-refresh of the panel queries.

1 Like

Regarding your Kapacitor idea…it may be possible to bend Kapacitor to your will like that, but it won’t be pretty, and I wouldn’t recommend it. As @pooh said in the other forum, if you really need to do a join in your query then just use Flux.

3 Likes

Hi @svetb,

I was really stupid not checking the 2nd option. Yet, it worked and solved the specific purpose. Thanks a lot for your support.

Cheers,
SD

1 Like

Good question and perfect answers to solve this problem. I appreciate that, thanks! :handshake:

1 Like