PCA (Prometheus Certified Associate) sample exam question with answer 36

Question:
Which of the following is the correct syntax for defining a custom label in an alerting rule?

  1. ...
    alert: HighCPUUsage
    expr: 100 * (1 - rate(node_cpu{mode="idle"}[5m])) > 80
    labels:
      severity: warning
    ...
  2. ...
    alert: HighCPUUsage
    expr: 100 * (1 - rate(node_cpu{mode="idle"}[5m])) > 80
    annotations:
      severity: warning
    ...
  3. ...
    alert: HighCPUUsage
    expr: 100 * (1 - rate(node_cpu{mode="idle"}[5m])) > 80
    label:
      severity: warning
    ...
  4. ...
    alert: HighCPUUsage
    expr: 100 * (1 - rate(node_cpu{mode="idle"}[5m])) > 80
    annotation:
      severity: warning
    ...
Answer:
A - Labels are used to attach metadata to alerts in Prometheus.
The correct syntax for defining a custom label in an alerting rule is to include the labels keyword followed by a list of key-value pairs.
Option B uses the annotations keyword instead of labels.
Options C and D have typos in the keywords (label instead of labels and annotation instead of annotations)