PrometheusRule [prometheusrules.monitoring.coreos.com/v1]

描述
The `PrometheusRule` custom resource definition (CRD) defines [alerting](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/) and [recording](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/) rules to be evaluated by `Prometheus` or `ThanosRuler` objects. `Prometheus` and `ThanosRuler` objects select `PrometheusRule` objects using label and namespace selectors.
类型
object
必填
spec

规格

属性类型描述
apiVersionstring

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

kindstring

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

metadataObjectMeta

ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.

specobject

Specification of desired alerting rule definitions for Prometheus.

.spec

描述
Specification of desired alerting rule definitions for Prometheus.
类型
object
属性类型描述
groupsarray

Content of Prometheus rule file

.spec.groups

描述
Content of Prometheus rule file
类型
array

.spec.groups[]

描述
RuleGroup is a list of sequentially evaluated recording and alerting rules.
类型
object
必填
name
属性类型描述
intervalstring

Interval determines how often rules in the group are evaluated.

labelsobject

Labels to add or overwrite before storing the result for its rules. The labels defined at the rule level take precedence.

It requires Prometheus >= 3.0.0. The field is ignored for Thanos Ruler.

limitinteger

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.

namestring

Name of the rule group.

partial_response_strategystring

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

query_offsetstring

Defines the offset the rule evaluation timestamp of this particular group by the specified duration into the past.

It requires Prometheus >= v2.53.0. It is not supported for ThanosRuler.

rulesarray

List of alerting and recording rules.

.spec.groups[].labels

描述
Labels to add or overwrite before storing the result for its rules. The labels defined at the rule level take precedence. It requires Prometheus >= 3.0.0. The field is ignored for Thanos Ruler.
类型
object

.spec.groups[].rules

描述
List of alerting and recording rules.
类型
array

.spec.groups[].rules[]

描述
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
类型
object
必填
expr
属性类型描述
alertstring

Name of the alert. Must be a valid label value. Only one of record and alert must be set.

annotationsobject

Annotations to add to each alert. Only valid for alerting rules.

exprinteger|string

PromQL expression to evaluate.

forstring

Alerts are considered firing once they have been returned for this long.

keep_firing_forstring

KeepFiringFor defines how long an alert will continue firing after the condition that triggered it has cleared.

labelsobject

Labels to add or overwrite.

recordstring

Name of the time series to output to. Must be a valid metric name. Only one of record and alert must be set.

.spec.groups[].rules[].annotations

描述
Annotations to add to each alert. Only valid for alerting rules.
类型
object

.spec.groups[].rules[].labels

描述
Labels to add or overwrite.
类型
object

API 端点

可用的 API 端点如下:

  • /apis/monitoring.coreos.com/v1/namespaces/{namespace}/prometheusrules
    • DELETE: delete collection of PrometheusRule
    • GET: list objects of kind PrometheusRule
    • POST: create a new PrometheusRule
  • /apis/monitoring.coreos.com/v1/namespaces/{namespace}/prometheusrules/{name}
    • DELETE: delete the specified PrometheusRule
    • GET: read the specified PrometheusRule
    • PATCH: partially update the specified PrometheusRule
    • PUT: replace the specified PrometheusRule

/apis/monitoring.coreos.com/v1/namespaces/{namespace}/prometheusrules

HTTP 方法
DELETE
描述
delete collection of PrometheusRule
HTTP 响应
HTTP 状态码响应体
200 - OKStatus schema
401 - UnauthorizedEmpty
HTTP 方法
GET
描述
list objects of kind PrometheusRule
HTTP 响应
HTTP 状态码响应体
200 - OKPrometheusRuleList schema
401 - UnauthorizedEmpty
HTTP 方法
POST
描述
create a new PrometheusRule
查询参数
参数类型描述
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.
请求体参数
参数类型描述
bodyPrometheusRule schemaapplication/json formatted
HTTP 响应
HTTP 状态码响应体
200 - OKPrometheusRule schema
201 - CreatedPrometheusRule schema
202 - AcceptedPrometheusRule schema
401 - UnauthorizedEmpty

/apis/monitoring.coreos.com/v1/namespaces/{namespace}/prometheusrules/{name}

HTTP 方法
DELETE
描述
delete the specified PrometheusRule
查询参数
参数类型描述
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 响应
HTTP 状态码响应体
200 - OKStatus schema
202 - AcceptedStatus schema
401 - UnauthorizedEmpty
HTTP 方法
GET
描述
read the specified PrometheusRule
HTTP 响应
HTTP 状态码响应体
200 - OKPrometheusRule schema
401 - UnauthorizedEmpty
HTTP 方法
PATCH
描述
partially update the specified PrometheusRule
查询参数
参数类型描述
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 响应
HTTP 状态码响应体
200 - OKPrometheusRule schema
401 - UnauthorizedEmpty
HTTP 方法
PUT
描述
replace the specified PrometheusRule
查询参数
参数类型描述
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.
请求体参数
参数类型描述
bodyPrometheusRule schemaapplication/json formatted
HTTP 响应
HTTP 状态码响应体
200 - OKPrometheusRule schema
201 - CreatedPrometheusRule schema
401 - UnauthorizedEmpty