PrometheusRule
Scope: Namespaced
Version: v1
PrometheusRule defines recording and alerting rules for a Prometheus instance
- apiVersion
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
- kind
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
- metadata
- spec
Required value
Specification of desired alerting rule definitions for Prometheus.
- spec.groups
Content of Prometheus rule file
RuleGroup is a list of sequentially evaluated recording and alerting rules.
- spec.groups.interval
Interval determines how often rules in the group are evaluated.
Pattern:
^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
- spec.groups.limit
Limit the number of alerts an alerting rule and series a recording rule can produce. Limit is supported starting with Prometheus >= 2.31 and Thanos Ruler >= 0.24.
- spec.groups.name
Required value
Name of the rule group.
- spec.groups.partial_response_strategy
PartialResponseStrategy is only used by ThanosRuler and will be ignored by Prometheus instances. More info: https://github.com/thanos-io/thanos/blob/main/docs/components/rule.md#partial-response
Pattern:
^(?i)(abort|warn)?$
- spec.groups.rules
- spec.groups.rules.alert
Name of the alert. Must be a valid label value. Only one of
record
andalert
must be set. - spec.groups.rules.annotations
Annotations to add to each alert. Only valid for alerting rules.
- spec.groups.rules.expr
Required value
PromQL expression to evaluate.
- spec.groups.rules.for
Alerts are considered firing once they have been returned for this long.
Pattern:
^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
- spec.groups.rules.keep_firing_for
KeepFiringFor defines how long an alert will continue firing after the condition that triggered it has cleared.
Pattern:
^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
- spec.groups.rules.labels
Labels to add or overwrite.
- spec.groups.rules.record
Name of the time series to output to. Must be a valid metric name. Only one of
record
andalert
must be set.