From 7cc9434f522662de5f1b97f44024b37bedb4d5fc Mon Sep 17 00:00:00 2001 From: maoling <11016631+maoling@users.noreply.github.com> Date: Sat, 28 Sep 2024 00:30:41 +0800 Subject: [PATCH] add alarm template for spring cloud gateway (#3019) --- .../spring-cloud-gateway/global-filters.adoc | 1 + docs/src/main/asciidoc/gateway-alarming.adoc | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 docs/src/main/asciidoc/gateway-alarming.adoc diff --git a/docs/modules/ROOT/pages/spring-cloud-gateway/global-filters.adoc b/docs/modules/ROOT/pages/spring-cloud-gateway/global-filters.adoc index 7f223c99..5bafd87b 100644 --- a/docs/modules/ROOT/pages/spring-cloud-gateway/global-filters.adoc +++ b/docs/modules/ROOT/pages/spring-cloud-gateway/global-filters.adoc @@ -57,6 +57,7 @@ In addition, through the `spring.cloud.gateway.metrics.tags.path.enabled` proper * `path`: The path of the request. These metrics are then available to be scraped from `/actuator/metrics/spring.cloud.gateway.requests` and can be easily integrated with Prometheus to create a link:images/gateway-grafana-dashboard.jpeg[Grafana] link:gateway-grafana-dashboard.json[dashboard]. +You can also alarm with these useful metrics to take an example from link:gateway-alarming.adoc[alarming-template]. NOTE: To enable the prometheus endpoint, add `micrometer-registry-prometheus` as a project dependency. diff --git a/docs/src/main/asciidoc/gateway-alarming.adoc b/docs/src/main/asciidoc/gateway-alarming.adoc new file mode 100644 index 00000000..c8e42821 --- /dev/null +++ b/docs/src/main/asciidoc/gateway-alarming.adoc @@ -0,0 +1,63 @@ +groups: + - name: Gateway_Service + rules: + - alert: Gateway Total Unsuccessful Requests Served + expr: sum(rate(spring_cloud_gateway_requests_seconds_count{outcome!="SUCCESSFUL"}[1m])) by (routeId, httpStatusCode, outcome, status)>1 + for: 1m + labels: + severity: critical + annotations: + summary: "Total Unsuccessful Requests Served increases quickly" + description: "Unsuccessful Requests: routeId:{{ $labels.routeId }}, code:{{$labels.httpStatusCode}}, outcome:{{$labels.outcome}}, status:{{$labels.status}} : [{{ $value }}]." + value: "Current:{{$value}}" + + - alert: Gateway QPS + expr: sum(rate(spring_cloud_gateway_requests_seconds_count[5m]))>10000 + for: 1m + labels: + severity: warning + annotations: + summary: "QPS increases quickly" + description: "QPS increases quickly: [{{ $value }}]." + value: "Current:{{$value}}" + + - alert: Gateway Too many threads + expr: max(jvm_threads_live_threads)>220 + for: 1m + labels: + severity: warning + annotations: + summary: "Too many threads" + description: "Too many threads: [{{ $value }}]." + value: "Current:{{$value}}" + + - alert: Gateway minor GC + expr: max(rate(jvm_gc_pause_seconds_count{action="end of minor GC"}[5m]))*300>200 + for: 1m + labels: + severity: warning + annotations: + summary: "minor GC has problem" + description: "minor GC has problem: [{{ $value }}]." + value: "Current:{{$value}}" + + - alert: Gateway major GC + expr: max(rate(jvm_gc_pause_seconds_count{action="end of major GC"}[5m]))*300>10 + for: 1m + labels: + severity: warning + annotations: + summary: "major GC has problem" + description: "major GC has problem: [{{ $value }}]." + value: "Current:{{$value}}" + + - alert: Gateway Latency is too high + expr: (sum(rate(spring_cloud_gateway_requests_seconds_sum[30s])) by (routeId))/(sum(rate(spring_cloud_gateway_requests_seconds_count[30s])) by (routeId))*1000>5000 + for: 30s + labels: + severity: critical + annotations: + summary: " Gateway Latency is too high" + description: " Gateway Latency is too high. routeId:{{ $labels.routeId }}. Latency is: [{{ $value }}] ms." + value: "Current:{{$value}} ms" +