It's saying there's no alert firing at time 20m ("got" is empty).
That seems correct to me. You've now made the two input_series have
identical values:
input_series:
- series: kube_replicaset_spec_replicas{job="prometheus",
namespace="auth-proxy"}
* values: '5+0x9 5+0x20'*
- series:
kube_deployment_status_replicas_available{job="prometheus",
namespace="auth-proxy"}
* values: '5+0x9 5+0x20'*
Hence you wouldn't expect the alert to fire, would you?
On Monday, 18 July 2022 at 10:34:22 UTC+1 [email protected] wrote:
> Hi,
>
> I did some changes as you suggested. After that I am getting below error.
>
> Unit Testing: replicas_mismatch_test.yaml
>
> FAILED:
>
> alertname: KubernetesDeploymentReplicasMismatch-authproxy, time: 20m,
>
> exp:[
>
> 0:
>
>
> Labels:{alertname="KubernetesDeploymentReplicasMismatch-authproxy",
> job="prometheus", namespace="auth-proxy", severity="critical"}
>
> Annotations:{description="Deployment Replicas mismatch\n
> VALUE = {{ $value }}\n LABELS = {{ $labels }}", summary="Kubernetes
> Deployment replicas mismatch (instance {{$labels.instance }})"}
>
> ],
>
> got:[]
>
>
> Alert:
>
>
> groups:
> - name: replicas-mismatch
> rules:
> - alert: KubernetesDeploymentReplicasMismatch-authproxy
> expr: kube_replicaset_spec_replicas{namespace="auth-proxy"} !=
> kube_deployment_status_replicas_available{namespace="auth-proxy"}
> for: 10m
> labels:
> severity: critical
> annotations:
> summary: Kubernetes Deployment replicas mismatch (instance {{
> $labels.instance }})
> description: "Deployment Replicas mismatch\n VALUE = {{ $value }}\n
> LABELS = {{ $labels }}"
>
> TestCase:
> rule_files:
> - /testdata/deployment_replicas_mismatch.yaml
> evaluation_interval: 1m
> tests:
> - interval: 1m
> # Series Data
> input_series:
> - series: kube_replicaset_spec_replicas{job="prometheus",
> namespace="auth-proxy"}
> values: '5+0x9 5+0x20'
> - series: kube_deployment_status_replicas_available{job="prometheus",
> namespace="auth-proxy"}
> values: '5+0x9 5+0x20'
> alert_rule_test:
> # Unit Test 1
> - eval_time: 9m
> alertname: KubernetesDeploymentReplicasMismatch-authproxy
> exp_alerts:
>
> - eval_time: 20m
> alertname: KubernetesDeploymentReplicasMismatch-authproxy
> exp_alerts:
> - exp_labels:
> namespace: auth-proxy
> job: prometheus
> severity: critical
> exp_annotations:
> summary: Kubernetes Deployment replicas mismatch (instance
> {{$labels.instance }})
> description: "Deployment Replicas mismatch\n VALUE = {{ $value }}\n
> LABELS = {{ $labels }}"
>
>
> On Mon, Jul 18, 2022 at 12:46 PM David Leadbeater <[email protected]> wrote:
>
>> You're alerting in the rules with annotations as follows:
>>
>> annotations:
>> summary: Kubernetes Deployment replicas mismatch (instance {{
>> $labels.instance }})
>> description: "Deployment Replicas mismatch\n VALUE = {{ $value }}\n
>> LABELS = {{ $labels }}"
>>
>> Then expecting they match:
>>
>> exp_annotations:
>> summary: "Kube_replicaset_spec_replicas_authproxy missmatches"
>> description: "YaRD_Kubernetes Deployment Replicas Mismatch in
>> authproxy namespace from 11 min getting alert"
>>
>> You need to update the expected annotations to match that the rules
>> are generating.
>>
>> David
>>
>> On Mon, 18 Jul 2022 at 17:09, Shivanand Shete <[email protected]>
>> wrote:
>> >
>> > Hi David,
>> >
>> > I corrected the alert name and please find the attached update .yaml
>> files.
>> > Alert:
>> >
>> > groups:
>> > - name: replicas-mismatch
>> > rules:
>> > - alert: KubernetesDeploymentReplicasMismatch-authproxy
>> > expr: kube_replicaset_spec_replicas{namespace="auth-proxy"} !=
>> kube_deployment_status_replicas_available{namespace="auth-proxy"}
>> > for: 10m
>> > labels:
>> > severity: critical
>> > annotations:
>> > summary: Kubernetes Deployment replicas mismatch (instance {{
>> $labels.instance }})
>> > description: "Deployment Replicas mismatch\n VALUE = {{ $value }}\n
>> LABELS = {{ $labels }}"
>> >
>> >
>> > TestCase:
>> >
>> > rule_files:
>> > - /testdata/deployment_replicas_mismatch.yaml
>> > evaluation_interval: 1m
>> > tests:
>> > - interval: 1m
>> > # Series Data
>> > input_series:
>> > - series: kube_replicaset_spec_replicas{job="prometheus",
>> namespace="auth-proxy"}
>> > values: '5+0x9 5+0x20 5+0x100000'
>> > - series: kube_deployment_status_replicas_available{job="prometheus",
>> namespace="auth-proxy"}
>> > values: '5+0x9 4+0x20 5+0x100000'
>> > alert_rule_test:
>> > # Unit Test 1
>> > - eval_time: 9m
>> > alertname: KubernetesDeploymentReplicasMismatch-authproxy
>> > exp_alerts:
>> >
>> > - eval_time: 20m
>> > alertname: KubernetesDeploymentReplicasMismatch-authproxy
>> > exp_alerts:
>> > - exp_labels:
>> > namespace: auth-proxy
>> > job: prometheus
>> > severity: critical
>> > exp_annotations:
>> > summary: "Kube_replicaset_spec_replicas_authproxy missmatches"
>> > description: "YaRD_Kubernetes Deployment Replicas Mismatch in authproxy
>> namespace from 11 min getting alert"
>> >
>> > Regards,
>> > Shivanand Shete.
>> >
>> > On Mon, Jul 18, 2022 at 12:22 PM David Leadbeater <[email protected]> wrote:
>> >>
>> >> In your attachment the alertname in the rules and the test doesn't
>> >> match -- the unit tests match the alert name first, so fix that first;
>> >> then you can iterate on the other fields that need to match (it looks
>> >> like the annotations need adjusting).
>> >>
>> >> David
>> >>
>> >> On Mon, 18 Jul 2022 at 15:49, Shivanand Shete <[email protected]>
>> wrote:
>> >> >
>> >> > Dear all,
>> >> >
>> >> > Please find the below alert rules and I want to test that alert
>> using Promtool.
>> >> >
>> >> > groups:
>> >> > - name: replicas-mismatch
>> >> > rules:
>> >> > - alert: KubernetesDeploymentReplicasMismatch-authproxy
>> >> > expr: kube_replicaset_spec_replicas{namespace="auth-proxy"} !=
>> kube_deployment_status_replicas_available{namespace="auth-proxy"}
>> >> > for: 10m
>> >> > labels:
>> >> > severity: critical
>> >> > annotations:
>> >> > summary: Kubernetes Deployment replicas mismatch (instance {{
>> $labels.instance }})
>> >> > description: "Deployment Replicas mismatch\n VALUE = {{ $value }}\n
>> LABELS = {{ $labels }}"
>> >> >
>> >> > And also I have eaten the test case but its not working please
>> suggest .
>> >> >
>> >> > rule_files:
>> >> > - /testdata/deployment_replicas_mismatch.yaml
>> >> > evaluation_interval: 1m
>> >> > tests:
>> >> > - interval: 1m
>> >> > # Series Data
>> >> > input_series:
>> >> > - series: kube_replicaset_spec_replicas{job="prometheus",
>> namespace="auth-proxy"}
>> >> > values: '5+0x9 5+0x20 5+0x100000'
>> >> > - series:
>> kube_deployment_status_replicas_available{job="prometheus",
>> namespace="auth-proxy"}
>> >> > values: '5+0x9 4+0x20 5+0x100000'
>> >> > alert_rule_test:
>> >> > # Unit Test 1
>> >> > - eval_time: 9m
>> >> > alertname: KubernetesDeploymentReplicasMismatch-authproxy
>> >> > exp_alerts:
>> >> >
>> >> > - eval_time: 20m
>> >> > alertname: KubernetesDeploymentReplicasMismatch-authproxy
>> >> > exp_alerts:
>> >> > - exp_labels:
>> >> > namespace: auth-proxy
>> >> > job: prometheus
>> >> > severity: critical
>> >> > exp_annotations:
>> >> > summary: "Kube_replicaset_spec_replicas_authproxy missmatches"
>> >> > description: "YaRD_Kubernetes Deployment Replicas Mismatch in
>> authproxy namespace from 11 min getting alert"
>> >> >
>> >> > --
>> >> > 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/9af657d1-6240-4d9a-bbad-d44355e6650bn%40googlegroups.com
>> .
>> >
>> >
>> >
>> > --
>> > Thanks & Regards,
>> > Shivanand Shete
>> > 9422362618
>>
>
>
> --
> *Thanks & Regards,*
> Shivanand Shete
> 9422362618
>
--
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/88ef3b74-fc1e-4f33-9b96-dc5bfe722809n%40googlegroups.com.