0

I'm using Influxdb 2.04 to store some data and Grafana 7.1.5 to visualize it. I'm relatively new to both, so I was looking for guidance on how to format this query.

I've got a query where I'm trying to show average run times of a handful of Jenkins pipelines. So Far I have a query that looks like this:

from(bucket: "/primary-bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._field == "completed_builds" or r._field == "avg_duration")
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> cumulativeSum(columns: ["completed_builds", "avg_duration"])
|> map(fn: (r) => ({ r with build_percent: 
        if not exists r.avg_duration or r.completed_builds == 0.0 then 0.0
        else float(v: r.avg_duration) / float(v: r.completed_builds)
}))

This gives me back a graph that looks like this

Notice all the legend items are named "build_percent". Each result looks like it is its own table. Does anyone know a way to rename each legend name so it correlates with its related "_measurement" value.

Thanks In Advance!

4

0 回答 0