Monitor State Change Not Working Correctly on Notification Rule

Hello, I have read extensively on the monitor state change but am not able to figure out the solution here. I have the below query within a notification rule:


statuses = monitor["from"](start: -15m)
statusChanges = statuses |> monitor.stateChangesOnly()

//    |> monitor.stateChanges(fromLevel: "any", toLevel: "crit")
// crit = statuses |> filter(fn: (r) => r["_level"] == "crit")
all_statuses = statusChanges |> filter(fn: (r) => r["_time"] >= experimental["subDuration"](from: now(), d: 30s))

However when I run it returns far more than just state changes and does not seem to do any filtering. Does anyone have experience with this or been able to use state change only function succesfully?

Hello @gtl,
Have you seen this? stateChangesOnly() does not work as expected · Issue #4179 · influxdata/flux · GitHub
Looks like you might need to include:

|> sort(columns: ["_time"])