AlertingRule [monitoring.openshift.io/v1]
Esc
Start typing to search...
On this page

AlertingRule [monitoring.openshift.io/v1]

Description

AlertingRule represents a set of user-defined Prometheus rule groups containing alerting rules. This resource is the supported method for cluster admins to create alerts based on metrics recorded by the platform monitoring stack in OpenShift, i.e. the Prometheus instance deployed to the openshift-monitoring namespace. You might use this to create custom alerting rules not shipped with OpenShift based on metrics from components such as the node_exporter, which provides machine-level metrics such as CPU usage, or kube-state-metrics, which provides metrics on Kubernetes usage.

The API is mostly compatible with the upstream PrometheusRule type from the prometheus-operator. The primary difference being that recording rules are not allowed here -- only alerting rules. For each AlertingRule resource created, a corresponding PrometheusRule will be created in the openshift-monitoring namespace. OpenShift requires admins to use the AlertingRule resource rather than the upstream type in order to allow better OpenShift specific defaulting and validation, while not modifying the upstream APIs directly.

You can find upstream API documentation for PrometheusRule resources here:

https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md

Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).

Type
`object`
Required
  • spec

Specification

PropertyTypeDescription
apiVersionstringAPIVersion 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
kindstringKind 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
metadataObjectMetaStandard object’s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
specobjectspec describes the desired state of this AlertingRule object.
statusobjectstatus describes the current state of this AlertOverrides object.

.spec

Description

spec describes the desired state of this AlertingRule object.

Type
`object`
Required
  • groups
PropertyTypeDescription
groupsarraygroups is a list of grouped alerting rules. Rule groups are the unit at which Prometheus parallelizes rule processing. All rules in a single group share a configured evaluation interval. All rules in the group will be processed together on this interval, sequentially, and all rules will be processed.
It’s common to group related alerting rules into a single AlertingRule resources, and within that resource, closely related alerts, or simply alerts with the same interval, into individual groups. You are also free to create AlertingRule resources with only a single rule group, but be aware that this can have a performance impact on Prometheus if the group is extremely large or has very complex query expressions to evaluate. Spreading very complex rules across multiple groups to allow them to be processed in parallel is also a common use-case.
groups[]objectRuleGroup is a list of sequentially evaluated alerting rules.

.spec.groups

Description

groups is a list of grouped alerting rules. Rule groups are the unit at which Prometheus parallelizes rule processing. All rules in a single group share a configured evaluation interval. All rules in the group will be processed together on this interval, sequentially, and all rules will be processed.

It’s common to group related alerting rules into a single AlertingRule resources, and within that resource, closely related alerts, or simply alerts with the same interval, into individual groups. You are also free to create AlertingRule resources with only a single rule group, but be aware that this can have a performance impact on Prometheus if the group is extremely large or has very complex query expressions to evaluate. Spreading very complex rules across multiple groups to allow them to be processed in parallel is also a common use-case.

Type
`array`

.spec.groups[]

Description

RuleGroup is a list of sequentially evaluated alerting rules.

Type
`object`
Required
  • name
  • rules
PropertyTypeDescription
intervalstringinterval is how often rules in the group are evaluated. If not specified, it defaults to the global.evaluation_interval configured in Prometheus, which itself defaults to 30 seconds. You can check if this value has been modified from the default on your cluster by inspecting the platform Prometheus configuration: The relevant field in that resource is: spec.evaluationInterval
namestringname is the name of the group.
rulesarrayrules is a list of sequentially evaluated alerting rules. Prometheus may process rule groups in parallel, but rules within a single group are always processed sequentially, and all rules are processed.
rules[]objectRule describes an alerting rule. See Prometheus documentation: - https://www.prometheus.io/docs/prometheus/latest/configuration/alerting_rules

.spec.groups[].rules

Description

rules is a list of sequentially evaluated alerting rules. Prometheus may process rule groups in parallel, but rules within a single group are always processed sequentially, and all rules are processed.

Type
`array`

.spec.groups[].rules[]

Description

Rule describes an alerting rule. See Prometheus documentation:

  • https://www.prometheus.io/docs/prometheus/latest/configuration/alerting_rules
Type
`object`
Required
  • alert
  • expr
PropertyTypeDescription
alertstringalert is the name of the alert. Must be a valid label value, i.e. may contain any Unicode character.
annotationsobject (string)annotations to add to each alert. These are values that can be used to store longer additional information that you won’t query on, such as alert descriptions or runbook links.
exprinteger-or-stringexpr is the PromQL expression to evaluate. Every evaluation cycle this is evaluated at the current time, and all resultant time series become pending or firing alerts. This is most often a string representing a PromQL expression, e.g.: mapi_current_pending_csr > mapi_max_pending_csr In rare cases this could be a simple integer, e.g. a simple "1" if the intent is to create an alert that is always firing. This is sometimes used to create an always-firing "Watchdog" alert in order to ensure the alerting pipeline is functional.
forstringfor is the time period after which alerts are considered firing after first returning results. Alerts which have not yet fired for long enough are considered pending.
labelsobject (string)labels to add or overwrite for each alert. The results of the PromQL expression for the alert will result in an existing set of labels for the alert, after evaluating the expression, for any label specified here with the same name as a label in that set, the label here wins and overwrites the previous value. These should typically be short identifying values that may be useful to query against. A common example is the alert severity, where one sets severity: warning under the labels key:

.status

Description

status describes the current state of this AlertOverrides object.

Type
`object`
PropertyTypeDescription
observedGenerationintegerobservedGeneration is the last generation change you’ve dealt with.
prometheusRuleobjectprometheusRule is the generated PrometheusRule for this AlertingRule. Each AlertingRule instance results in a generated PrometheusRule object in the same namespace, which is always the openshift-monitoring namespace.

.status.prometheusRule

Description

prometheusRule is the generated PrometheusRule for this AlertingRule. Each AlertingRule instance results in a generated PrometheusRule object in the same namespace, which is always the openshift-monitoring namespace.

Type
`object`
Required
  • name
PropertyTypeDescription
namestringname of the referenced PrometheusRule.

API endpoints

The following API endpoints are available:

  • /apis/monitoring.openshift.io/v1/alertingrules
    • GET: list objects of kind AlertingRule
  • /apis/monitoring.openshift.io/v1/namespaces/{namespace}/alertingrules
    • DELETE: delete collection of AlertingRule
    • GET: list objects of kind AlertingRule
    • POST: create an AlertingRule
  • /apis/monitoring.openshift.io/v1/namespaces/{namespace}/alertingrules/{name}
    • DELETE: delete an AlertingRule
    • GET: read the specified AlertingRule
    • PATCH: partially update the specified AlertingRule
    • PUT: replace the specified AlertingRule
  • /apis/monitoring.openshift.io/v1/namespaces/{namespace}/alertingrules/{name}/status
    • GET: read status of the specified AlertingRule
    • PATCH: partially update status of the specified AlertingRule
    • PUT: replace status of the specified AlertingRule

/apis/monitoring.openshift.io/v1/alertingrules

HTTP method
`GET`
Description
list objects of kind AlertingRule

HTTP responses

HTTP codeReponse body
200 - OKAlertingRuleList schema
401 - UnauthorizedEmpty

/apis/monitoring.openshift.io/v1/namespaces/{namespace}/alertingrules

HTTP method
`DELETE`
Description
delete collection of AlertingRule

HTTP responses

HTTP codeReponse body
200 - OKStatus schema
401 - UnauthorizedEmpty
HTTP method
`GET`
Description
list objects of kind AlertingRule

HTTP responses

HTTP codeReponse body
200 - OKAlertingRuleList schema
401 - UnauthorizedEmpty
HTTP method
`POST`
Description
create an AlertingRule

Query parameters

ParameterTypeDescription
dryRunstringWhen 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
fieldValidationstringfieldValidation 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.

Body parameters

ParameterTypeDescription
bodyAlertingRule schema

HTTP responses

HTTP codeReponse body
200 - OKAlertingRule schema
201 - CreatedAlertingRule schema
202 - AcceptedAlertingRule schema
401 - UnauthorizedEmpty

/apis/monitoring.openshift.io/v1/namespaces/{namespace}/alertingrules/{name}

Global path parameters

ParameterTypeDescription
namestringname of the AlertingRule
HTTP method
`DELETE`
Description
delete an AlertingRule

Query parameters

ParameterTypeDescription
dryRunstringWhen 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

HTTP responses

HTTP codeReponse body
200 - OKStatus schema
202 - AcceptedStatus schema
401 - UnauthorizedEmpty
HTTP method
`GET`
Description
read the specified AlertingRule

HTTP responses

HTTP codeReponse body
200 - OKAlertingRule schema
401 - UnauthorizedEmpty
HTTP method
`PATCH`
Description
partially update the specified AlertingRule

Query parameters

ParameterTypeDescription
dryRunstringWhen 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
fieldValidationstringfieldValidation 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.

HTTP responses

HTTP codeReponse body
200 - OKAlertingRule schema
401 - UnauthorizedEmpty
HTTP method
`PUT`
Description
replace the specified AlertingRule

Query parameters

ParameterTypeDescription
dryRunstringWhen 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
fieldValidationstringfieldValidation 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.

Body parameters

ParameterTypeDescription
bodyAlertingRule schema

HTTP responses

HTTP codeReponse body
200 - OKAlertingRule schema
201 - CreatedAlertingRule schema
401 - UnauthorizedEmpty

/apis/monitoring.openshift.io/v1/namespaces/{namespace}/alertingrules/{name}/status

Global path parameters

ParameterTypeDescription
namestringname of the AlertingRule
HTTP method
`GET`
Description
read status of the specified AlertingRule

HTTP responses

HTTP codeReponse body
200 - OKAlertingRule schema
401 - UnauthorizedEmpty
HTTP method
`PATCH`
Description
partially update status of the specified AlertingRule

Query parameters

ParameterTypeDescription
dryRunstringWhen 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
fieldValidationstringfieldValidation 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.

HTTP responses

HTTP codeReponse body
200 - OKAlertingRule schema
401 - UnauthorizedEmpty
HTTP method
`PUT`
Description
replace status of the specified AlertingRule

Query parameters

ParameterTypeDescription
dryRunstringWhen 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
fieldValidationstringfieldValidation 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.

Body parameters

ParameterTypeDescription
bodyAlertingRule schema

HTTP responses

HTTP codeReponse body
200 - OKAlertingRule schema
201 - CreatedAlertingRule schema
401 - UnauthorizedEmpty