Chapter 9. PrometheusRule [monitoring.coreos.com/v1] Description PrometheusRule defines recording and alerting rules for a Prometheus instance Type object Required spec 9.1. Specification Property Type Description apiVersion string 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 string 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 ObjectMeta Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata spec object Specification of desired alerting rule definitions for Prometheus. 9.1.1. .spec Description Specification of desired alerting rule definitions for Prometheus. Type object Property Type Description groups array Content of Prometheus rule file groups[] object RuleGroup is a list of sequentially evaluated recording and alerting rules. 9.1.2. .spec.groups Description Content of Prometheus rule file Type array 9.1.3. .spec.groups[] Description RuleGroup is a list of sequentially evaluated recording and alerting rules. Type object Required name Property Type Description interval string Interval determines how often rules in the group are evaluated. limit integer 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. name string Name of the rule group. partial_response_strategy string 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 rules array List of alerting and recording rules. rules[] object Rule describes an alerting or recording rule See Prometheus documentation: [alerting]( https://www.prometheus.io/docs/prometheus/latest/configuration/alerting_rules/ ) or [recording]( https://www.prometheus.io/docs/prometheus/latest/configuration/recording_rules/#recording-rules ) rule 9.1.4. .spec.groups[].rules Description List of alerting and recording rules. Type array 9.1.5. .spec.groups[].rules[] Description Rule describes an alerting or recording rule See Prometheus documentation: [alerting]( https://www.prometheus.io/docs/prometheus/latest/configuration/alerting_rules/ ) or [recording]( https://www.prometheus.io/docs/prometheus/latest/configuration/recording_rules/#recording-rules ) rule Type object Required expr Property Type Description alert string Name of the alert. Must be a valid label value. Only one of record and alert must be set. annotations object (string) Annotations to add to each alert. Only valid for alerting rules. expr integer-or-string PromQL expression to evaluate. for string Alerts are considered firing once they have been returned for this long. keep_firing_for string KeepFiringFor defines how long an alert will continue firing after the condition that triggered it has cleared. labels object (string) Labels to add or overwrite. record string Name of the time series to output to. Must be a valid metric name. Only one of record and alert must be set. 9.2. API endpoints The following API endpoints are available: /apis/monitoring.coreos.com/v1/prometheusrules GET : list objects of kind PrometheusRule /apis/monitoring.coreos.com/v1/namespaces/{namespace}/prometheusrules DELETE : delete collection of PrometheusRule GET : list objects of kind PrometheusRule POST : create a PrometheusRule /apis/monitoring.coreos.com/v1/namespaces/{namespace}/prometheusrules/{name} DELETE : delete a PrometheusRule GET : read the specified PrometheusRule PATCH : partially update the specified PrometheusRule PUT : replace the specified PrometheusRule 9.2.1. /apis/monitoring.coreos.com/v1/prometheusrules HTTP method GET Description list objects of kind PrometheusRule Table 9.1. HTTP responses HTTP code Reponse body 200 - OK PrometheusRuleList schema 401 - Unauthorized Empty 9.2.2. /apis/monitoring.coreos.com/v1/namespaces/{namespace}/prometheusrules HTTP method DELETE Description delete collection of PrometheusRule Table 9.2. HTTP responses HTTP code Reponse body 200 - OK Status schema 401 - Unauthorized Empty HTTP method GET Description list objects of kind PrometheusRule Table 9.3. HTTP responses HTTP code Reponse body 200 - OK PrometheusRuleList schema 401 - Unauthorized Empty HTTP method POST Description create a PrometheusRule Table 9.4. Query parameters Parameter Type Description dryRun string When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed fieldValidation string fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered. Table 9.5. Body parameters Parameter Type Description body PrometheusRule schema Table 9.6. HTTP responses HTTP code Reponse body 200 - OK PrometheusRule schema 201 - Created PrometheusRule schema 202 - Accepted PrometheusRule schema 401 - Unauthorized Empty 9.2.3. /apis/monitoring.coreos.com/v1/namespaces/{namespace}/prometheusrules/{name} Table 9.7. Global path parameters Parameter Type Description name string name of the PrometheusRule HTTP method DELETE Description delete a PrometheusRule Table 9.8. Query parameters Parameter Type Description dryRun string When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed Table 9.9. HTTP responses HTTP code Reponse body 200 - OK Status schema 202 - Accepted Status schema 401 - Unauthorized Empty HTTP method GET Description read the specified PrometheusRule Table 9.10. HTTP responses HTTP code Reponse body 200 - OK PrometheusRule schema 401 - Unauthorized Empty HTTP method PATCH Description partially update the specified PrometheusRule Table 9.11. Query parameters Parameter Type Description dryRun string When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed fieldValidation string fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered. Table 9.12. HTTP responses HTTP code Reponse body 200 - OK PrometheusRule schema 401 - Unauthorized Empty HTTP method PUT Description replace the specified PrometheusRule Table 9.13. Query parameters Parameter Type Description dryRun string When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed fieldValidation string fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered. Table 9.14. Body parameters Parameter Type Description body PrometheusRule schema Table 9.15. HTTP responses HTTP code Reponse body 200 - OK PrometheusRule schema 201 - Created PrometheusRule schema 401 - Unauthorized Empty

Commands: