Showing one result in Grafana (jitter calculation)

Hi, I have the following code for outputing the jitter in Flux. All of it is in just one query (A) in grafana:

import “math”
entryA = from(bucket:“telegraf”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop )
|> filter(fn: (r) => r.host== “PRG-Vmontes-VElisa” )
|> filter(fn: (r) => r.name == “www.google.com”)
|> filter(fn: (r) => r._measurement == “ping” and r._field == “average_response_ms”)
|> aggregateWindow(every: 5m, fn: mean)
|> set(key: “status”, value:“present”)
|> yield(name: “A”)

entryB = from(bucket:“telegraf”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop )
|> filter(fn: (r) => r.host== “PRG-Vmontes-VElisa” )
|> filter(fn: (r) => r.name == “www.google.com”)
|> filter(fn: (r) => r._measurement == “ping” and r._field == “average_response_ms”)
|> aggregateWindow(every: 5m, fn: mean)
|> timeShift(duration: 5m, columns: [“_time”])
|> set(key: “status”, value:“future”)
|> yield(name: “B”)

final = union(tables: [entryA,entryB])
|> pivot(rowKey: [“_time”], columnKey: [“status”], valueColumn: “_value”)
|> map(fn: (r) => ({r with _value: float(v: r.present) }))
|> map(fn: (r) => ({r with _value: float(v: r.future) }))
|> toFloat()
|> map(fn: (r) => ({r with _value: ( r.future - r.present) }))
|> filter(fn: (r) => (r._value > -100 ))
|> map(fn: (r) => ({r with _value: math.abs(x: r._value ) }))
final

The output that I get is the one in the picture below

the light blue line is the one that matters since that is my jitter. The thing I want is to only output that value (variable “final”).

Can anyone tell me how i can output just this value? I would like to use it for other mathematical operations and equations to calculate the quality of my ISP.

Hi @supersers,
Can’t you just comment out yield functions from entryA and entryB ? In Flux comment is // .

and maybe add |> yield(name: "final") at the very end (instead of final) ?

Best regards,
ldrascic

Hi, that helped removing two entries “_value” but I still have 3 outputs: present, future and value (jitter calculation)

Hi @supersers,
I did same query but with cpu data and indeed in InfluxDB I get only 1 table as a result but there is a catch. Grafana interpretes columns future and present the same way column _value and therefore Grafana creates 3 fields instead of just one (_value).

You can solve this issue in one of 2 ways:

  1. You can add |> drop(columns: ["future", "present"]) before last row final. That would drop future and present columns and Grafana will show only values from _value as field.

  2. You can add Grafana transformation Filter by name and deselect unwanted fields:

Best regards,
ldrascic

Hi Idrascic,

Just to let you know:

  1. The first option does not solve the issue
  2. The second one does solve the visualization issue.

I still need to work in the problem since I need the “final” table results to be calculated with others to get my KPI.

I really appreciate your help.