Here you go, this is from the table command onwards:
| table _time, Last_Received, Minutes_Ago, Panel, Status
| streamstats count by Panel
| where count <= 2
`comment("The above streamstats and where command is so that include only the last two results")`
| stats list(Status) as status by Panel
| eval status = case(match(mvindex(status,0), "normal") AND match(mvindex(status,1), "normal"), "System status has not changed", match(mvindex(status, 0), "normal"), "System has returned to normal", match(mvindex(status, 0), "degraded"), "System is degraded")
| eval system_status = case(match(status, "System is degraded"), 0, match(status, "System status has not changed") OR match(status, "System has returned to normal"), 1)
| eventstats sum(system_status) as sum_status count(Panel) as panel_count
| eval overall_status = if(sum_status / panel_count != 1, "System status is degraded", "System is running normally")
... View more