Skip to content

Commit

Permalink
fix(mixin): Fix alert syntax
Browse files Browse the repository at this point in the history
Update tests
  • Loading branch information
adinhodovic committed Oct 21, 2023
1 parent e389e97 commit 0d324ce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions celery-mixin/alerts/alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
},
annotations: {
summary: 'Celery high queue length.',
description: 'More than %(celeryHighQueueLengthThreshold)s tasks in the queue {{{ $labels.job }}/{ $labels.queue_name }} the past %(celeryHighQueueLengthInterval)s.' % $._config,
description: 'More than %(celeryHighQueueLengthThreshold)s tasks in the queue {{ $labels.job }}/{{ $labels.queue_name }} the past %(celeryHighQueueLengthInterval)s.' % $._config,
dashboard_url: $._config.celeryTasksOverviewUrl + '?&var-job={{ $labels.job }}&var-queue_name={{ $labels.queue_name }}',
},
},
Expand All @@ -83,7 +83,7 @@
annotations: {
summary: 'A Celery worker is offline.',
description: 'The Celery worker {{ $labels.job }}/{{ $labels.hostname }} is offline.',
dashboard_url: $._config.celeryTasksOverviewUrl + '?&var-job={{ $labels.job }}&var-queue_name={{ $labels.queue_name }}',
dashboard_url: $._config.celeryTasksOverviewUrl + '?&var-job={{ $labels.job }}',
},
},
]),
Expand Down
4 changes: 2 additions & 2 deletions celery-mixin/prometheus-alerts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
- "alert": "CeleryHighQueueLength"
"annotations":
"dashboard_url": "https://grafana.com/d/celery-tasks-overview-32s3/celery-tasks-overview?&var-job={{ $labels.job }}&var-queue_name={{ $labels.queue_name }}"
"description": "More than 100 tasks in the queue {{{ $labels.job }}/{ $labels.queue_name }} the past 20m."
"description": "More than 100 tasks in the queue {{ $labels.job }}/{{ $labels.queue_name }} the past 20m."
"summary": "Celery high queue length."
"expr": |
sum(
Expand All @@ -60,7 +60,7 @@
"severity": "warning"
- "alert": "CeleryWorkerDown"
"annotations":
"dashboard_url": "https://grafana.com/d/celery-tasks-overview-32s3/celery-tasks-overview?&var-job={{ $labels.job }}&var-queue_name={{ $labels.queue_name }}"
"dashboard_url": "https://grafana.com/d/celery-tasks-overview-32s3/celery-tasks-overview?&var-job={{ $labels.job }}"
"description": "The Celery worker {{ $labels.job }}/{{ $labels.hostname }} is offline."
"summary": "A Celery worker is offline."
"expr": |
Expand Down
28 changes: 15 additions & 13 deletions celery-mixin/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ tests:
- interval: 5m
input_series:
- series: 'celery_task_failed_total{job="celery-exporter", namespace="staging", queue_name="celery", name="test-task"}'
values: '1+10x10'
values: "1+10x10"
- series: 'celery_task_succeeded_total{job="celery-exporter", namespace="staging", queue_name="celery", name="test-task"}'
values: '1+10x10'
values: "1+10x10"
alert_rule_test:
- eval_time: 15m
alertname: CeleryTaskHighFailRate
Expand All @@ -21,15 +21,15 @@ tests:
queue_name: celery
name: test-task
exp_annotations:
summary: 'Celery high task fail rate.'
description: 'More than 5% tasks failed for the task celery/test-task the past 10m.'
dashboard_url: 'https://grafana.com/d/celery-tasks-by-task-32s3/celery-tasks-by-task?&var-queue_name=celery&var-task=test-task'
summary: "Celery high task fail rate."
description: "More than 5% tasks failed for the task celery-exporter/celery/test-task the past 10m."
dashboard_url: "https://grafana.com/d/celery-tasks-by-task-32s3/celery-tasks-by-task?var-job=celery-exporter&var-queue_name=celery&var-task=test-task"
- interval: 1m
input_series:
- series: 'celery_queue_length{job="celery-exporter", namespace="staging", queue_name="celery-low-queue"}'
values: '1+0x50'
values: "1+0x50"
- series: 'celery_queue_length{job="celery-exporter", namespace="staging", queue_name="celery-high-queue"}'
values: '1000+200x50'
values: "1000+200x50"
alert_rule_test:
- eval_time: 40m
alertname: CeleryHighQueueLength
Expand All @@ -40,14 +40,15 @@ tests:
namespace: staging
queue_name: celery-high-queue
exp_annotations:
summary: 'Celery high queue length.'
description: 'More than 100 tasks in the queue celery-high-queue the past 20m.'
summary: "Celery high queue length."
description: "More than 100 tasks in the queue celery-exporter/celery-high-queue the past 20m."
dashboard_url: https://grafana.com/d/celery-tasks-overview-32s3/celery-tasks-overview?&var-job=celery-exporter&var-queue_name=celery-high-queue
- interval: 1m
input_series:
- series: 'celery_worker_up{job="celery-exporter", namespace="staging", hostname="down"}'
values: '0+0x20'
values: "0+0x20"
- series: 'celery_worker_up{job="celery-exporter", namespace="staging", hostname="up"}'
values: '1+0x20'
values: "1+0x20"
alert_rule_test:
- eval_time: 20m
alertname: CeleryWorkerDown
Expand All @@ -58,5 +59,6 @@ tests:
namespace: staging
hostname: down
exp_annotations:
summary: 'A Celery worker is offline.'
description: 'The Celery worker down is offline.'
summary: "A Celery worker is offline."
description: "The Celery worker celery-exporter/down is offline."
dashboard_url: "https://grafana.com/d/celery-tasks-overview-32s3/celery-tasks-overview?&var-job=celery-exporter"

0 comments on commit 0d324ce

Please sign in to comment.