Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable Key : Value pairs not working for Athena data source #446

Closed
MatinF opened this issue Oct 8, 2024 · 2 comments
Closed

Variable Key : Value pairs not working for Athena data source #446

MatinF opened this issue Oct 8, 2024 · 2 comments
Labels

Comments

@MatinF
Copy link

MatinF commented Oct 8, 2024

What happened?

We are trying to use the Athena data source to load data from a simple table consisting of metaname (key) and deviceid (value).

As described in below articles, it should be possible (and simple) to extract these for use in a Variable dropdown as key-value pairs:
grafana/grafana#30012
https://grafana.com/blog/2019/07/17/ask-us-anything-how-to-alias-dashboard-variables-in-grafana-in-sql/

However, in practice this does not seem to work when using the Amazon Athena data source.

To showcase this, see below:

The query I am using
I am using below query:

SELECT 
    deviceid AS __value,
    metaname AS __text
FROM
    tbl_aggregations_devicemeta

Using query in regular panel
As evident, the query returns the expected results as two separate columns:
Image

Using query in Grafana variable
Below is the result when using this query in a Grafana variable. As evident, the query returns the values (instead of the keys) for the dropdown. Futher, only the values are returned when fetching the value of the dropdown as well - it's not possible either to explicitly extract the metaname keys by using the :text modifier.

Image

This is a very basic requirement for dynamic Variable dropdowns, so it would be great to have a fix for this.

What did you expect to happen?

I expected the Grafana Variable query to create a dropdown showing the metaname keys and that when I reference this Variable in my queries, I would get the deviceid values.

Did this work before?

No, we reported this as a bug in an older issue, grafana/grafana#30012, but that issue was closed.

How do we reproduce it?

It should be easy to reproduce by creating a simple key/value table and using Amazon Athena to query this within the Variable section.

Is the bug inside a dashboard panel?

No, it is inside the Variable section.

Environment (with versions)?

Grafana: latest cloud version
OS: Windows 10
Browser: Chrome

Grafana platform?

I use Grafana Cloud

Datasource(s)?

Athena

@grafana-issues-bot grafana-issues-bot bot added the type/bug Something isn't working label Oct 8, 2024
@iwysiu iwysiu transferred this issue from grafana/grafana Oct 9, 2024
@idastambuk
Copy link
Contributor

Hi @MatinF, the documentation you're referencing is a bit outdated, here's the current one: Athena readme and Grafana Template Variable docs

As you can see the text and value fields are defined as just that, without the __ before it.
Does that work for you?

@idastambuk idastambuk moved this from Incoming to Waiting in AWS Datasources Oct 10, 2024
@MatinF
Copy link
Author

MatinF commented Oct 10, 2024

Thanks a ton, that made it work!

@MatinF MatinF closed this as completed Oct 10, 2024
@github-project-automation github-project-automation bot moved this from Waiting to Done in AWS Datasources Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

4 participants