It's the "for: 5m" in the alerting rule which is suppressing it.  Try 
commenting that out.

On Monday, 10 October 2022 at 10:14:19 UTC+1 shivana...@gmail.com wrote:

> Thanks for your reply.
> I did some changes in input series like below.
>
> In the input series I am passing '1 0 1 0 1' means within 5 min interval 
> changes 3 times. restarts 3 times.
>
> Alert:
>
> groups:
> - name: distribution-service.alerts
> rules:
> - alert: Distribution_Service
> expr: changes(process_start_time_seconds{job=~"distribution-service"}[5m]) 
> > 0
> for: 5m
> labels:
> severity: critical
> annotations:
> summary: Distribution-service too many restarts (instance {{ 
> $labels.instance }})
> description: Distribution-service has restarted more than once in the last 
> 5 minutes. It might be crashlooping. VALUE = {{ $value }} LABELS = {{ 
> $labels }}
>
>
> Test_rule.yaml:
>
> rule_files:
> - ./distribution-service.yaml
>
> evaluation_interval: 1m
>
>
> tests:
> - interval: 1m
> input_series:
> - series: 'process_start_time_seconds{job="distribution-service", 
> instance="test-host"}'
> values: '1 0 1 0 1'
>
> alert_rule_test:
> - eval_time: 5m
> alertname: Distribution_Service
> exp_alerts:
> - exp_labels:
> severity: critical
> job: distribution-service
> instance: test-host
> exp_annotations:
> summary: "Distribution-service too many restarts (instance test-host)"
> description: "Distribution-service has restarted more than once in the 
> last 5 minutes. It might be crashlooping. VALUE = 6 LABELS = 
> map[instance:test-host job:distribution-service]"
>
>
> Receive Output error:
>
> Unit Testing:  distribution-service-test.yaml
>   FAILED:
>     alertname: Distribution_Service, time: 5m, 
>         exp:[
>             0:
>               Labels:{alertname="Distribution_Service", 
> instance="test-host", job="distribution-service", severity="critical"}
>               Annotations:{description="Distribution-service has restarted 
> more than once in the last 5 minutes. It might be crashlooping. VALUE = 6 
> LABELS = map[instance:test-host job:distribution-service]", 
> summary="Distribution-service too many restarts (instance test-host)"}
>             ], 
>         got:[]
>
>
>
> On Monday, October 10, 2022 at 1:46:54 PM UTC+5:30 Brian Candler wrote:
>
>> Well, if the values of the timeseries that you provide are 4 4 4 4 4, 
>> answer me this: how many times has it changed in that period?
>>
>> On Monday, 10 October 2022 at 08:38:21 UTC+1 shivana...@gmail.com wrote:
>>
>>> As you suggested I updated input series data Still getting below error.
>>>
>>> Could you please help me on which input series data I need to pass.
>>>
>>> Alert:
>>>
>>> groups:
>>> - name: distribution-service.alerts
>>> rules:
>>> - alert: Distribution_Service
>>> expr: 
>>> changes(process_start_time_seconds{job=~"distribution-service"}[5m]) >= 1
>>> for: 1m
>>> labels:
>>> severity: critical
>>> annotations:
>>> summary: Distribution-service too many restarts (instance {{ 
>>> $labels.instance }})
>>> description: Distribution-service has restarted more than once in the 
>>> last 5 minutes. It might be crashlooping. VALUE = {{ $value }} LABELS = {{ 
>>> $labels }}
>>>
>>>
>>> Test Alert:
>>>
>>> rule_files:
>>> - ./distribution-service.yaml
>>>
>>> evaluation_interval: 5m
>>>
>>>
>>> tests:
>>> - interval: 1m
>>> input_series:
>>> - series: 'process_start_time_seconds{job="distribution-service", 
>>> instance="test-host"}'
>>> values: '4 4 4 4 4'
>>>
>>> alert_rule_test:
>>> - eval_time: 5m
>>> alertname: Distribution_Service
>>> exp_alerts:
>>> - exp_labels:
>>> severity: critical
>>> job: distribution-service
>>> instance: test-host
>>> exp_annotations:
>>> summary: "Distribution-service too many restarts (instance test-host)"
>>> description: "Distribution-service has restarted more than once in the 
>>> last 5 minutes. It might be crashlooping. VALUE = 4 LABELS = 
>>> map[instance:test-host job:distribution-service]"
>>>
>>> Gerring Below Error:
>>>
>>> Unit Testing:  distribution-service-test.yaml
>>>   FAILED:
>>>     alertname: Distribution_Service, time: 5m, 
>>>         exp:[
>>>             0:
>>>               Labels:{alertname="Distribution_Service", 
>>> instance="test-host", job="distribution-service", severity="critical"}
>>>               Annotations:{description="Distribution-service has 
>>> restarted more than once in the last 5 minutes. It might be crashlooping. 
>>> VALUE = 4 LABELS = map[instance:test-host job:distribution-service]", 
>>> summary="Distribution-service too many restarts (instance test-host)"}
>>>             ], 
>>>         got:[]
>>>
>>>
>>> On Monday, October 10, 2022 at 12:24:49 PM UTC+5:30 Brian Candler wrote:
>>>
>>>> You only put one value in your test series data.  But you have a range 
>>>> vector expression, with changes() 
>>>> <https://prometheus.io/docs/prometheus/latest/querying/functions/#changes>,
>>>>  
>>>> and filtered with >1.  For the value to have changed more than 1 time 
>>>> (i.e. 
>>>> 2 or more times) you need at least 3 data points.
>>>>
>>>> For an example of a test series with multiple data points, see
>>>>
>>>> https://prometheus.io/docs/prometheus/latest/configuration/unit_testing_rules/#example
>>>>
>>>> On Monday, 10 October 2022 at 06:16:10 UTC+1 shivana...@gmail.com 
>>>> wrote:
>>>>
>>>>>  Dear all,
>>>>>
>>>>> Please find the below my prometheous alert and rules file , but I am 
>>>>> not able test the alert using promtool.
>>>>> I not able to understand where is the exact issue.
>>>>> Please kindly help me.
>>>>>
>>>>> Alert rule :
>>>>>
>>>>> groups:
>>>>> - name: distribution-service.alerts
>>>>> rules:
>>>>> - alert: Distribution_Service
>>>>> expr: 
>>>>> changes(process_start_time_seconds{job=~"distribution-service"}[5m]) > 1
>>>>> for: 5m
>>>>> labels:
>>>>> severity: critical
>>>>> annotations:
>>>>> summary: Distribution-service too many restarts (instance {{ 
>>>>> $labels.instance }})
>>>>> description: Distribution-service has restarted more than once in the 
>>>>> last 5 minutes. It might be crashlooping. VALUE = {{ $value }} LABELS = 
>>>>> {{ 
>>>>> $labels }}
>>>>>
>>>>>
>>>>>
>>>>> Rule_test_File:
>>>>>
>>>>> rule_files:
>>>>> - ./distribution-service.yaml
>>>>>
>>>>> evaluation_interval: 5m
>>>>>
>>>>>
>>>>> tests:
>>>>> - interval: 5m
>>>>> input_series:
>>>>> - series: 'process_start_time_seconds{job="distribution-service", 
>>>>> instance="test-host"}'
>>>>> values: '4'
>>>>>
>>>>> alert_rule_test:
>>>>> - eval_time: 5m
>>>>> alertname: Distribution_Service
>>>>> exp_alerts:
>>>>> - exp_labels:
>>>>> severity: warning
>>>>> job: distribution-service
>>>>> instance: test-host
>>>>> exp_annotations:
>>>>> summary: "Distribution-service too many restarts (instance test-host)"
>>>>> description: "Distribution-service has restarted more than once in the 
>>>>> last 5 minutes. It might be crashlooping. VALUE = 4 LABELS = 
>>>>> map[instance:test-host job:distribution-service]"
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>

-- 
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 prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/e423708f-b17f-49da-9553-3fdaa5484f46n%40googlegroups.com.

Reply via email to