-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[feature request] SHOW TAG KEYS/VALUES should accept a WHERE time clause #5668
Comments
+1 I tried to do this today. It would be a great help. |
Perhaps it's not the best issue to comment on the case but one of the things that I find stange is the way that tags are treated. Quote from the docs:
So if you think of |
@Groblus it is not valid to think of tags as related to fields. They are completely different concepts. All tag keys and values are stored only as strings, and only once, in the index, for each series. Fields are stored as float, int, bool, or string, and are individually stored with each point, and are unindexed. SHOW queries operate on metadata like databases, measurements, and tags. SELECT queries operate on the metrics themselves, which are the fields. Tag values may also be SELECTed, but only to differentiate the field results. |
I would like to see this as well. Here is my use case. With telegraf and procstat plugin a want to monitor a set of processes that all have the same name (but different pid, obvisouly). Then I plot the data on grafana dashboards, using template features. With grafana template features I can create a variable based on a query. For instance, I have this template variable to filter the set of processes by the process name I want:
So far so good.
Although, and strangely, the query is considered valid if I try it in the web interface of influxdb. But it returns nothing. (of course in the web interface of influxdb I replaced $pname with a string) Actually, same would happen if I wanted to pre-filter by the EDIT: Actually it is even worst. If the template variable contains all pids, then the dashboard gets repeat even if there is no data. So, it's kind of grafana issue, but the most natural way to solve it would be that the pid variable gets populated only with values valid for the current filter. Which is possible only with a where clause for SHOW TAG VALUES. |
+1. same issue here... SELECT value_pid from procstat where process_name=$pname OR, and this is also related to some other opened issues, be able to select tags directly in the result set : SELECT tag_pid from procstat where process_name=$pname I relaly think the later would be the better solution. |
+1 |
3 similar comments
+1 |
+1 |
+1 |
+1 on being able to restrict tag values returned based on a time range. This feature would be extremely useful when using Grafana templating variables. In some cases we can have 100s of values listed when only a few might pertain to time period being viewed. |
+1. Really need this for Grafana templates. Can't deploy without it. |
+1 Same use case here, grafana dashboards and plenty of customer demand |
I've found a workaround that seems to work in my environment. Create a short retention policy and then create a continuous query that groups by the tags you want to use in the grafana templating.
I have some extra info that i can group by and push it into a fake measurement called host_info.
I dont care what the values are, its just about getting a distinct list of hosts that are up and pushing data in the last few days. I have this in my templates in grafana as something like this:
I'm just going to reuse the templates in the users dashboards and a few variations of it for other host info like disk etc... It works for me, hope others can find something similar! |
+1 |
+1 |
2 similar comments
+1 |
+1 |
+1 Need this for grafana templates as well |
+1 Main use case is for grafana template variables. Showing a drop down of 300 entries when the time period only has 3 unique values is no fun!! |
I am running into the same issue when I try to use grafana template variables. Any update on having a WHERE time clause for SHOW TAG VALUES? |
This restriction is definetly a big problem for us, especially where some of our tag values can increase over time, and managing the size with retention policies isn't always the answer. One workaround we had thought about might be the idea of using output from SELECT value,tag WHERE $timeFilter and discarding everything other than the desired tags? Probably horribly expensive, especially seeing as it would be a disk operation instead of access from memory indexes, but a possibility if the selected time series wasn't too big? |
I was shocked when I found out this wasn't a feature when using Grafana template variables. For my usage we have a high number of hosts and a high turnover of hostnames. Even with a retention policy of 30 days, I have some query strings in Grafana using template variables with a filter which exceeds 250k characters. Instead only handful of hosts need to be selected for that period. This is a feature with should be added. |
@beckettsean I dont think its that expensive to implement for the lower bound case i.e |
Here's an example of my workaround. Just wrote a script that updates the templated variables to be the ones that I wanted within a specified timeframe |
For Grafana variables the answer is: |
|
@itshikanov It works, thanks! |
@joway @itshikanov, in this case, query returns array and grafana UI fails with "templating" error. Which version of grafana do you use? |
Very much surprised that this issue is not solved yet... Completely kills our use case to use influxdb. |
Found workaround for all of those who are looking to use tags from InfluxDB with respect of timeFilter for Grafana variables templating. |
Thanks @BushnevYuri, Can I use this to convert a current Variable "$host" with the following configuration to add in the timeFilter i.e. to only return the $host variables which are present in the Dashboard's Time Filter timeframe? SHOW TAG VALUES FROM "snmp.hosts" WITH KEY = "agent_host" It's not clear to me how I'd need to construct your suggested SELECT suggestion based on the above SHOW query? select DISTINCT("name") from (select "name","value" from "http_req_duration" WHERE $timeFilter AND "group" =~ /^$Group$/ AND "TestName" =~ /^$TestName$/) |
Hi @BushnevYuri, Any chance you could provide an example as to how to use your workaround SELECT query to get the following SHOW TAGS query to respect the timeFilter? SHOW TAG VALUES FROM "snmp.hosts" WITH KEY = "agent_host" Ultimately, I don’t see how I use the TestName and Group parameters in your example query for my SHOW TAGS query above? |
The following works for me in grafana as a variable: |
Thanks for the clarifications. I’m now able to filter the tag keys by $timeFilter - The work around is good enough but surprised that InfluxDB cant handle the time filter in a standard show tags query. |
As an update to @ekle 's workaround, I was able to use
To make the query respect the currently selected Grafana time window, you use the |
I am using InfluxDB
However, the peculiarity is that the finest granularity is 1 day... I can't filter tags on an hourly or a minutely basis... this makes sense from a performance perspective but I cannot find this behaviour documented anywhere. Would anyone be able to shed a light on this? |
@brtknr - You cannot filter |
Hi @davidnewhall, here is the answer: https://community.influxdata.com/t/undocumented-behaviour-with-show-tag-keys-values/10805/6 |
Interesting. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still an issue. |
any news about this issue? |
I found this workaround: Where "request" is tag key. |
It's not a fast query, but subselects can make it work for cases where you want to filter by other tag or field values. The sub-query / group by is to return unique values of the tag. If you want "tag_a" values when "tag_b" = some other value, you can query a related field [1], using a simple aggregate (e.g. last()). I haven't checked if other aggregate functions are faster, because this met my needs.
[1] Yes, tags and fields are separate concepts in the database. By "related" I mean in the practical sense of where the data comes from, not how it's stored. |
+1 |
+1 |
1 similar comment
+1 |
Rather than update
DISTINCT()
to accept tags (#3880), we could accomplish much the same goal if theSHOW TAG VALUES
query respected aWHERE time
clause. SHOW TAG VALUES already returns the deduplicated set of values.It is not trivial, since the query can no longer be answered directly from the metastore, but it seems easier than making functions accept tags, which is a totally new code path.
The text was updated successfully, but these errors were encountered: