influxdbflux-influxdb

Why is this InfluxDB Flux query returning 2 tables?


Obv. I'm new to InfluxDB & the Flux query language so appreciate patience! Happy to be redirected to documentation but I haven't found anything genuinely useful to date.

I've configured Jenkins (2.277.3) to push build metrics to InfluxDB (Version 2.0.5 ('7c3ead)) using plugin (https://plugins.jenkins.io/influxdb/). No custom metrics at the moment. Data is being successfully sent.

I'd like to build a simple bar chart to show build times for a specific project. Each "bar" would be an individual build (with a distinct build number). Also:

I'm trying to create the query(ies) to support this view:

from(bucket: "db0")
  |> range(start: -2d)
  |> filter(fn: (r) => r["project_name"] == "Job2")
  |> filter(fn: (r) => r._measurement == "jenkins_data" and r._field == "build_time" )

This results in 2 tables in the Table view, one for build SUCCESS and one for build FAILURE. Can someone explain to be why this is the case, and whether I'm missing some fundamental understanding of how to use the tool?

Screen snip of the data "shape"

SUCCESS table

FAILURE table


Solution

  • "Each flux query returns a stream of tables meaning your query can return multiple tables. Each table is created depending on the grouping. If you change the grouping at the end of your query you could merge these tables into 1. The simples example would be to just add |> group() at the end and see that now you are getting just 1 table."

    Accepting @ditoslav's comment as the answer to my question.