From ae5bcbc68a03038b9f09f7290d854c56647ed6c6 Mon Sep 17 00:00:00 2001 From: Magnus Root Date: Wed, 25 Feb 2026 14:46:49 +0300 Subject: [PATCH] Added alert rules --- alert_rules_template.json | 535 ++++++++++++++++++++ dashboard_template.json | 992 +++++++++++++++++++++++++++++++++++--- 2 files changed, 1471 insertions(+), 56 deletions(-) create mode 100644 alert_rules_template.json diff --git a/alert_rules_template.json b/alert_rules_template.json new file mode 100644 index 0000000..5fc4624 --- /dev/null +++ b/alert_rules_template.json @@ -0,0 +1,535 @@ +{ + "version": "1.3.0", + "description": "Шаблон правил алертинга Grafana для PTAF", + "defaults": { + "no_data_state": "NoData", + "exec_err_state": "Error", + "receiver": "Telegram PTAF Grafana", + "folder": "WAF - PTAF", + "group": "PTAF Grafana", + "group_interval": "1m" + }, + "rps_alert": { + "relative_time_range_from": 1800, + "keep_firing_for": "", + "annotation_summary": "Превышен порог в {rps_limit} RPS в {client_title}", + "queries": { + "data_query": { + "refId": "A", + "queryType": "lucene", + "datasource_uid": "", + "model": { + "bucketAggs": [ + { + "field": "@timestamp", + "id": "2", + "settings": { + "interval": "1m", + "min_doc_count": "0", + "trimEdges": "0" + }, + "type": "date_histogram" + } + ], + "format": "table", + "instant": false, + "luceneQueryType": "Metric", + "metrics": [ + { + "hide": false, + "id": "1", + "type": "count" + } + ], + "queryType": "lucene", + "range": true, + "timeField": "@timestamp" + } + }, + "math_expression": { + "refId": "RPS", + "expression": "$A / 60", + "type": "math" + }, + "reduce_expression": { + "refId": "Текущий RPS", + "reducer": "median", + "type": "reduce", + "source_ref": "RPS" + }, + "threshold_expression": { + "refId": "Превышение", + "type": "threshold", + "source_ref": "Текущий RPS", + "evaluator_type": "gt" + } + } + }, + "static_alerts": [ + { + "uid": "ef4ohmap00utcd", + "title": "Use in /", + "condition": "Порог", + "for": "3m", + "no_data_state": "NoData", + "exec_err_state": "Error", + "data": [ + { + "refId": "Занято в /", + "relativeTimeRange": { + "from": 86400, + "to": 0 + }, + "datasourceUid": "deibaq3pwytxce", + "model": { + "datasource": { + "type": "prometheus", + "uid": "deibaq3pwytxce" + }, + "editorMode": "code", + "expr": "100 - (\n 100 * (\n node_filesystem_avail_bytes{\n job=\"node_exporter\",\n mountpoint=\"/\",\n device!~'rootfs|tmpfs|sysfs|proc|devpts|overlay|squashfs'\n }\n /\n on(instance, device, mountpoint) group_left\n node_filesystem_size_bytes{\n job=\"node_exporter\",\n mountpoint=\"/\",\n device!~'rootfs|tmpfs|sysfs|proc|devpts|overlay|squashfs'\n }\n )\n)", + "format": "time_series", + "instant": true, + "intervalMs": 15000, + "legendFormat": "{{mountpoint}} - Available", + "maxDataPoints": 43200, + "range": false, + "refId": "Занято в /" + } + }, + { + "refId": "Порог", + "relativeTimeRange": { + "from": 0, + "to": 0 + }, + "datasourceUid": "__expr__", + "model": { + "conditions": [ + { + "evaluator": { + "params": [ + 75 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "E" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "datasource": { + "type": "__expr__", + "uid": "__expr__" + }, + "expression": "Занято в /", + "intervalMs": 1000, + "maxDataPoints": 43200, + "refId": "Порог", + "type": "threshold" + } + } + ], + "annotations": { + "summary": "🖥 {{ $labels.instance }}: диск / заполнен на {{ $values.\"Занято в /\".Value | printf \"%.1f\" }}% (порог 75%)" + } + }, + { + "uid": "af4ok3zmdvny8f", + "title": "Use in /var/log", + "condition": "Порог", + "for": "5m", + "no_data_state": "NoData", + "exec_err_state": "Error", + "data": [ + { + "refId": "Занято в /var/log", + "relativeTimeRange": { + "from": 86400, + "to": 0 + }, + "datasourceUid": "deibaq3pwytxce", + "model": { + "datasource": { + "type": "prometheus", + "uid": "deibaq3pwytxce" + }, + "editorMode": "code", + "expr": "100 - (\n 100 * (\n node_filesystem_avail_bytes{\n job=\"node_exporter\",\n mountpoint=\"/var/log\",\n device!~'rootfs'\n }\n /\n on(instance, device, mountpoint) group_left\n node_filesystem_size_bytes{\n job=\"node_exporter\",\n mountpoint=\"/var/log\",\n device!~'rootfs'\n }\n )\n)", + "format": "time_series", + "instant": true, + "intervalMs": 15000, + "legendFormat": "{{mountpoint}} - Available", + "maxDataPoints": 43200, + "range": false, + "refId": "Занято в /var/log" + } + }, + { + "refId": "Порог", + "relativeTimeRange": { + "from": 0, + "to": 0 + }, + "datasourceUid": "__expr__", + "model": { + "conditions": [ + { + "evaluator": { + "params": [ + 75 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "E" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "datasource": { + "type": "__expr__", + "uid": "__expr__" + }, + "expression": "Занято в /var/log", + "intervalMs": 1000, + "maxDataPoints": 43200, + "refId": "Порог", + "type": "threshold" + } + } + ], + "annotations": { + "summary": "🖥 {{ $labels.instance }}: диск /var/log заполнен на {{ $values.\"Занято в /var/log\".Value | printf \"%.1f\" }}% (порог 75%)" + } + }, + { + "uid": "ef4spdg2qcge8c", + "title": "CPU Busy", + "condition": "C", + "for": "3m", + "no_data_state": "NoData", + "exec_err_state": "Error", + "data": [ + { + "refId": "Занято CPU", + "relativeTimeRange": { + "from": 600, + "to": 0 + }, + "datasourceUid": "deibaq3pwytxce", + "model": { + "datasource": { + "type": "prometheus", + "uid": "deibaq3pwytxce" + }, + "editorMode": "code", + "expr": "100 - (\n avg by(instance) (\n rate(node_cpu_seconds_total{mode=\"idle\", instance=~\"PTAF-TB-.*\"}[5m])\n ) * 100\n)", + "instant": true, + "intervalMs": 1000, + "legendFormat": "__auto", + "maxDataPoints": 43200, + "range": false, + "refId": "Занято CPU" + } + }, + { + "refId": "C", + "relativeTimeRange": { + "from": 0, + "to": 0 + }, + "datasourceUid": "__expr__", + "model": { + "conditions": [ + { + "evaluator": { + "params": [ + 75 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "C" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "datasource": { + "type": "__expr__", + "uid": "__expr__" + }, + "expression": "Занято CPU", + "intervalMs": 1000, + "maxDataPoints": 43200, + "refId": "C", + "type": "threshold" + } + } + ], + "annotations": { + "summary": "🔥 {{ $labels.instance }}: CPU загружен на {{ $values.\"Занято CPU\".Value | printf \"%.1f\" }}% (порог 75%)" + } + }, + { + "uid": "ef4spmgmowe80e", + "title": "RAM Busy", + "condition": "Превышение потребления RAM", + "for": "3m", + "no_data_state": "NoData", + "exec_err_state": "Error", + "data": [ + { + "refId": "Занято RAM", + "relativeTimeRange": { + "from": 600, + "to": 0 + }, + "datasourceUid": "deibaq3pwytxce", + "model": { + "datasource": { + "type": "prometheus", + "uid": "deibaq3pwytxce" + }, + "editorMode": "code", + "expr": "100 - (\n (node_memory_MemAvailable_bytes{instance=~\"PTAF-TB-.*\"} / \n node_memory_MemTotal_bytes{instance=~\"PTAF-TB-.*\"}) * 100\n)", + "instant": true, + "intervalMs": 1000, + "legendFormat": "__auto", + "maxDataPoints": 43200, + "range": false, + "refId": "Занято RAM" + } + }, + { + "refId": "Превышение потребления RAM", + "relativeTimeRange": { + "from": 0, + "to": 0 + }, + "datasourceUid": "__expr__", + "model": { + "conditions": [ + { + "evaluator": { + "params": [ + 75 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "C" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "datasource": { + "type": "__expr__", + "uid": "__expr__" + }, + "expression": "Занято RAM", + "intervalMs": 1000, + "maxDataPoints": 43200, + "refId": "Превышение потребления RAM", + "type": "threshold" + } + } + ], + "annotations": { + "summary": "💾 {{ $labels.instance }}: RAM занята на {{ $values.\"Занято RAM\".Value | printf \"%.1f\" }}% (порог 75%)" + } + }, + { + "uid": "cfc4iwprdvn5se", + "title": "Состояние контейнеров", + "condition": "Целевое значение", + "for": "2m", + "no_data_state": "NoData", + "exec_err_state": "Error", + "annotations": { + "summary": "🐳 {{ $labels.instance }}: контейнер {{ $labels.name }} упал (статус: {{ $values.\"Текущее количество\".Value }})" + }, + "data": [ + { + "refId": "Текущее количество", + "relativeTimeRange": { + "from": 600, + "to": 0 + }, + "datasourceUid": "deibaq3pwytxce", + "model": { + "datasource": { + "type": "prometheus", + "uid": "deibaq3pwytxce" + }, + "editorMode": "code", + "expr": "docker_container_status", + "instant": true, + "intervalMs": 1000, + "legendFormat": "__auto", + "maxDataPoints": 43200, + "range": false, + "refId": "Текущее количество" + } + }, + { + "refId": "Целевое значение", + "relativeTimeRange": { + "from": 0, + "to": 0 + }, + "datasourceUid": "__expr__", + "model": { + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "eq" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "C" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "datasource": { + "type": "__expr__", + "uid": "__expr__" + }, + "expression": "Текущее количество", + "intervalMs": 1000, + "maxDataPoints": 43200, + "refId": "Целевое значение", + "type": "threshold" + } + } + ] + }, + { + "uid": "efcxg0oa65gcgd", + "title": "Упала Angie", + "condition": "C", + "for": "1m", + "no_data_state": "NoData", + "exec_err_state": "Error", + "data": [ + { + "refId": "A", + "relativeTimeRange": { + "from": 600, + "to": 0 + }, + "datasourceUid": "deibaq3pwytxce", + "model": { + "datasource": { + "type": "prometheus", + "uid": "deibaq3pwytxce" + }, + "editorMode": "code", + "expr": "node_systemd_unit_state{name=\"angie.service\", state=\"active\",instance=~\"PTAF-TB-.*\"}", + "hide": false, + "instant": true, + "intervalMs": 1000, + "legendFormat": "__auto", + "maxDataPoints": 43200, + "range": false, + "refId": "A" + } + }, + { + "refId": "C", + "relativeTimeRange": { + "from": 0, + "to": 0 + }, + "datasourceUid": "__expr__", + "model": { + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "eq" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "C" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "datasource": { + "type": "__expr__", + "uid": "__expr__" + }, + "expression": "A", + "intervalMs": 1000, + "maxDataPoints": 43200, + "refId": "C", + "type": "threshold" + } + } + ], + "annotations": { + "summary": "🔴 {{ $labels.instance }}: служба angie.service не активна" + } + } + ] +} \ No newline at end of file diff --git a/dashboard_template.json b/dashboard_template.json index 79120a2..263eb88 100644 --- a/dashboard_template.json +++ b/dashboard_template.json @@ -1,5 +1,5 @@ { - "version": "3.0.1", + "version": "3.1.0", "description": "Data-driven template - panels fully describe their query logic", "datasource": { "type": "grafana-opensearch-datasource", @@ -7,7 +7,10 @@ }, "dashboard_meta": { "uid": "pt-af-requests-auto", - "tags": ["auto-generated", "waf-monitoring"], + "tags": [ + "auto-generated", + "waf-monitoring" + ], "version": 0 }, "dashboard": { @@ -15,7 +18,10 @@ "list": [ { "builtIn": 1, - "datasource": {"type": "grafana", "uid": "-- Grafana --"}, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", @@ -30,7 +36,10 @@ "links": [], "schemaVersion": 39, "timezone": "browser", - "time": {"from": "now-6h", "to": "now"}, + "time": { + "from": "now-6h", + "to": "now" + }, "timepicker": {}, "weekStart": "" }, @@ -74,23 +83,61 @@ "x_offset": 0, "y_offset": 17 } + ], + "overview_row_title": "Обзор", + "overview_panels": [ + { + "panel_key": "overview_status_codes", + "width": 24, + "x_offset": 0, + "y_offset": 1 + }, + { + "panel_key": "overview_tenant_per_nodes", + "width": 24, + "x_offset": 0, + "y_offset": 13 + }, + { + "panel_key": "overview_tenant_per_node", + "width": 24, + "x_offset": 0, + "y_offset": 23 + }, + { + "panel_key": "overview_uri_top15", + "width": 24, + "x_offset": 0, + "y_offset": 34 + } ] }, "panels": { "row": { "type": "row", "collapsed": true, - "gridPos": {"h": 1, "w": 24, "x": 0, "y": 0}, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, "panels": [] }, - "rps": { "type": "timeseries", "description": "Requests per second", - "gridPos": {"h": 8, "w": 12, "x": 0, "y": 1}, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 1 + }, "fieldConfig": { "defaults": { - "color": {"mode": "palette-classic"}, + "color": { + "mode": "palette-classic" + }, "custom": { "axisBorderShow": false, "drawStyle": "line", @@ -99,20 +146,34 @@ "lineInterpolation": "smooth", "lineWidth": 1, "showPoints": "never", - "thresholdsStyle": {"mode": "line"} + "thresholdsStyle": { + "mode": "line" + } }, "thresholds": { "mode": "absolute", "steps": [ - {"color": "green", "value": null}, - {"color": "dark-red", "value": 1800} + { + "color": "green", + "value": null + }, + { + "color": "dark-red", + "value": 1800 + } ] } } }, "options": { - "legend": {"displayMode": "list", "placement": "bottom", "showLegend": true}, - "tooltip": {"mode": "single"} + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single" + } }, "query_mode": "rps", "query_config": { @@ -123,14 +184,20 @@ "expression_ref_id": "RPS" } }, - "status_codes": { "type": "timeseries", "description": "HTTP status codes", - "gridPos": {"h": 8, "w": 12, "x": 0, "y": 1}, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 1 + }, "fieldConfig": { "defaults": { - "color": {"mode": "palette-classic"}, + "color": { + "mode": "palette-classic" + }, "custom": { "drawStyle": "line", "fillOpacity": 10, @@ -140,42 +207,128 @@ } }, "overrides": [ - {"matcher": {"id": "byName", "options": "2**"}, "properties": [{"id": "color", "value": {"fixedColor": "green", "mode": "fixed"}}]}, - {"matcher": {"id": "byName", "options": "3**"}, "properties": [{"id": "color", "value": {"fixedColor": "blue", "mode": "fixed"}}]}, - {"matcher": {"id": "byName", "options": "4**"}, "properties": [{"id": "color", "value": {"fixedColor": "yellow", "mode": "fixed"}}]}, - {"matcher": {"id": "byName", "options": "5**"}, "properties": [{"id": "color", "value": {"fixedColor": "red", "mode": "fixed"}}]} + { + "matcher": { + "id": "byName", + "options": "2**" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "3**" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "4**" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "5**" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + } ] }, "options": { - "legend": {"displayMode": "list", "placement": "bottom", "showLegend": true}, - "tooltip": {"mode": "single"} + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single" + } }, "query_mode": "multi_target", "query_config": { "base_query": "SID:{sid}", "metric": "count", "targets": [ - {"alias": "2**", "query_suffix": "AND response_status_code:[200 TO 299]", "ref_id": "A"}, - {"alias": "3**", "query_suffix": "AND response_status_code:[300 TO 399]", "ref_id": "B"}, - {"alias": "4**", "query_suffix": "AND response_status_code:[400 TO 499]", "ref_id": "C"}, - {"alias": "5**", "query_suffix": "AND response_status_code:[500 TO 599]", "ref_id": "D"} + { + "alias": "2**", + "query_suffix": "AND response_status_code:[200 TO 299]", + "ref_id": "A" + }, + { + "alias": "3**", + "query_suffix": "AND response_status_code:[300 TO 399]", + "ref_id": "B" + }, + { + "alias": "4**", + "query_suffix": "AND response_status_code:[400 TO 499]", + "ref_id": "C" + }, + { + "alias": "5**", + "query_suffix": "AND response_status_code:[500 TO 599]", + "ref_id": "D" + } ] } }, - "response_time": { "type": "timeseries", "description": "Response time distribution", - "gridPos": {"h": 8, "w": 12, "x": 12, "y": 1}, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 1 + }, "fieldConfig": { "defaults": { - "color": {"mode": "palette-classic"}, + "color": { + "mode": "palette-classic" + }, "custom": { "drawStyle": "line", "fillOpacity": 30, "lineWidth": 0, "showPoints": "never", - "stacking": {"mode": "normal"} + "stacking": { + "mode": "normal" + } }, "max": 100, "min": 0, @@ -183,8 +336,14 @@ } }, "options": { - "legend": {"displayMode": "list", "placement": "bottom", "showLegend": true}, - "tooltip": {"mode": "single"} + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single" + } }, "query_mode": "range_percent", "query_config": { @@ -193,23 +352,54 @@ "metric": "count", "total_ref_id": "F", "ranges": [ - {"label": "0-0.3s", "from": "0", "to": "0.3", "ref_id": "A"}, - {"label": "0.3-1s", "from": "0.3","to": "1", "ref_id": "B"}, - {"label": "1-3s", "from": "1", "to": "3", "ref_id": "C"}, - {"label": "3-10s", "from": "3", "to": "10", "ref_id": "D"}, - {"label": "10s+", "from": "10", "to": "*", "ref_id": "E"} + { + "label": "0-0.3s", + "from": "0", + "to": "0.3", + "ref_id": "A" + }, + { + "label": "0.3-1s", + "from": "0.3", + "to": "1", + "ref_id": "B" + }, + { + "label": "1-3s", + "from": "1", + "to": "3", + "ref_id": "C" + }, + { + "label": "3-10s", + "from": "3", + "to": "10", + "ref_id": "D" + }, + { + "label": "10s+", + "from": "10", + "to": "*", + "ref_id": "E" + } ], "range_field": "upstream_response_time_digital" } }, - "traffic_combined": { "type": "timeseries", "description": "Response and Request Traffic", - "gridPos": {"h": 8, "w": 24, "x": 0, "y": 17}, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 17 + }, "fieldConfig": { "defaults": { - "color": {"mode": "palette-classic"}, + "color": { + "mode": "palette-classic" + }, "custom": { "drawStyle": "line", "fillOpacity": 10, @@ -222,22 +412,46 @@ }, "overrides": [ { - "matcher": {"id": "byRegexp", "options": "/.*Response.*/"}, + "matcher": { + "id": "byRegexp", + "options": "/.*Response.*/" + }, "properties": [ - {"id": "color", "value": {"fixedColor": "green", "mode": "fixed"}} + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } ] }, { - "matcher": {"id": "byRegexp", "options": "/.*Request.*/"}, + "matcher": { + "id": "byRegexp", + "options": "/.*Request.*/" + }, "properties": [ - {"id": "color", "value": {"fixedColor": "blue", "mode": "fixed"}} + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } ] } ] }, "options": { - "legend": {"displayMode": "list", "placement": "bottom", "showLegend": true}, - "tooltip": {"mode": "single"} + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single" + } }, "query_mode": "multi_sum_expression", "query_config": { @@ -262,14 +476,20 @@ ] } }, - "traffic": { "type": "timeseries", "description": "Traffic", - "gridPos": {"h": 8, "w": 12, "x": 0, "y": 9}, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 9 + }, "fieldConfig": { "defaults": { - "color": {"mode": "palette-classic"}, + "color": { + "mode": "palette-classic" + }, "custom": { "drawStyle": "line", "fillOpacity": 10, @@ -291,18 +511,28 @@ "expression_ref_id": "Traffic" } }, - "status_codes_barchart": { "type": "barchart", "description": "Status codes distribution", - "gridPos": {"h": 8, "w": 12, "x": 0, "y": 9}, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 9 + }, "fieldConfig": { "defaults": { - "color": {"mode": "palette-classic"} + "color": { + "mode": "palette-classic" + } } }, "options": { - "legend": {"displayMode": "list", "placement": "bottom", "showLegend": true} + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + } }, "query_mode": "bucket_logs", "query_config": { @@ -312,13 +542,581 @@ { "field": "response_status_code", "id": "3", - "settings": {"min_doc_count": "1", "order": "desc", "orderBy": "_count", "size": "10"}, + "settings": { + "min_doc_count": "1", + "order": "desc", + "orderBy": "_count", + "size": "10" + }, "type": "terms" }, { "field": "@timestamp", "id": "2", - "settings": {"interval": "1m", "trimEdges": "1"}, + "settings": { + "interval": "1m", + "trimEdges": "1" + }, + "type": "date_histogram" + } + ] + } + }, + "overview_status_codes": { + "type": "barchart", + "title": "response_status_code SID: ${SID:raw}", + "description": "Коды ответов по выбранным SID за период", + "transparent": true, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 1 + }, + "interval": "1m", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/^2\\d\\d.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/^3\\d\\d.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/^4\\d\\d.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/^499.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/^5\\d\\d.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + } + ] + }, + "options": { + "barRadius": 0.1, + "barWidth": 0.8, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [ + "mean", + "max", + "sum" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Name", + "sortDesc": true + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "normal", + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 100 + }, + "query_mode": "bucket_logs", + "query_config": { + "base_query": "log_type:access AND SID:${SID:lucene}", + "bucket_aggs": [ + { + "field": "response_status_code", + "id": "4", + "settings": { + "min_doc_count": "1", + "order": "desc", + "orderBy": "1", + "size": "0" + }, + "type": "terms" + }, + { + "id": "3", + "settings": { + "filters": [ + { + "label": "${SID:raw}", + "query": "SID:(*)" + } + ] + }, + "type": "filters" + }, + { + "field": "@timestamp", + "id": "2", + "settings": { + "interval": "auto", + "trimEdges": "1" + }, + "type": "date_histogram" + } + ] + } + }, + "overview_tenant_per_nodes": { + "type": "barchart", + "title": "Request Count by TENANT (${tenant:raw}) per nodes", + "description": "Количество запросов по каждому тенанту для каждой фильтрующей ноды", + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 13 + }, + "interval": "5m", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 2, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "fieldMinMax": false, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + } + ] + } + }, + "overrides": [] + }, + "options": { + "barRadius": 0.1, + "barWidth": 0.88, + "fullHighlight": true, + "groupWidth": 0.9, + "legend": { + "calcs": [ + "min", + "max", + "sum", + "mean" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Name", + "sortDesc": true + }, + "orientation": "vertical", + "showValue": "auto", + "stacking": "none", + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 100 + }, + "query_mode": "bucket_logs", + "query_config": { + "base_query": "log_type:access", + "bucket_aggs": [ + { + "field": "node_name.keyword", + "id": "3", + "settings": { + "min_doc_count": "1", + "order": "desc", + "orderBy": "1", + "size": "0" + }, + "type": "terms" + }, + { + "id": "4", + "settings": { + "filters": [ + { + "label": "${tenant:raw}", + "query": "TENANT.keyword:${tenant:lucene}" + } + ] + }, + "type": "filters" + }, + { + "field": "@timestamp", + "id": "2", + "settings": { + "interval": "auto", + "trimEdges": "1" + }, + "type": "date_histogram" + } + ] + } + }, + "overview_tenant_per_node": { + "type": "barchart", + "title": "Request Count by TENANT per node ${node_name:raw}", + "description": "Количество запросов по тенантам с разбивкой по выбранной ноде", + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 23 + }, + "interval": "5m", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 4, + "scaleDistribution": { + "log": 2, + "type": "log" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "fieldMinMax": false, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + } + ] + } + }, + "overrides": [] + }, + "options": { + "barRadius": 0.5, + "barWidth": 0.9, + "fullHighlight": true, + "groupWidth": 0.9, + "legend": { + "calcs": [ + "min", + "max", + "sum", + "mean" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true + }, + "orientation": "vertical", + "showValue": "auto", + "stacking": "none", + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 100 + }, + "query_mode": "bucket_logs", + "query_config": { + "base_query": "log_type:access", + "bucket_aggs": [ + { + "id": "3", + "settings": { + "filters": [ + { + "label": "${node_name}", + "query": "node_name.keyword:(${node_name:lucene})" + } + ] + }, + "type": "filters" + }, + { + "field": "TENANT.keyword", + "id": "4", + "settings": { + "min_doc_count": "1", + "order": "desc", + "orderBy": "_term", + "size": "0" + }, + "type": "terms" + }, + { + "field": "@timestamp", + "id": "2", + "settings": { + "interval": "auto", + "offset": "0" + }, + "type": "date_histogram" + } + ] + } + }, + "overview_uri_top15": { + "type": "barchart", + "title": "URI от SID ${SID:raw} (top 15)", + "description": "Топ 15 URI по выбранным SID", + "transparent": true, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 34 + }, + "interval": "1m", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "options": { + "barRadius": 0.1, + "barWidth": 0.9, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [ + "mean", + "max", + "sum" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Total", + "sortDesc": true + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "normal", + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 100 + }, + "query_mode": "bucket_logs", + "query_config": { + "base_query": "log_type:access AND SID:(${SID:lucene})", + "bucket_aggs": [ + { + "id": "3", + "settings": { + "filters": [ + { + "label": "${SID:raw}", + "query": "SID:(${SID:lucene})" + } + ] + }, + "type": "filters" + }, + { + "field": "uri.keyword", + "id": "4", + "settings": { + "min_doc_count": "1", + "order": "desc", + "orderBy": "1", + "size": "15" + }, + "type": "terms" + }, + { + "field": "@timestamp", + "id": "2", + "settings": { + "interval": "auto", + "trimEdges": "1" + }, "type": "date_histogram" } ] @@ -329,8 +1127,90 @@ "bucket_agg": { "field": "@timestamp", "id": "2", - "settings": {"interval": "1m", "trimEdges": "1"}, + "settings": { + "interval": "1m", + "trimEdges": "1" + }, "type": "date_histogram" } + }, + "templating": { + "list": [ + { + "name": "tenant", + "label": "tenant", + "description": "Тенант — все ресурсы клиента", + "type": "query", + "datasource": { + "type": "grafana-opensearch-datasource", + "uid": "af84zsvlp9blsa" + }, + "definition": "{\"find\": \"terms\", \"field\": \"TENANT.keyword\"}", + "query": "{\"find\": \"terms\", \"field\": \"TENANT.keyword\"}", + "refresh": 1, + "includeAll": true, + "multi": true, + "allValue": "*", + "sort": 1, + "regex": "", + "allowCustomValue": false, + "current": { + "text": "All", + "value": [ + "$__all" + ] + } + }, + { + "name": "SID", + "label": "SID", + "description": "ID ресурса клиента", + "type": "query", + "datasource": { + "type": "grafana-opensearch-datasource", + "uid": "af84zsvlp9blsa" + }, + "definition": "{\"find\": \"terms\", \"field\": \"SID\"}", + "query": "{\"find\": \"terms\", \"field\": \"SID\"}", + "refresh": 1, + "includeAll": true, + "multi": true, + "allValue": "*", + "sort": 1, + "regex": "", + "allowCustomValue": false, + "current": { + "text": "All", + "value": [ + "$__all" + ] + } + }, + { + "name": "node_name", + "label": "node_name", + "description": "hostname фильтрующей ноды", + "type": "query", + "datasource": { + "type": "grafana-opensearch-datasource", + "uid": "af84zsvlp9blsa" + }, + "definition": "{\"find\": \"terms\", \"field\": \"node_name.keyword\"}", + "query": "{\"find\": \"terms\", \"field\": \"node_name.keyword\"}", + "refresh": 1, + "includeAll": true, + "multi": true, + "allValue": "*", + "sort": 1, + "regex": "", + "allowCustomValue": false, + "current": { + "text": "All", + "value": [ + "$__all" + ] + } + } + ] } } \ No newline at end of file