Sharing: Tag Browser In Grafana
# general
t
Sharing: Tag Browser In Grafana
Just sharing some work I did that is specific to UMH. I wanted a tag brower in grafana, as I'm not expecting everyone to have access to the UMH console that wants to see tag values.
If you want to implement it here is a link to all of the steps to add Materialized Views, Procedures, Jobs to TimescaleDB...and the JSON to import into grafana. https://40hero.notion.site/Tag-Browser-In-Grafana-for-UMH-12fd9b1ffcc380d29ec7f954c1fdeaa0?pvs=4
d
is this a mockup or does this work?! :p
this is pretty awesome
t
It works
On my instance but it just uses what is in timescale. It uses the asset table for the isa95 hierarchy, and tag name delimiters of . Or $ for the tag hierarchy… then it puts them together in the full_hierarchy… but then the tag tree requires a specific id, label, parent table schema , so i had to create a materialized view to build that tree…. Then schedule it to refresh every 5m
I originally had it all in one materialized view, but it was too complicated to follow, and now that we have separate views we can use those for other purposes too
d
first 6 steps should be done in the postgres command line right?
t
Whatever tool you use for sql queries
I used pgadmin
j
@Mateusz @Alex
d
nice work. how about to use the grafana api to create a new dashboard with a query on the selected tag? This would allow the user to quickly create a new dashboard with the correct query without writing any code. Or as a first step display the query for the tag in a text field for user to copy. Pretty much the same as the tag browser in the mgnt console.
j
@Rao
m
Looks amazing! Would you use this to explore the UNS or use this as a dynamic template for specific data points?
t
Browsing, kinda like how we have the tag browser in the console. But not everyone using the system will have access to the console. I can quickly find the tag i need and view some basic things, which can help identify what is important.
d
@trentc I am trying it right now Is it normal that the regex takes a long time?
i also needed to chop up SQL scripts to get it working
am i doing something wrong?
hmmm this worked (after a few minutes)
but i'm facing some issues
@trentc would you be willing to help me in this? 🙂
this would be the wrong user in grafana i would assume?
this seems worse:
t
You shouldn't have to "chop up" any sql. Just paste in what I provided and execute...
The tag_hierarchy is the one that takes awhile....it will take several seconds.
Also, you should have an index on your tag table if you don't already....I didn't include that in my docs because it should be applied in the latest versions of UMH
this is because the SQL used didn't provide Select rights to user "grafanareader"
assuming you got all of the materialized views working, you should be able to query tag_tree or full_hierarchy select * from tag_tree There should be at least an id, label, and parent columns....
I made some revisions, as once I had 3500 tags in my system, the grafana interactive tree was taking a really long time to populate 8000 rows... See OP up top for the link, it will be updated with new docs.
j
nice!