influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

schema.tagValues not working properly or ignoring "time" parameter

Open matrog opened this issue 3 years ago • 5 comments
trafficstars

Hello, i'm having issues with schema.tagValues function returning to many tags.

Here's env details

  • Red Hat Enterprise Linux release 8.5 (Ootpa)

  • InfluxDB 2.1.1 Server: 657e183 Frontend: cc65325

  • Influx installed via official RPM

if I use schema.tagValues with -1h (then same happen with any time range) it will return tag values outside that range

import "influxdata/influxdb/schema"
schema.tagValues(bucket: "prometheus", tag: "instance", predicate: (r) => r["_measurement"] == "node_cpu_usage_seconds_total", start: -1h)

i get

table_RESULT _valueNO GROUPSTRING
0 172.242.0.11
0 172.242.0.6
0 172.242.128.10
0 172.242.128.14
0 172.242.64.12
0 172.242.64.5

In order to verify real tags I run the following query on the same time range

 from(bucket: "prometheus")
  |> range(start: 2022-03-18T15:17:35.987Z, stop: 2022-03-18T16:17:35.987Z)
  |> filter(fn: (r) => r["_measurement"] == "node_cpu_usage_seconds_total"  )
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> group()
  |> unique(column: "instance")
  |> keep(columns: ["instance","_start","_stop"])

I get certaing tag values

table_RESULT instanceNO GROUPSTRING
0 172.242.0.11
0 172.242.128.14
0 172.242.64.12

which are correct. I suspect an issue with the function since we do not delete any tag or serie and we don't have a retention policy set.

matrog avatar Mar 18 '22 16:03 matrog

Run into the same problem. Would appreciate a comment from maintainers šŸ‘šŸ¼

dimitrisfasoulas avatar May 09 '22 20:05 dimitrisfasoulas

Problem persists in InfluxDB v2.2.0 OSS:

import "influxdata/influxdb/schema"

schema.tagValues(
    bucket: "my_bucket",
    tag: "my_tag",
    predicate: (r) => r._measurement == "my_measurement",
    start: v.timeRangeStart,
    stop: v.timeRangeStop,
)

Results are far outside the expected time range although there's some bounding happening, perhaps the -30d and now() default for start and stop respectively.

Please note: v.timeRangeStart and v.timeRangeStop are provided by Grafana, and work as expected.

EDIT: a quick follow up:

It appears that the minimum granularity is approximately 12 hours:

    start: -12h,
    stop: now(),

always has the same result, even if start is -1s, -1m, -1h, etc... Larger ranges for start change the results but also have similar behaviors although I've not dug into the precise behavior.

alvintownsend avatar May 31 '22 15:05 alvintownsend

I'm having the same problem. Looks like the stop property is not working at all

femanzo avatar Jun 15 '22 21:06 femanzo

I am having the same issue with InfluxDB 2.4.0 (git: de247bab08) build_date: 2022-08-18T19:37:34Z Here is the query that I am running

import "influxdata/influxdb/schema"
schema.tagValues(bucket: "test", tag: "test-tag", start: -7d, stop: -1d)

and the message I see in the console is

found unexpected argument stop

rnsv avatar Aug 27 '22 21:08 rnsv

Same thing for me on 2.4. I'm resorting to using the predicate to filter which is waay slower. Is there a way to calculate this faster in the predicate?


schema.tagValues(
  bucket: "alerting",
  tag: "_measurement",
  predicate: (r) => r._time > date.sub(d: 5d, from: now()),
  start: -5d
)

doivosevic avatar Aug 31 '22 07:08 doivosevic

Iā€˜m havinng the same issue.

env details: InfluxDB v2.6.1 Server: [9dcf880] (https://github.com/influxdata/influxdb/tree/9dcf880fe0) Frontend: [5ba8e15] (https://github.com/influxdata/ui/tree/5ba8e15)

WoohTao avatar Jan 29 '23 02:01 WoohTao

Seems like if predicate is set, start will work. Mabye start is used to limit predicate, following will return all tags:

import "influxdata/influxdb/schema"
schema.tagValues(
    bucket: "test",
    tag: "my_tag",
    predicate: (r) => true,
    start: v.timeRangeStart,
    stop: v.timeRangeStop
)

But if I set a predicate, will return tags during [start, stop]:

import "influxdata/influxdb/schema"
schema.tagValues(
    bucket: "test",
    tag: "my_tag",
    predicate: (r) => r._field == "my_field",
    start: v.timeRangeStart,
    stop: v.timeRangeStop
)

harttle avatar Apr 11 '23 16:04 harttle