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

Dashboard -> Variables #16

Closed
neilor-mendes opened this issue Oct 14, 2024 · 31 comments
Closed

Dashboard -> Variables #16

neilor-mendes opened this issue Oct 14, 2024 · 31 comments

Comments

@neilor-mendes
Copy link

neilor-mendes commented Oct 14, 2024

@haohanyang is it also possible to add the feature to support dashboard variables? I tried it but seems the plugins is missing some components to make it work.

Variables is very useful to create more interactive and dynamic dashboards

image

Found this link, maybe it can help: https://grafana.com/developers/plugin-tools/how-to-guides/data-source-plugins/add-support-for-variables

@haohanyang
Copy link
Owner

The plugin doesn's support Query Variable but it supports , for example, custom variables which you enter manually from the dashboard. If that is want you want?

image

@neilor-mendes
Copy link
Author

Are you planning to develop the Query Variable ?

Actually I'd like to dynamically, based on a query, build the list of possible values available for the filter instead of the custom variable. My use case we has a lot of different values and would be nice to count on it.

Here is an example but for influx db https://youtu.be/6jYKn5ULJX0?t=368

@haohanyang
Copy link
Owner

I didn't read through the "Query Variables" in the first time when I implemented the plugin. But it looks like a power feature. Will plan it for future release.

@neilor-mendes
Copy link
Author

Do you have an ETA for it? Just to understand how I can overcome this need now.

@haohanyang
Copy link
Owner

I anticipate the first iteration could happen in this week

@haohanyang
Copy link
Owner

@neilor-mendes
Copy link
Author

Added #17 to fix this

Package: https://github.com/haohanyang/mongodb-datasource/actions/runs/11371029920

@haohanyang Let me know when it is available to test and I can do that!

@haohanyang
Copy link
Owner

It's ready for test now. Necessary changes can be done in this PR

@neilor-mendes
Copy link
Author

am I missing anything here? I still can't see the textbox to write the query after the plugin get upgraded.

image

@haohanyang
Copy link
Owner

haohanyang commented Oct 17, 2024 via email

@neilor-mendes
Copy link
Author

Let me test again @haohanyang

@neilor-mendes
Copy link
Author

neilor-mendes commented Oct 17, 2024

@haohanyang I downloaded it again and didn't work. What I can check to make sure I'm using the right package?

-rw-r--r-- 1 admin admin     2498 Oct 16 17:47 README.md
-rw-r--r-- 1 admin admin      850 Oct 16 17:47 plugin.json
-rw-r--r-- 1 admin admin    60508 Oct 16 17:47 module.js.map
-rw-r--r-- 1 admin admin    23657 Oct 16 17:47 module.js
-rw-r--r-- 1 admin admin    11356 Oct 16 17:47 LICENSE
-rw-r--r-- 1 admin admin       53 Oct 16 17:47 CHANGELOG.md
-rwxr-xr-x 1 admin admin     1044 Oct 16 17:49 go_plugin_build_manifest
-rwxr-xr-x 1 admin admin 26951680 Oct 16 17:50 gpx_mongodb_datasource_linux_amd64
-rwxr-xr-x 1 admin admin 27695104 Oct 16 17:52 gpx_mongodb_datasource_windows_amd64.exe
-rwxr-xr-x 1 admin admin 25886720 Oct 16 17:52 gpx_mongodb_datasource_linux_arm64
-rwxr-xr-x 1 admin admin 30210304 Oct 16 17:52 gpx_mongodb_datasource_darwin_amd64
-rwxr-xr-x 1 admin admin 25690112 Oct 16 17:52 gpx_mongodb_datasource_linux_arm
-rwxr-xr-x 1 admin admin 29886530 Oct 16 17:52 gpx_mongodb_datasource_darwin_arm64
drwxr-xr-x 2 admin admin     4096 Oct 17 14:49 img/
drwxr-xr-x 3 admin admin     4096 Oct 17 14:49 ./
drwxr-xr-x 9 admin admin     4096 Oct 17 15:06 ../

@haohanyang
Copy link
Owner

haohanyang commented Oct 18, 2024

I updated the mongo version to 0.1.1 so you can see it here
image

https://github.com/haohanyang/mongodb-datasource/actions/runs/11401370940

@neilor-mendes
Copy link
Author

@haohanyang Now I was able to write the query but seems there is something still not right. On the preview of values down below we are supposed to see the list of values coming from the query not the key name and those values will be used as variable values.

image

@haohanyang
Copy link
Owner

I updated the text name so you can view the value: <field_name>:<values>
If the array has only 1 element, the value is its element. Otherwise the value is an array that can be formatted according to Grafana's syntax

@neilor-mendes
Copy link
Author

@haohanyang Gonna test it and let you know!

@neilor-mendes
Copy link
Author

neilor-mendes commented Nov 27, 2024

@haohanyang can we reopen this? I'm just testing it know and seems it is not working as expected yet but you are close.

Se below that it is returnin a object and not only a list of values
image

It is expected only the values separated by comma.

@haohanyang
Copy link
Owner

haohanyang commented Nov 27, 2024

This is indeed an array, want you see is just a pretty-print. See

text = `${field.name}:[${values[0]}, ...]`;

But the value is an array if it has more than 1 element

value: values.length === 1 ? values[0] : values,

@neilor-mendes
Copy link
Author

neilor-mendes commented Nov 29, 2024

@haohanyang ,

Sorry to bother you again but take a look on what is happening.

image

This is an example of the query I'm using

[ { "$project": { "chipid": 1, "_id": 0 } } ]

@haohanyang
Copy link
Owner

haohanyang commented Dec 2, 2024 via email

@neilor-mendes
Copy link
Author

neilor-mendes commented Dec 2, 2024 via email

@haohanyang
Copy link
Owner

Makes sense. I will make a PR to fix this

@haohanyang
Copy link
Owner

@neilor-mendes please check #28.

@neilor-mendes
Copy link
Author

neilor-mendes commented Dec 5, 2024 via email

@neilor-mendes
Copy link
Author

neilor-mendes commented Dec 5, 2024 via email

@haohanyang
Copy link
Owner

haohanyang commented Dec 5, 2024

Multi-value is supported
image
image

@neilor-mendes
Copy link
Author

neilor-mendes commented Dec 7, 2024 via email

@haohanyang
Copy link
Owner

haohanyang commented Dec 7, 2024 via email

@neilor-mendes
Copy link
Author

neilor-mendes commented Dec 9, 2024

@haohanyang I'm still not sure what is wrong... The query is not returning any value, take a look below:

This is how the query retuns at MongoDB Compass

image

But here, after upgraded the plugin, it is empty, im running the same query:

image

Version Upgraded:

image

@haohanyang
Copy link
Owner

haohanyang commented Dec 9, 2024 via email

@haohanyang
Copy link
Owner

haohanyang commented Dec 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants