How to query for transition (value change) in tag?

(Not sure if “Store” is the right category, but there’s no “Query” or “Mine Data”)

Simplified background: I’m using Telegraf to write values collected from an instrument to InfluxDB (v 1.5.4), and with each value I write a tag called “alarm_status” that can be LO, HI, or OK. Currently, I’m also writing another tag called “alarm_change” that is true when “alarm_status” changes value, e.g. the previous value was LO and the current value is OK. I would like to eliminate this second tag for various efficiency reasons.

Can I construct a query to get the times and values for which there was a transition in alarm_status ? (without using the “alarm_change” tag)

Hello @wiwo,
I’m so sorry for the delay, sometimes questions get lost.
Does this help you:
https://v2.docs.influxdata.com/v2.0/reference/flux/stdlib/monitor/statechangesonly/

@Anaisdg I have the same question as @wiwo but the answer you have given doesn’t suit my needs. Let me explain below what I try to do:

In my application, I’m sending a field value named app_version and this is sent only during the booting process. So if I have 3 new deployments of my app with each having a new version, I have only 3 metrics sent from my app. Now, I want to trigger an alert on slack if the new deployment version is different from the previous one. I can use last() to get the latest value of this field, however, I do not see an option to compare it with the previous value.

@shankardevy Hey, I’m probably late to answer your question. I stumbled upon your question by mistake.

One thing you can do is instead of using last, use the top to get the last 2 values which are sorted by time. Then simply compare your values.