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

-- 
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/CADYa5us80YVTVHJmWkAFQrem4tbG-R-xbtqiDnZFDbnoCWyg2Q%40mail.gmail.com.

Attachment: deployment_replicas_mismatch.yaml
Description: application/yaml

Attachment: replicas_mismatch_test.yaml
Description: application/yaml

Reply via email to