Structured custom variables (e.g. 2-tuples)

  • What Grafana version and what operating system are you using?

    • 10.0.1 / Linux
  • What are you trying to achieve?

    • I have a fixed list of 2-tuples which I want to use to repeat a row such that each instance of the row receives the two values separately.
    • Either two variables which are correlated, or a single variable where I can extract only part of the value when interpolating, would both be fine.
    • The set of variables I want to include in this dashboard are a very small and arbitrary subset of the values available in the data source, so I need to hard-code them in a custom variable, I can’t extract them from a query.
  • How are you trying to achieve it?

    • I don’t know of a way to use templating for this, I’m currently manually configuring each row, but since each row has several widgets which all refer to the same variables this is very painful to maintain as the list changes.
  • Can you copy/paste the configuration(s) that you are having problems with?

    • No, because I don’t know where to start to attempt this.

try this post for something similar:

have you looked at the key : value approach?

1 Like

May be something similar would work in your case:

1 Like

Yes, and that’s helpful to know for aliases. But as far as I can tell, it’s not useful for this case because there are repeated keys which map to different values. I really do need something like a list of 2-tuples, or a list of structures.

please provide some sampling of pairs. for ex

1 Like

Sure, so the pairs in my case are related to a queue middleware, where the first item is a queue manager (which hosts multiple queues) and the second would be the name of the queue.

An example list would be:

(QM_1, msg.input.queue),
(QM_1, msg.output.queue),
(QM_2, error.queue),
(QM_META, log.queue)

So what I’m looking to achieve is have a row of panels showing various metrics for each queue. You’ll notice that each queue manager can have multiple queues, and the queue name isn’t necessarily unique across all queue managers either (although in practice I suspect it will be).

What I need is for the query to filter on tags something like:

queueManager=${qm}
queueName={$queue}

Ahh, I hadn’t tried using the key : value syntax quite like that. I can’t try that right away I’m afraid, but later today or tomorrow I’ll definitely give that a shot. Thanks so much for taking the time offer the suggestion!

As an aside, although this might solve this issue, it does strike me that I can think of cases where there are more than two values you want to iterate over. It would be fab to have the ability to enter a list of JSON objects (say) and be able to access multiple fields of the object. But perhaps this flexibility for hard-coded variables isn’t useful to enough people to be worth implementing. Just a thought!

1 Like

well we can only go with data you provided, not some other hypothericals. and yes you can do that also with json data. we will cross that bridge when you provide a different data set

1 Like

its is hard coded because you provided a hard coded list. so definitely worth implementing when you list is static. but it is also doable from a real database also