Hi,
I tried the last days to create a flux query to show the count of reported versions per timeframe, before showing my awful try of a query I would provide the data structure.
bucket: cms
_measurement: (always the same) census
tags:
unique_id - a unqiue id per installation
fields:
cms_version: semVer string x.y.z
cms_major: x - only the major version
cms_minor: x.y - only the minor version
db_version - same structure like cms
db_server - string with mysql, postgresql, mssql,…
…
We get this information about every 6 hours depending on the triggered cronjobs for each installation.
My try to create a query for grafana which at least works a kind of
from(bucket: "cms")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._field == "cms_major" and r._value == "3")
|> sort(columns: ["_time"], desc: true)
|> aggregateWindow(every: 1w, fn: first, column: "unique_id", createEmpty: false)
|> group(columns: ["unique_id", "_value", "_field"])
|> map(fn: (r) => ({ _time: r._time, _field: "value", count: 1 }))
|> aggregateWindow(every: 1w, fn: sum, column: "count", createEmpty: false)
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "count")
|> group(columns: ["_time"])
|> sum(column: "value")
|> duplicate(column: "_time", as: "_stop")
The query works more or less, it returns a count per week without duplicated unique ids for major version 3, at least in influxdb. Using this query in grafana ends in many columns with the name “value timestamp”. Using a transform in grafana to reduce rows based on last and replace all fields shows a graph. But I think that’s not right since the data should be already correct right?
The next issue is to show multiple versions in comparison on one chart (version 3 4 5 +++), I tried to using union but that doesn’t look quite well and doesn’t work with transformation.
any advice would be helpful.
thanks