How does Influxdb sort and draw the line by default?

Viewed 15

I have a simple query for fetching some data like:

from(bucket: "almon")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "binary")
  |> filter(fn: (r) => r["_field"] == "duration_mili")
  |> group()
  |> yield(name: "mean")

and the graph I get is enter image description here

What I don't understand is why are the data points sorted by _time, but the actual line seems to not follow that. After exploring the data it seems like the line is drawn in the order of sorted tags. Why is that so and is that documented somewhere? What influences the logic for drawing the line on the graph?

1 Answers

By default InfluxDB returns data grouped by measurement+tags and then within those groups it is sorted by _time.

Because you called group() you removed that default grouping, but that doesn't force a re-sorting, so you still have the data ordered by groups even though it's no longer separated by groups.

If you add |> sort(columns: ["_time"]) after your group() that should take care of things for you.

Related