Yes I fixed that, After that getting below error.
Unit Testing: pod-restart_test.yaml
FAILED:
alertname: KubernetesPodCrashLooping, time: 2m,
exp:[
0:
Labels:{alertname="KubernetesPodCrashLooping",
instance="test_host", pod="test_pod", severity="warning"}
Annotations:{description="Pod test_pod is crash looping\n
VALUE = 4\n LABELS = {{ $labels }}", summary="Kubernetes pod crash
looping (instance test_host)"}
],
got:[]
On Tuesday, January 10, 2023 at 1:06:10 PM UTC+5:30 [email protected] wrote:
> Looks like:
>
> "WARNING: no file match pattern /testdata/pod-restar.yaml" is the relevant
> bit.
>
> You've got a typo in rules_file in the test file.
>
> David
>
> On Tue, 10 Jan 2023 at 18:31, Shivanand Shete <[email protected]>
> 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 File:
> > groups:
> > - name: pod-restart.alerts
> > rules:
> > - alert: KubernetesPodCrashLooping
> > expr: increase(kube_pod_container_status_restarts_total[1m]) > 3
> > for: 2m
> > labels:
> > severity: warning
> > annotations:
> > summary: Kubernetes pod crash looping (instance {{ $labels.instance }})
> > description: "Pod {{ $labels.pod }} is crash looping\n VALUE = {{ $value
> }}\n LABELS = {{ $labels }}"
> >
> >
> > Rule Test File content:
> >
> >
> > evaluation_interval: 1m
> >
> >
> > tests:
> > - interval: 1m
> > input_series:
> > - series: kube_pod_container_status_restarts_total{pod="test_pod",
> instance="test_host" }
> > values: 5 10 15 20
> >
> > alert_rule_test:
> > - eval_time: 2m
> > alertname: KubernetesPodCrashLooping
> > exp_alerts:
> > - exp_labels:
> > pod: test_pod
> > instance: test_host
> > severity: warning
> > exp_annotations:
> > summary: Kubernetes pod crash looping (instance test_host)
> > description: "Pod test_pod is crash looping\n VALUE = 4\n LABELS = {{
> $labels }}"
> >
> > I am Getting Below Error Output.
> >
> > :/testdata# promtool test rules pod-restart_test.yaml
> > Unit Testing: pod-restart_test.yaml
> > WARNING: no file match pattern /testdata/pod-restar.yaml
> > FAILED:
> > alertname: KubernetesPodCrashLooping, time: 2m,
> > exp:[
> > 0:
> > Labels:{alertname="KubernetesPodCrashLooping", instance="test_host",
> pod="test_pod", severity="warning"}
> > Annotations:{description="Pod test_pod is crash looping\n VALUE = 4\n
> LABELS = {{ $labels }}", summary="Kubernetes pod crash looping (instance
> test_host)"}
> > ],
> > got:[]
> >
> > --
> > 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/1b8f054f-2657-48f5-b369-c87d560f7154n%40googlegroups.com
> .
>
--
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/3cbe34ea-46fc-47e7-8dd1-403eb6913a8bn%40googlegroups.com.