Hi, I’m playing with new provisioning API for alerts and I’m getting error when I’m trying to create rule with instant PromQL query and “empty” time range:
ERRO[2022-08-22T16:12:02.643+00:00] RPC /ia.v1beta1.Rules/CreateAlertRule done in 24.130287ms with unexpected error: status: 500, body: {"message":"invalid alert query A: invalid relative time range: {From:0s To:0s}","traceID":"00000000000000000000000000000000"} request=287c2b10-2235-11ed-b296-0242ac150002
Same error I’m getting when I’m trying to create same rule with Grafana UI and time range from: now to: now. However action Run queries works fine and I’m getting correct query results.
It’s not clear what time range should I specify for the instant query? It’s just has no sense.
We have new API documentation for the provisioning APIs in the next version. The AlertQuery type has a parameter for QueryType, which is a string. Have you tried providing the string instant?
I did some testing using developer tools in my browser to see what the AlertQuery type looks like when I create an instant query alert and saw that it used the QueryType of “instant” in the request. The copy as curl option in developer tools is a really useful tool when you’re trying to see what some of these requests look like.
Hi i also have the same error, this is the data block that i have added, the requirement is to evaluate the instant query given and check if it passes the threshold. What is the changes that i have to make.
data:
- refId: A
datasourceUid: ‘P4169E866C3094E38’
model:
conditions:
- evaluator:
params:
- 10
type: gt
operator:
type: and
query:
params:
- A
reducer:
type: last
type: query
datasource:
type: expr
uid: ‘P4169E866C3094E38’
expression: (sum(rate(istio_requests_total{reporter=“destination”, response_code=~“5.*”, destination_workload_namespace=~“vn-dev”}[2m])) by (destination_workload) / sum(rate(istio_requests_total{reporter=“destination”, destination_workload_namespace=~“vn-dev”}[2m])) by (destination_workload))
intervalMs: 1000
maxDataPoints: 43200
queryType: ‘instant’
refId: A
type: math
Is there any update on this issue? the answer above referring to the docs, shows that there was not any attempt made even to investigate the issue. The docs mention nothing about the whole yaml structure.