Extract bits from integer stored in Influx DB to display in Grafana

75 Views Asked by At

I have a status word where each bit has a particular meaning. I need to extract all bits and display messages in Grafana relevant to bit values and generate alerts basing on some extracted bits.

I can't figure out how to extract bits in rows, not in columns, using Flux.

For example, I have integer field Alarm:

(https://i.stack.imgur.com/bg0Ha.png)

And I would like to extract all bits from it like this for further processing:

(https://i.stack.imgur.com/Rk0I9.png)

I know how to extract bits into columns using Flux: import "bitwise" ... |> map(fn: (r) => ({ r with bit00: bool(v: bitwise.sand(a: r._value, b: 1) / 1), bit01: bool(v: bitwise.sand(a: r._value, b: 2) / 2), bit02: bool(v: bitwise.sand(a: r._value, b: 4) / 4), ... })) But this gives bits as columns, not rows as I need...

0

There are 0 best solutions below