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)