Hi Team,
I have the below custom InfluxDB query where I wanted to write an alert on
import "strings"
from(bucket: "monitoring_metrics")
|> range(start: -1h) // You can adjust the time range for your needs
|> filter(fn: (r) =>
r["_measurement"] == "jvm_memory" and
(r["_field"] == "HeapMemoryUsage.committed" or r["_field"] == "HeapMemoryUsage.used") and
r["type"] == "APP" and
(r["app_env"] == "ENV1" or r["miles_env"] == "ENV2" or r["miles_env"] == "ENV3") and
strings.containsStr(v: r.jolokia_agent_url, substr: "20888")
)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
|> map(fn: (r) => ({
r with
heap_usage_percent: (r["HeapMemoryUsage.used"] / r["HeapMemoryUsage.committed"]) * 100.0
}))
|> yield(name: "mean")
I wanted to get the alert to be based on “heap_usage_percent” field. If the value is above 90 percent.
Also each of the “app_env” have the rows which contains this value calculated. Can someone please shed some light on this how get the alert condition set ?
It looks like the alert is basing on "_measurement " as a default.
thank you