Hi guys I want to use this query to count the number of Top10, but there is a problem with this number
from(bucket: “nginx_prod”)
|> range(start: -24h)
|> filter(fn: (r) => r[“_measurement”] == "nginx_log")
|> filter(fn: (r) => exists r["server_name"])
|> group(columns: ["server_name"])
|> count()
This query looks up the value 7727074 for www.test.com:9988 Use this query
from(bucket: “nginx_prod”)
|> range(start: -24h)
|> filter(fn: (r) => r["_measurement"] == "nginx_log")
|> filter(fn: (r) => r["server_name"] == "www.test.com:9988")
|> count()
The query returns a value of 518813
The actual value should be this 518813
What is the problem?
suyash
August 27, 2024, 9:55am
2
tengdagg:
I want to use this query to count the number of Top10, but there is a problem with this number
from(bucket: “nginx_prod”)
|> range(start: -24h)
|> filter(fn: (r) => r[“_measurement”] == "nginx_log")
|> filter(fn: (r) => exists r["server_name"])
|> group(columns: ["server_name"])
|> count()
This query looks up the value 7727074 for www.test.com:9988 Use this query
from(bucket: “nginx_prod”)
|> range(start: -24h)
|> filter(fn: (r) => r["_measurement"] == "nginx_log")
|> filter(fn: (r) => r["server_name"] == "www.test.com:9988")
|> count()
The query returns a value of 518813
The actual value should be this 518813
What is the problem?
Can you add this function distinct(column: "_time")
before grouping it in you first query ? Hopefully it should give you an accurate count as it will ensure unique data points by timestamp are calculated.
@suyash
Error after adding this query distinct(column: “_time”)
suyash
August 28, 2024, 10:43am
4
I see, can you try the following using unique() . I tried it on mine and it worked:
from(bucket: "nginx_prod")
|> range(start: -24h)
|> filter(fn: (r) => r["_measurement"] == "nginx_log")
|> filter(fn: (r) => r["server_name"] == "www.test.com:9988")
|> unique(column: "_time")
|> count()