Hello Team ,

I am planning to write prometheus unit test cases for my alert rule , i 
want to write prometheus unit test cases for below alert rule ,

*( 
sum(rate(grpc_server_handling_seconds_bucket{endpoint="http",grpc_method="ActivateService",grpc_service="ibm.commonservice.v1.CommonService",grpc_type="unary",job="ibm-adns-api-service",le="1",service="ibm-adns-api-service"}[15m]))
 
by 
(job)+sum(rate(grpc_server_handling_seconds_bucket{endpoint="http",grpc_method="ActivateService",grpc_service="ibm.commonservice.v1.CommonService",grpc_type="unary",job="ibm-adns-api-service",le="5",service="ibm-adns-api-service"}[15m]))
 
by (job) ) / 2 /  
sum(rate(grpc_server_handling_seconds_count{endpoint="http",grpc_method="ActivateService",grpc_service="ibm.commonservice.v1.CommonService",grpc_type="unary",job="ibm-adns-api-service",service="ibm-adns-api-service"}[15m]))
 
by (job) < 0.9*

I have written below test cases , can you please help me how to calculate 
test case values .

rule_files:
  - alert.rules

evaluation_interval: 1m

tests:
  - interval: 1m
    input_series:
      - series: 
'grpc_server_handling_seconds_bucket{endpoint="http",grpc_method="ActivateService",grpc_service="ibm.commonservice.v1.CommonService",grpc_type="unary",job="ibm-adns-api-service",le="1",service="ibm-adns-api-service"}'
      *  values: '1 1+0x2 0+0x12'*
      - series: 
'grpc_server_handling_seconds_bucket{endpoint="http",grpc_method="ActivateService",grpc_service="ibm.commonservice.v1.CommonService",grpc_type="unary",job="ibm-adns-api-service",le="5",service="ibm-adns-api-service"}'
      *  values:  0 0+0x2 1+1x12*
      - series: 
'grpc_server_handling_seconds_count{endpoint="http",grpc_method="ActivateService",grpc_service="ibm.commonservice.v1.CommonService",grpc_type="unary",job="ibm-adns-api-service",service="ibm-adns-api-service"}'
   *     values:  1 1+0x14*
    alert_rule_test:
      - eval_time: 15m
        alertname: ADNSAPISlowUnaryQueries of operation ActivateService
        exp_alerts:
          - exp_labels:
              severity: warning
              endpoint: 'http'
              grpc_method: 'ActivateService'
              grpc_service: 'ibm.commonservice.v1.CommonService'
              grpc_type: 'unary'
              job: 'ibm-adns-api-service'
              service: 'ibm-adns-api-service'
            exp_annotations:
              summary: "Detected slow response time from the operation 
ActivateService"
              description: "This is the description"
Thanks & Regards


-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/8f21d7fb-6a55-4e75-b225-fcb938ca62d3%40googlegroups.com.

Reply via email to