Alerting on Prometheus Data Tick Script HELP

kapacitor
#1

I want to Alert on Prometheus data. I have it working and alerting on a specific Value except I’m not sure how I access the prometheus “Fields” in the Element field in prometheus. I tried just spitting out the entire element using {{ index .Tags “element” }} but it doesnt work. I’m assuming this is wrong. Can’t really find much documentation about this. Tick Script I am using is below.

var warn = 1
var period = 30s
var every = 10s

// Dataframe
var data = stream
    |from()
        .database('prometheus_raw')
        .retentionPolicy('autogen')
        .measurement('kube_deployment_status_replicas_available')
    |window()
        .period(period)
        .every(every)

// Thresholds
var alert = data
    |alert()
        .id('{{ index .Tags "element"}}')
        .message('Deployment Alert - The Following Deployment has less than 1 Replica Available: {{ index .Tags "element" }}')
        .warn(lambda: "value" < warn)

// Alert
alert
        .stateChangesOnly()
        .slack()
        .channel('@marc')
#2

Did the answer you got in the #influxdb Slack channel answer this question for you?

dg