Key-value variable as a JSON query doesnt work

  • Grafana version v10.3.3 (252761264e)

  • What are you trying to achieve?

I wan to create a key-value variable using data received from JSON API with the JSON API plugin

  • How are you trying to achieve it?

I use https://jsonplaceholder.typicode.com/users as a test backend, I want to pick up key-value pairs like Bret: 1, Antonette: 2, etc. So I use path /users and JSONpath fields like $[*].id for __value and $[*].username for __text:

  • What happened?

I receive just ids
изображение

  • What did you expect to happen?

I expect to receive IDs and usernames

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

Pastebined test dashboard : https://pastebin.com/raw/tS7HkHLJ

  • Did you follow any online instructions? If so, what is the URL?

JSON API plugin guide: Variables | JSON API for Grafana

Grafana gide about variables: Add and manage variables | Grafana documentation

Some issues on this site like this: __value and __text for variables not working as expected

I guess that JSON API is not the proper plugin to solve this issue, so I tried with Infinity plugin with no result, too. Is it possible to get gey-value variables from APIs with any plugin?

Welcome to forum @viktorkho

Here it is using infinity plugin

image

1 Like

Thank you @yosiasz for solution, did you try on v10.3.3? (or on v11.0.0?)

Seems it works on v11.0.0 (grafana.net and play.grafana.com), but not on v10.3.3, available for download…

I’ve easily reproduced your solution in cloud (works fine - thanks a lot for it), exported dashboard to my on-premise Grafana and… it doesn’t work here

@viktorkho - I doubt you might be using older version of Infinity plugin on your on-prem instance. ( __text and __value support was recently added grafana-infinity-datasource/CHANGELOG.md at main · grafana/grafana-infinity-datasource · GitHub) On older versions of infinity, if two columns returned the first one will be used as text and the second one will be used as value.

1 Like