Files
terraform-aws-observability…/modules/workloads/nginx/rules.tf
T
Rodrigue Koffi 3b1b530050 Pre-commit fixes (#44)
* Pre-commit fixes

* Restrict terraform version to < 1.3.0

* fixup! Restrict terraform version to < 1.3.0

* fixup! Restrict terraform version to < 1.3.0

* Pinned min version to 1.1.0, support for nullable

* Update README.md
2022-09-27 23:40:14 +02:00

44 lines
2.1 KiB
Terraform

################################################################################################################################################
# Alerting rules ###############################################################################################################################
################################################################################################################################################
resource "aws_prometheus_rule_group_namespace" "alerting_rules" {
count = var.enable_alerting_rules ? 1 : 0
name = "accelerator-nginx-alerting"
workspace_id = var.managed_prometheus_workspace_id
data = <<EOF
groups:
- name: Nginx-HTTP-4xx-error-rate
rules:
- alert: metric:alerting_rule
expr: sum(rate(nginx_http_requests_total{status=~"^4.."}[1m])) / sum(rate(nginx_http_requests_total[1m])) * 100 > 5
for: 1m
labels:
severity: critical
annotations:
summary: Nginx high HTTP 4xx error rate (instance {{ $labels.instance }})
description: "Too many HTTP requests with status 4xx (> 5%)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
- name: Nginx-HTTP-5xx-error-rate
rules:
- alert: metric:alerting_rule
expr: sum(rate(nginx_http_requests_total{status=~"^5.."}[1m])) / sum(rate(nginx_http_requests_total[1m])) * 100 > 5
for: 1m
labels:
severity: critical
annotations:
summary: Nginx high HTTP 5xx error rate (instance {{ $labels.instance }})
description: "Too many HTTP requests with status 5xx (> 5%)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
- name: Nginx-high-latency
rules:
- alert: metric:alerting_rule
expr: histogram_quantile(0.99, sum(rate(nginx_http_request_duration_seconds_bucket[2m])) by (host, node)) > 3
for: 2m
labels:
severity: warning
annotations:
summary: Nginx latency high (instance {{ $labels.instance }})
description: "Nginx p99 latency is higher than 3 seconds\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
EOF
}