Implementing variables?
PeterSurda opened this issue · 8 comments
I'm trying to add a variable in grafana from TickTockDB data source, and it doesn't produce any results. I suspect the API to do this isn't implemented in TickTockDB. Do you know more about this? I don't know enough about what's missing and the design in order to implement it.
I use collectd to feed the data, but I put telegraf in the middle so that it can add the necessary tags (collectd's opentsdb output doesn't have tags). I want mainly a variable from the "host" tag, that would be adequate. Then I could select the host for a chart from a drop down menu.
@PeterSurda Do you refer to this? I created a custom variable 'HOST' with values (rpi4, raspberrypi, yi-Ideapad), and used it in query tag=value as host=$HOST.
You got it, except I want the variable values to be generated dynamically. In InfluxDB and QuestDB for example I can specify a query to produce the list:
- InfluxDB:
schema.tagValues(bucket: "mybucket", tag: "host")
- QuestDB:
SELECT host FROM df_value;
Grafana documentation says that for OpenTSDB the query is tag_values(host)
. However when applied on TickTockDB, it produces no results.
Well, what I could do is to have a process, run by a scheduler, that will run a query and use a grafana api call to populate the variable.
TT doesn't support APIs (e.g., tag_values(tag)) to retrieve values associated with a tag currently (v.0.12.1). The closest API is suggest?type=tagv&q=&max=1000
which returns all available values for all tags. The results can be filtered by keyword as specified as q=xxxx
. Actually when you typed in the value textbox, you can see all unfiltered values for all tags (see the pic below).
To support retrieval of values of a tag, another index between a tag and its values is needed. We will put the functionality in the future list. Hope it is not a dealbreaker for you to use TT.
Thank you, I'll find some workaround. Even with this TT seems like the best choice so far (migrating away from rrdtool I also tried graphite carbon, influx, questdb).
This below for example is a quick PoC to produce a list of hosts for a specific chart that have data in the last minute:
curl -s 'http://localhost:6182/api/query?start=1m-ago&m=none:pybitmessagestatus_value.value\{type_instance=networkconnections,host=*\}'|jq -r '[.[].tags.host]|sort|unique|values'
Thank you, I'll find some workaround. Even with this TT seems like the best choice so far (migrating away from rrdtool I also tried graphite carbon, influx, questdb).
This below for example is a quick PoC to produce a list of hosts for a specific chart that have data in the last minute:
curl -s 'http://localhost:6182/api/query?start=1m-ago&m=none:pybitmessagestatus_value.value\{type_instance=networkconnections,host=*\}'|jq -r '[.[].tags.host]|sort|unique|values'
That's a smart workaround, even better than building an internal index (which is costly).
Now I just have to figure out how to do that inside grafana rather than in a shell.