Class AlertPolicy.Condition.PrometheusQueryLanguageCondition (3.33.0)

public static final class AlertPolicy.Condition.PrometheusQueryLanguageCondition extends GeneratedMessageV3 implements AlertPolicy.Condition.PrometheusQueryLanguageConditionOrBuilder

A condition type that allows alert policies to be defined using Prometheus Query Language (PromQL).

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

A Prometheus alerting rule is described here. The semantics of a Prometheus alerting rule is described here.

A Prometheus rule group is described here. The semantics of a Prometheus rule group is described here.

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.

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).

Protobuf type google.monitoring.v3.AlertPolicy.Condition.PrometheusQueryLanguageCondition

Inheritance

Object > AbstractMessageLite<MessageType,BuilderType> > AbstractMessage > GeneratedMessageV3 > AlertPolicy.Condition.PrometheusQueryLanguageCondition

Static Fields

ALERT_RULE_FIELD_NUMBER

public static final int ALERT_RULE_FIELD_NUMBER
Field Value
TypeDescription
int

DURATION_FIELD_NUMBER

public static final int DURATION_FIELD_NUMBER
Field Value
TypeDescription
int

EVALUATION_INTERVAL_FIELD_NUMBER

public static final int EVALUATION_INTERVAL_FIELD_NUMBER
Field Value
TypeDescription
int

LABELS_FIELD_NUMBER

public static final int LABELS_FIELD_NUMBER
Field Value
TypeDescription
int

QUERY_FIELD_NUMBER

public static final int QUERY_FIELD_NUMBER
Field Value
TypeDescription
int

RULE_GROUP_FIELD_NUMBER

public static final int RULE_GROUP_FIELD_NUMBER
Field Value
TypeDescription
int

Static Methods

getDefaultInstance()

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition getDefaultInstance()
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
TypeDescription
Descriptor

newBuilder()

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition.Builder newBuilder()
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition.Builder

newBuilder(AlertPolicy.Condition.PrometheusQueryLanguageCondition prototype)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition.Builder newBuilder(AlertPolicy.Condition.PrometheusQueryLanguageCondition prototype)
Parameter
NameDescription
prototypeAlertPolicy.Condition.PrometheusQueryLanguageCondition
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition.Builder

parseDelimitedFrom(InputStream input)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseDelimitedFrom(InputStream input)
Parameter
NameDescription
inputInputStream
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
IOException

parseFrom(byte[] data)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseFrom(byte[] data)
Parameter
NameDescription
databyte[]
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
databyte[]
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseFrom(ByteString data)
Parameter
NameDescription
dataByteString
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
dataByteString
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseFrom(CodedInputStream input)
Parameter
NameDescription
inputCodedInputStream
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputCodedInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
IOException

parseFrom(InputStream input)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseFrom(InputStream input)
Parameter
NameDescription
inputInputStream
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
IOException

parseFrom(ByteBuffer data)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseFrom(ByteBuffer data)
Parameter
NameDescription
dataByteBuffer
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static AlertPolicy.Condition.PrometheusQueryLanguageCondition parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
dataByteBuffer
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition
Exceptions
TypeDescription
InvalidProtocolBufferException

parser()

public static Parser<AlertPolicy.Condition.PrometheusQueryLanguageCondition> parser()
Returns
TypeDescription
Parser<PrometheusQueryLanguageCondition>

Methods

containsLabels(String key)

public boolean containsLabels(String key)

Optional. Labels to add to or overwrite in the PromQL query result. Label names must be valid. Label values can be templatized by using variables. The only available variable names are the names of the labels in the PromQL result, including "name" and "value". "labels" may be empty.

map<string, string> labels = 4 [(.google.api.field_behavior) = OPTIONAL];

Parameter
NameDescription
keyString
Returns
TypeDescription
boolean

equals(Object obj)

public boolean equals(Object obj)
Parameter
NameDescription
objObject
Returns
TypeDescription
boolean
Overrides

getAlertRule()

public String getAlertRule()

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. This field may not exceed 2048 Unicode characters in length.

string alert_rule = 6 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
String

The alertRule.

getAlertRuleBytes()

public ByteString getAlertRuleBytes()

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. This field may not exceed 2048 Unicode characters in length.

string alert_rule = 6 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
ByteString

The bytes for alertRule.

getDefaultInstanceForType()

public AlertPolicy.Condition.PrometheusQueryLanguageCondition getDefaultInstanceForType()
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition

getDuration()

public Duration getDuration()

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.

.google.protobuf.Duration duration = 2 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
Duration

The duration.

getDurationOrBuilder()

public DurationOrBuilder getDurationOrBuilder()

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.

.google.protobuf.Duration duration = 2 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
DurationOrBuilder

getEvaluationInterval()

public Duration getEvaluationInterval()

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.

.google.protobuf.Duration evaluation_interval = 3 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
Duration

The evaluationInterval.

getEvaluationIntervalOrBuilder()

public DurationOrBuilder getEvaluationIntervalOrBuilder()

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.

.google.protobuf.Duration evaluation_interval = 3 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
DurationOrBuilder

getLabels() (deprecated)

public Map<String,String> getLabels()

Use #getLabelsMap() instead.

Returns
TypeDescription
Map<String,String>

getLabelsCount()

public int getLabelsCount()

Optional. Labels to add to or overwrite in the PromQL query result. Label names must be valid. Label values can be templatized by using variables. The only available variable names are the names of the labels in the PromQL result, including "name" and "value". "labels" may be empty.

map<string, string> labels = 4 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
int

getLabelsMap()

public Map<String,String> getLabelsMap()

Optional. Labels to add to or overwrite in the PromQL query result. Label names must be valid. Label values can be templatized by using variables. The only available variable names are the names of the labels in the PromQL result, including "name" and "value". "labels" may be empty.

map<string, string> labels = 4 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
Map<String,String>

getLabelsOrDefault(String key, String defaultValue)

public String getLabelsOrDefault(String key, String defaultValue)

Optional. Labels to add to or overwrite in the PromQL query result. Label names must be valid. Label values can be templatized by using variables. The only available variable names are the names of the labels in the PromQL result, including "name" and "value". "labels" may be empty.

map<string, string> labels = 4 [(.google.api.field_behavior) = OPTIONAL];

Parameters
NameDescription
keyString
defaultValueString
Returns
TypeDescription
String

getLabelsOrThrow(String key)

public String getLabelsOrThrow(String key)

Optional. Labels to add to or overwrite in the PromQL query result. Label names must be valid. Label values can be templatized by using variables. The only available variable names are the names of the labels in the PromQL result, including "name" and "value". "labels" may be empty.

map<string, string> labels = 4 [(.google.api.field_behavior) = OPTIONAL];

Parameter
NameDescription
keyString
Returns
TypeDescription
String

getParserForType()

public Parser<AlertPolicy.Condition.PrometheusQueryLanguageCondition> getParserForType()
Returns
TypeDescription
Parser<PrometheusQueryLanguageCondition>
Overrides

getQuery()

public String getQuery()

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.

string query = 1 [(.google.api.field_behavior) = REQUIRED];

Returns
TypeDescription
String

The query.

getQueryBytes()

public ByteString getQueryBytes()

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.

string query = 1 [(.google.api.field_behavior) = REQUIRED];

Returns
TypeDescription
ByteString

The bytes for query.

getRuleGroup()

public String getRuleGroup()

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.

string rule_group = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
String

The ruleGroup.

getRuleGroupBytes()

public ByteString getRuleGroupBytes()

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.

string rule_group = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
ByteString

The bytes for ruleGroup.

getSerializedSize()

public int getSerializedSize()
Returns
TypeDescription
int
Overrides

hasDuration()

public boolean hasDuration()

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.

.google.protobuf.Duration duration = 2 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
boolean

Whether the duration field is set.

hasEvaluationInterval()

public boolean hasEvaluationInterval()

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.

.google.protobuf.Duration evaluation_interval = 3 [(.google.api.field_behavior) = OPTIONAL];

Returns
TypeDescription
boolean

Whether the evaluationInterval field is set.

hashCode()

public int hashCode()
Returns
TypeDescription
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
TypeDescription
FieldAccessorTable
Overrides

internalGetMapField(int number)

protected MapField internalGetMapField(int number)
Parameter
NameDescription
numberint
Returns
TypeDescription
MapField
Overrides

isInitialized()

public final boolean isInitialized()
Returns
TypeDescription
boolean
Overrides

newBuilderForType()

public AlertPolicy.Condition.PrometheusQueryLanguageCondition.Builder newBuilderForType()
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition.Builder

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

protected AlertPolicy.Condition.PrometheusQueryLanguageCondition.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Parameter
NameDescription
parentBuilderParent
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition.Builder
Overrides

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Parameter
NameDescription
unusedUnusedPrivateParameter
Returns
TypeDescription
Object
Overrides

toBuilder()

public AlertPolicy.Condition.PrometheusQueryLanguageCondition.Builder toBuilder()
Returns
TypeDescription
AlertPolicy.Condition.PrometheusQueryLanguageCondition.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)
Parameter
NameDescription
outputCodedOutputStream
Overrides
Exceptions
TypeDescription
IOException