Reputation: 137
I am trying to create an MQL alert policy in GCP monitoring via the console but when I try to save it it keeps giving me an error. "Error: Unable to save alerting policy. Request contains an invalid argument."
As far as I can see my query is valid. There are no issues reported in the query editor and it displays the chart I was expecting.
This is the json view, which is generated by the policy creator:
{
"displayName": "kube_deployment_replicas_mismatch",
"documentation": {
"content": "The expected number of replicas have not been available for 15 minutes or longer",
"mimeType": "text/markdown"
},
"userLabels": {
"type": "application"
},
"conditions": [
{
"displayName": "kube_deployment_replicas_mismatch",
"conditionMonitoringQueryLanguage": {
"duration": "900s",
"trigger": {
"count": 1
},
"evaluationMissingData": "EVALUATION_MISSING_DATA_INACTIVE",
"query": "{ kubernetes.io/anthos/kube_deployment_spec_replicas\n; kubernetes.io/anthos/kube_deployment_status_replicas_available }\n| [metric.deployment]\n| ratio\n| condition val() != 1"
}
}
],
"alertStrategy": {
"autoClose": "604800s"
},
"combiner": "OR",
"enabled": true,
"notificationChannels": [
"projects/xxxxxxxxx/notificationChannels/xxxxxxxxxxx"
]
}
Upvotes: 1
Views: 1167
Reputation: 3256
Some MQL table operations require their inputs to be aligned.
If you pass unaligned input to these table operations,MQL automatically aligns the data for you.
But this can cause problems in an alerting query. In these cases, it will be prevented from creating an alerting policy that uses this type of query.
One solution is to add | window 30s
after the operation that implicitly aligns the data for you.
Trying the same for the query you provided works with the alert creation.
Here is the sample query:
fetch istio_canonical_service
| metric 'istio.io/service/server/request_count'
| { filter (metric.response_code < 499); ident }
| group_by [metric.destination_service_namespace]
| ratio
| fraction_less_than(0.50)
| condition val() > 0.20
| window 30s # correctly sets the window to 30s
Before adding | window 30s
I was also getting the same after adding it, the alert policy has been created successfully.
For more information follow this official doc.
Upvotes: 4