Prometheus Alerting Rules: Comparing metrics in expression with a value from label

11/7/2018

I'm trying to figure out if this is possible through Prometheus:

I have a label on a deployment which specifies a value:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    APP: my_app
    OWNER1: my_username
    CUSTOM_VALUE: '4' # My custom label which defines a value

In Prometheus, is it possible for me to create a rule where the expression compares a metric with this value?

e.g.

alert: compare_values
expr: kube_deployment_status_replicas_available != 'CUSTOM_VALUE' # Is this even possible?
for: 1m
labels:
  severity: page
annotations:
  summary: Compare

The idea is to define certain thresholds for different applications and dynamically compare the metrics (latency, number of deployments, etc) to these thresholds set in the respective labels.

-- BlueChips23
kubernetes
prometheus
prometheus-alertmanager

0 Answers