This commit is contained in:
2023-09-28 21:44:03 +01:00
parent ca8de72f58
commit 348824af09
10 changed files with 179 additions and 16 deletions

View File

@@ -0,0 +1,23 @@
////////////////////////////////////////////////////////////////////
v = {
"timeRangeStart": 2023-06-16T14:44:00Z,
"timeRangeStop": 2023-06-18T14:44:00Z
}
bucket = "telegraf"
////////////////////////////////////////////////////////////////////
hosts = ${httpHost:json}
hostsLength = hosts |> length()
measurement = "nginx_access-logv3"
from(bucket: "${bucket}")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == measurement and r["_field"] == "nginx_host")
|> filter(fn: (r) => if hostsLength>0 then contains(value: r["_value"], set: hosts) else true)
|> group(columns: ["resp_code"])
|> count()
|> group()
|> sort(columns: ["_value"], desc: true)