# Cloud Monitoring V3 API - Class Google::Cloud::Monitoring::V3::AlertPolicy::Condition::PrometheusQueryLanguageCondition (v1.10.0)

1.10.0 (latest) 1.9.0 1.8.0 1.7.1 1.6.1 1.5.1 1.4.0 1.3.0 1.2.0 1.1.0 1.0.1 0.18.0 0.17.0 0.16.0 0.15.2 0.14.0 0.13.0 0.12.1 0.11.0 0.10.0 0.9.0 0.8.0 0.7.1 Reference documentation and code samples for the Cloud Monitoring V3 API class Google::Cloud::Monitoring::V3::AlertPolicy::Condition::PrometheusQueryLanguageCondition.

A condition type that allows alerting policies to be defined using
[Prometheus Query Language
(PromQL)](https://prometheus.io/docs/prometheus/latest/querying/basics/).


The PrometheusQueryLanguageCondition message contains information
from a Prometheus alerting rule and its associated rule group.

A Prometheus alerting rule is described
[here](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/).
The semantics of a Prometheus alerting rule is described
[here](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#rule).

A Prometheus rule group is described
[here](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/).
The semantics of a Prometheus rule group is described
[here](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#rule_group).

Because Cloud Alerting has no representation of a Prometheus rule
group resource, we must embed the information of the parent rule
group inside each of the conditions that refer to it. We must also
update the contents of all Prometheus alerts in case the information
of their rule group changes.

<br />

The PrometheusQueryLanguageCondition protocol buffer combines the
information of the corresponding rule group and alerting rule.
The structure of the PrometheusQueryLanguageCondition protocol buffer
does NOT mimic the structure of the Prometheus rule group and alerting
rule YAML declarations. The PrometheusQueryLanguageCondition protocol
buffer may change in the future to support future rule group and/or
alerting rule features. There are no new such features at the present
time (2023-06-26).

## Inherits

- Object

## Extended By

- Google::Protobuf::MessageExts::ClassMethods

## Includes

- Google::Protobuf::MessageExts

## Methods

### #alert_rule

    def alert_rule() -> ::String

**Returns**

- (::String) --- Optional. The alerting rule name of this alert in the corresponding Prometheus configuration file.

  Some external tools may require this field to be populated correctly
  in order to refer to the original Prometheus configuration file.
  The rule group name and the alert name are necessary to update the
  relevant AlertPolicies in case the definition of the rule group changes
  in the future.

  This field is optional. If this field is not empty, then it must be a
  [valid Prometheus label
  name](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels).
  This field may not exceed 2048 Unicode characters in length.

### #alert_rule=

    def alert_rule=(value) -> ::String

**Parameter**

- **value** (::String) --- Optional. The alerting rule name of this alert in the corresponding Prometheus configuration file.


  Some external tools may require this field to be populated correctly
  in order to refer to the original Prometheus configuration file.
  The rule group name and the alert name are necessary to update the
  relevant AlertPolicies in case the definition of the rule group changes
  in the future.

  This field is optional. If this field is not empty, then it must be a
  [valid Prometheus label
  name](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels).
  This field may not exceed 2048 Unicode characters in length.
**Returns**

- (::String) --- Optional. The alerting rule name of this alert in the corresponding Prometheus configuration file.

  Some external tools may require this field to be populated correctly
  in order to refer to the original Prometheus configuration file.
  The rule group name and the alert name are necessary to update the
  relevant AlertPolicies in case the definition of the rule group changes
  in the future.

  This field is optional. If this field is not empty, then it must be a
  [valid Prometheus label
  name](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels).
  This field may not exceed 2048 Unicode characters in length.

### #disable_metric_validation

    def disable_metric_validation() -> ::Boolean

**Returns**

- (::Boolean) --- Optional. Whether to disable metric existence validation for this condition.

  This allows alerting policies to be defined on metrics that do not yet
  exist, improving advanced customer workflows such as configuring
  alerting policies using Terraform.

  Users with the `monitoring.alertPolicyViewer` role are able to see the
  name of the non-existent metric in the alerting policy condition.

### #disable_metric_validation=

    def disable_metric_validation=(value) -> ::Boolean

**Parameter**

- **value** (::Boolean) --- Optional. Whether to disable metric existence validation for this condition.


  This allows alerting policies to be defined on metrics that do not yet
  exist, improving advanced customer workflows such as configuring
  alerting policies using Terraform.

  Users with the `monitoring.alertPolicyViewer` role are able to see the
  name of the non-existent metric in the alerting policy condition.
**Returns**

- (::Boolean) --- Optional. Whether to disable metric existence validation for this condition.

  This allows alerting policies to be defined on metrics that do not yet
  exist, improving advanced customer workflows such as configuring
  alerting policies using Terraform.

  Users with the `monitoring.alertPolicyViewer` role are able to see the
  name of the non-existent metric in the alerting policy condition.

### #duration

    def duration() -> ::Google::Protobuf::Duration

**Returns**

- ([::Google::Protobuf::Duration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Protobuf-Duration)) --- Optional. Alerts are considered firing once their PromQL expression was evaluated to be "true" for this long. Alerts whose PromQL expression was not evaluated to be "true" for long enough are considered pending. Must be a non-negative duration or missing. This field is optional. Its default value is zero.

### #duration=

    def duration=(value) -> ::Google::Protobuf::Duration

**Parameter**

- **value** ([::Google::Protobuf::Duration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Protobuf-Duration)) --- Optional. Alerts are considered firing once their PromQL expression was evaluated to be "true" for this long. Alerts whose PromQL expression was not evaluated to be "true" for long enough are considered pending. Must be a non-negative duration or missing. This field is optional. Its default value is zero.
**Returns**

- ([::Google::Protobuf::Duration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Protobuf-Duration)) --- Optional. Alerts are considered firing once their PromQL expression was evaluated to be "true" for this long. Alerts whose PromQL expression was not evaluated to be "true" for long enough are considered pending. Must be a non-negative duration or missing. This field is optional. Its default value is zero.

### #evaluation_interval

    def evaluation_interval() -> ::Google::Protobuf::Duration

**Returns**

- ([::Google::Protobuf::Duration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Protobuf-Duration)) --- Optional. How often this rule should be evaluated. Must be a positive multiple of 30 seconds or missing. This field is optional. Its default value is 30 seconds. If this PrometheusQueryLanguageCondition was generated from a Prometheus alerting rule, then this value should be taken from the enclosing rule group.

### #evaluation_interval=

    def evaluation_interval=(value) -> ::Google::Protobuf::Duration

**Parameter**

- **value** ([::Google::Protobuf::Duration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Protobuf-Duration)) --- Optional. How often this rule should be evaluated. Must be a positive multiple of 30 seconds or missing. This field is optional. Its default value is 30 seconds. If this PrometheusQueryLanguageCondition was generated from a Prometheus alerting rule, then this value should be taken from the enclosing rule group.
**Returns**

- ([::Google::Protobuf::Duration](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Protobuf-Duration)) --- Optional. How often this rule should be evaluated. Must be a positive multiple of 30 seconds or missing. This field is optional. Its default value is 30 seconds. If this PrometheusQueryLanguageCondition was generated from a Prometheus alerting rule, then this value should be taken from the enclosing rule group.

### #labels

    def labels() -> ::Google::Protobuf::Map{::String => ::String}

**Returns**

- (::Google::Protobuf::Map{::String =\> ::String}) --- Optional. Labels to add to or overwrite in the PromQL query result. Label names [must be
  valid](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). Label values can be [templatized by using
  variables](https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars). The only available variable names are the names of the labels in the PromQL result, including "**name**" and "value". "labels" may be empty.

### #labels=

    def labels=(value) -> ::Google::Protobuf::Map{::String => ::String}

**Parameter**

- **value** (::Google::Protobuf::Map{::String =\> ::String}) --- Optional. Labels to add to or overwrite in the PromQL query result. Label names [must be
  valid](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). Label values can be [templatized by using
  variables](https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars). The only available variable names are the names of the labels in the PromQL result, including "**name**" and "value". "labels" may be empty.
**Returns**

- (::Google::Protobuf::Map{::String =\> ::String}) --- Optional. Labels to add to or overwrite in the PromQL query result. Label names [must be
  valid](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). Label values can be [templatized by using
  variables](https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars). The only available variable names are the names of the labels in the PromQL result, including "**name**" and "value". "labels" may be empty.

### #query

    def query() -> ::String

**Returns**

- (::String) --- Required. The PromQL expression to evaluate. Every evaluation cycle this expression is evaluated at the current time, and all resultant time series become pending/firing alerts. This field must not be empty.

### #query=

    def query=(value) -> ::String

**Parameter**

- **value** (::String) --- Required. The PromQL expression to evaluate. Every evaluation cycle this expression is evaluated at the current time, and all resultant time series become pending/firing alerts. This field must not be empty.
**Returns**

- (::String) --- Required. The PromQL expression to evaluate. Every evaluation cycle this expression is evaluated at the current time, and all resultant time series become pending/firing alerts. This field must not be empty.

### #rule_group

    def rule_group() -> ::String

**Returns**

- (::String) --- Optional. The rule group name of this alert in the corresponding Prometheus configuration file.

  Some external tools may require this field to be populated correctly
  in order to refer to the original Prometheus configuration file.
  The rule group name and the alert name are necessary to update the
  relevant AlertPolicies in case the definition of the rule group changes
  in the future.

  This field is optional. If this field is not empty, then it must
  contain a valid UTF-8 string.
  This field may not exceed 2048 Unicode characters in length.

### #rule_group=

    def rule_group=(value) -> ::String

**Parameter**

- **value** (::String) --- Optional. The rule group name of this alert in the corresponding Prometheus configuration file.


  Some external tools may require this field to be populated correctly
  in order to refer to the original Prometheus configuration file.
  The rule group name and the alert name are necessary to update the
  relevant AlertPolicies in case the definition of the rule group changes
  in the future.

  This field is optional. If this field is not empty, then it must
  contain a valid UTF-8 string.
  This field may not exceed 2048 Unicode characters in length.
**Returns**

- (::String) --- Optional. The rule group name of this alert in the corresponding Prometheus configuration file.

  Some external tools may require this field to be populated correctly
  in order to refer to the original Prometheus configuration file.
  The rule group name and the alert name are necessary to update the
  relevant AlertPolicies in case the definition of the rule group changes
  in the future.

  This field is optional. If this field is not empty, then it must
  contain a valid UTF-8 string.
  This field may not exceed 2048 Unicode characters in length.