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

**URL:** <https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614>\
**Category:** Dashboards\
**Created:** [July 19, 2024, 9:27am UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614 "2024-07-19T09:27:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![cartroo](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/cartroo/32/47298_2.png) [@cartroo](https://community.grafana.com/u/cartroo)\
**Post date:** [July 19, 2024, 9:27am UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/1 "2024-07-19T09:27:16Z")

</div>

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

- **What** are you trying to achieve?

- **How** are you trying to achieve it?

- Can you copy/paste the configuration(s) that you are having problems with?

---

<div class="post-metadata">

**Author:** ![sowdenraymond](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/sowdenraymond/32/38541_2.png) [@sowdenraymond](https://community.grafana.com/u/sowdenraymond)\
**Post date:** [July 19, 2024, 10:31am UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/2 "2024-07-19T10:31:42Z")

</div>

try this post for something similar:

> [@Change title based on condition (Repeating Panel)](https://community.grafana.com/t/change-title-based-on-condition-repeating-panel/118953):
>
> I need to change the title of a panel based on a variable which the panel repeats over. For example: Repeating variable var can take values: 1, 2, 3, 4, 5. When var = 1, title of panel should read: “blah blah Precision blah” When var = 2, title = “blah blah Accuracy blah” When var = 3, 4, or 5, then title = “blah blah Speed blah” Is there a syntax to support this in Grafana titles?

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [July 19, 2024, 3:17pm UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/3 "2024-07-19T15:17:59Z")

</div>

> [@cartroo](#):
>
> single variable where I can extract only part of the

have you looked at the `key : value` approach?

---

<div class="post-metadata">

**Author:** ![ebabeshko](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@ebabeshko](https://community.grafana.com/u/ebabeshko)\
**Post date:** [July 19, 2024, 4:08pm UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/4 "2024-07-19T16:08:25Z")

</div>

> [@cartroo](#):
>
> Either two variables which are correlated

May be something similar would work in your case:

> [@Application to servers mapping](https://community.grafana.com/t/application-to-servers-mapping/125006/5):
>
> [chained] One possible option is to use [Infinity plugin](https://grafana.com/grafana/plugins/yesoreyeram-infinity-datasource/) for that: parse-json | scope "applications" | where "name" in ('${Application:text}') | mv-expand "server"="servers" | project "server"="server"

---

<div class="post-metadata">

**Author:** ![cartroo](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/cartroo/32/47298_2.png) [@cartroo](https://community.grafana.com/u/cartroo)\
**Post date:** [July 21, 2024, 3:55pm UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/5 "2024-07-21T15:55:01Z")

</div>

> [@yosiasz](#):
>
> have you looked at the `key : value` approach?

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.

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [July 21, 2024, 3:56pm UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/6 "2024-07-21T15:56:33Z")

</div>

please provide some sampling of pairs. for ex

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/4/7/473a0e9dcca28bf37a735117d5cc3b03c9df1725.png)

---

<div class="post-metadata">

**Author:** ![cartroo](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/cartroo/32/47298_2.png) [@cartroo](https://community.grafana.com/u/cartroo)\
**Post date:** [July 21, 2024, 4:01pm UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/7 "2024-07-21T16:01:47Z")

</div>

> [@yosiasz](#):
>
> please provide some sampling of pairs.

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:

```auto
(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:

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

```

---

<div class="post-metadata">

**Author:** ![cartroo](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/cartroo/32/47298_2.png) [@cartroo](https://community.grafana.com/u/cartroo)\
**Post date:** [July 21, 2024, 4:11pm UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/9 "2024-07-21T16:11:17Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [July 21, 2024, 4:18pm UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/10 "2024-07-21T16:18:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [July 21, 2024, 4:24pm UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/11 "2024-07-21T16:24:36Z")

</div>

> [@cartroo](#):
>
> this flexibility for hard-coded variables isn’t useful to enough people to be worth implementing

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

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [July 26, 2024, 5:58am UTC](https://community.grafana.com/t/structured-custom-variables-e-g-2-tuples/126614/12 "2024-07-26T05:58:52Z")

</div>


