Skip to content

PrometheusRule [monitoring.coreos.com/v1]

Description

The PrometheusRule custom resource definition (CRD) defines alerting and recording rules to be evaluated by Prometheus or ThanosRuler objects.

Prometheus and ThanosRuler objects select PrometheusRule objects using label and namespace selectors.

Type
`object`
Required
  • spec

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 spec defines the specification of desired alerting rule definitions for Prometheus.
status object status defines the status subresource. It is under active development and is updated only when the "StatusForConfigurationResources" feature gate is enabled.
Most recent observed status of the PrometheusRule. Read-only. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

.spec

Description
spec defines the specification of desired alerting rule definitions for Prometheus.
Type
`object`
Property Type Description
groups array groups defines the content of Prometheus rule file
groups[] object RuleGroup is a list of sequentially evaluated recording and alerting rules.

.spec.groups

Description
groups defines the content of Prometheus rule file
Type
`array`

.spec.groups[]

Description
RuleGroup is a list of sequentially evaluated recording and alerting rules.
Type
`object`
Required
  • name
Property Type Description
interval string interval defines how often rules in the group are evaluated.
labels object (string) labels define the 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.
limit integer limit defines 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 defines the name of the rule group.
partial_response_strategy string partial_response_strategy 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_offset string query_offset 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.
rules array rules defines the list of alerting and recording rules.
rules[] object Rule describes an alerting or recording rule See Prometheus documentation: alerting or recording rule

.spec.groups[].rules

Description
rules defines the list of alerting and recording rules.
Type
`array`

.spec.groups[].rules[]

Description
Rule describes an alerting or recording rule See Prometheus documentation: alerting or recording rule
Type
`object`
Required
  • expr
Property Type Description
alert string alert defines the name of the alert. Must be a valid label value. Only one of record and alert must be set.
annotations object (string) annotations defines annotations to add to each alert. Only valid for alerting rules.
expr integer-or-string expr defines the PromQL expression to evaluate.
for string for defines how alerts are considered firing once they have been returned for this long.
keep_firing_for string keep_firing_for defines how long an alert will continue firing after the condition that triggered it has cleared.
labels object (string) labels defines labels to add or overwrite.
record string record defines the name of the time series to output to. Must be a valid metric name. Only one of record and alert must be set.

.status

Description

status defines the status subresource. It is under active development and is updated only when the "StatusForConfigurationResources" feature gate is enabled.

Most recent observed status of the PrometheusRule. Read-only. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

Type
`object`
Property Type Description
bindings array bindings defines the list of workload resources (Prometheus, PrometheusAgent, ThanosRuler or Alertmanager) which select the configuration resource.
bindings[] object WorkloadBinding is a link between a configuration resource and a workload resource.

.status.bindings

Description
bindings defines the list of workload resources (Prometheus, PrometheusAgent, ThanosRuler or Alertmanager) which select the configuration resource.
Type
`array`

.status.bindings[]

Description
WorkloadBinding is a link between a configuration resource and a workload resource.
Type
`object`
Required
  • group
  • name
  • namespace
  • resource
Property Type Description
conditions array conditions defines the current state of the configuration resource when bound to the referenced Workload object.
conditions[] object ConfigResourceCondition describes the status of configuration resources linked to Prometheus, PrometheusAgent, Alertmanager or ThanosRuler.
group string group defines the group of the referenced resource.
name string name defines the name of the referenced object.
namespace string namespace defines the namespace of the referenced object.
resource string resource defines the type of resource being referenced (e.g. Prometheus, PrometheusAgent, ThanosRuler or Alertmanager).

.status.bindings[].conditions

Description
conditions defines the current state of the configuration resource when bound to the referenced Workload object.
Type
`array`

.status.bindings[].conditions[]

Description
ConfigResourceCondition describes the status of configuration resources linked to Prometheus, PrometheusAgent, Alertmanager or ThanosRuler.
Type
`object`
Required
  • lastTransitionTime
  • status
  • type
Property Type Description
lastTransitionTime string lastTransitionTime defines the time of the last update to the current status property.
message string message defines the human-readable message indicating details for the condition’s last transition.
observedGeneration integer observedGeneration defines the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[].observedGeneration is 9, the condition is out of date with respect to the current state of the object.
reason string reason for the condition’s last transition.
status string status of the condition.
type string type of the condition being reported. Currently, only "Accepted" is supported.

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
  • /apis/monitoring.coreos.com/v1/namespaces/{namespace}/prometheusrules/{name}/status

    • GET: read status of the specified PrometheusRule
    • PATCH: partially update status of the specified PrometheusRule
    • PUT: replace status of the specified PrometheusRule

/apis/monitoring.coreos.com/v1/prometheusrules

HTTP method
`GET`
Description
list objects of kind PrometheusRule

HTTP responses

HTTP code Reponse body
200 - OK PrometheusRuleList schema
401 - Unauthorized Empty

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

HTTP method
`DELETE`
Description
delete collection of PrometheusRule

HTTP responses

HTTP code Reponse body
200 - OK Status schema
401 - Unauthorized Empty
HTTP method
`GET`
Description
list objects of kind PrometheusRule

HTTP responses

HTTP code Reponse body
200 - OK PrometheusRuleList schema
401 - Unauthorized Empty
HTTP method
`POST`
Description
create a PrometheusRule

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.

Body parameters

Parameter Type Description
body PrometheusRule schema

HTTP responses

HTTP code Reponse body
200 - OK PrometheusRule schema
201 - Created PrometheusRule schema
202 - Accepted PrometheusRule schema
401 - Unauthorized Empty

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

Global path parameters

Parameter Type Description
name string name of the PrometheusRule
HTTP method
`DELETE`
Description
delete a PrometheusRule

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

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

HTTP responses

HTTP code Reponse body
200 - OK PrometheusRule schema
401 - Unauthorized Empty
HTTP method
`PATCH`
Description
partially update the specified PrometheusRule

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.

HTTP responses

HTTP code Reponse body
200 - OK PrometheusRule schema
401 - Unauthorized Empty
HTTP method
`PUT`
Description
replace the specified PrometheusRule

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.

Body parameters

Parameter Type Description
body PrometheusRule schema

HTTP responses

HTTP code Reponse body
200 - OK PrometheusRule schema
201 - Created PrometheusRule schema
401 - Unauthorized Empty

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

Global path parameters

Parameter Type Description
name string name of the PrometheusRule
HTTP method
`GET`
Description
read status of the specified PrometheusRule

HTTP responses

HTTP code Reponse body
200 - OK PrometheusRule schema
401 - Unauthorized Empty
HTTP method
`PATCH`
Description
partially update status of the specified PrometheusRule

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.

HTTP responses

HTTP code Reponse body
200 - OK PrometheusRule schema
401 - Unauthorized Empty
HTTP method
`PUT`
Description
replace status of the specified PrometheusRule

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.

Body parameters

Parameter Type Description
body PrometheusRule schema

HTTP responses

HTTP code Reponse body
200 - OK PrometheusRule schema
201 - Created PrometheusRule schema
401 - Unauthorized Empty