diff --git a/docs/networking/network.md b/docs/networking/network.md index 0bd49466..e0483fd5 100644 --- a/docs/networking/network.md +++ b/docs/networking/network.md @@ -301,7 +301,7 @@ host. It never decrypts TLS, so it holds no signing key. It caches nothing. rule lets through gets a second log line, `would_deny user= method= host= port=

result=`, from the `would_denied` `access_log` in `hive-squid.nix`; the usual request line keeps - its format. The `egress` dashboard in Grafana lists the hosts per agent. Only + its format. The **would-deny** tab of the `egress` dashboard in Grafana lists the hosts per agent. Only the operator changes the mode: nothing moves an agent to `restricted` after a time or a count. The self-check's users aren't agents, so `deny-canary.invalid` stays a 403. diff --git a/docs/swarm/services.md b/docs/swarm/services.md index 96626af3..e8188c86 100644 --- a/docs/swarm/services.md +++ b/docs/swarm/services.md @@ -203,7 +203,7 @@ kept. - `agents`: per-agent resource usage and Claude Code activity. - `authelia`, `bao`, `queue`: the identity provider, the secret store and the NATS queue. - `claude-usage`: Claude use by model, effort, token type and source. Filter by hive, service (agents or the review classifier) and agent. The service filter separates the classifier's API-key spend from the agents. -- `egress`: the requests that agents in `log` mode made to hosts restricted mode would refuse, by agent and host. Filter by agent. +- `egress`: what agents send through the egress proxy, in three tabs. **overview** has the totals (requests, agents active, refused, credential challenges, data transferred), requests over time by status, and the busiest agents and destinations. **refused** lists the hosts the proxy refused for each agent. **would-deny** lists what agents in `log` mode reached that restricted mode would refuse. Filter by agent. - `controller`: the swarm controller's job graph by state, and the push and commit rates it sees on the forge. - `review-classifier`: review requests by outcome, the verdict mix, results per check, retried asks, and run duration p50 and p95. - `forge`: what the forge holds, and the forge process's CPU, memory and descriptors. diff --git a/docs/swarm/ui.md b/docs/swarm/ui.md index b5386b95..a4efd6cc 100644 --- a/docs/swarm/ui.md +++ b/docs/swarm/ui.md @@ -592,8 +592,8 @@ modes (**allow unrestricted**, **log**, **restrict**) set the mode with a `PUT` without the list resets a stored list to the default. An agent with no stored list sends the flags alone. `log` sends `unrestricted_internet: false` with `internet_log: true`; the other two leave `internet_log` out, which ends -logging. The **egress** dashboard in Grafana shows the hosts a `log` agent -reached. +logging. The **would-deny** tab of the **egress** dashboard in Grafana shows the hosts a +`log` agent reached. The hive's egress proxy applies the flag to each agent's proxy credential (see [the egress proxy](../networking/network.md#egress-proxy-squid)). An agent sends its credential from its next start after it has fetched it, so a flag change applies diff --git a/nix/host-modules/swarm-grafana/dashboards/egress.json b/nix/host-modules/swarm-grafana/dashboards/egress.json index 72501fd4..3e859975 100644 --- a/nix/host-modules/swarm-grafana/dashboards/egress.json +++ b/nix/host-modules/swarm-grafana/dashboards/egress.json @@ -1,299 +1,1865 @@ { - "title": "hyperhive · egress log mode", - "uid": "hyperhive-egress", - "description": "What agents in log mode reached that restricted mode would refuse.", - "editable": true, - "refresh": "1m", - "schemaVersion": 39, - "tags": ["hyperhive", "swarm", "egress", "squid"], - "time": { - "from": "now-24h", - "to": "now" + "apiVersion": "dashboard.grafana.app/v2beta1", + "kind": "Dashboard", + "metadata": { + "name": "hyperhive-egress" }, - "timezone": "utc", - "version": 1, - "templating": { - "list": [ + "spec": { + "title": "hyperhive · egress", + "description": "What agents send through the egress proxy: totals, refused requests, and what log mode would deny.", + "editable": true, + "cursorSync": "Off", + "liveNow": false, + "preload": false, + "tags": ["hyperhive", "swarm", "egress", "squid"], + "links": [], + "annotations": [ { - "name": "agent", - "label": "Agent", - "type": "query", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" - }, - "query": { - "refId": "agent", - "type": "fieldValue", - "field": "agent", - "query": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\"", - "limit": 200 - }, - "refresh": 2, - "includeAll": true, - "multi": true, - "current": { - "text": "All", - "value": "$__all" - }, - "sort": 1 - } - ] - }, - "panels": [ - { - "id": 1, - "type": "stat", - "title": "Would-deny requests", - "description": "Requests let through that restricted mode would have refused, in the range.", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" - }, - "gridPos": { "h": 5, "w": 6, "x": 0, "y": 0 }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" + "kind": "AnnotationQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "grafana", + "version": "v0", + "datasource": { + "name": "-- Grafana --" + }, + "spec": {} }, - "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | agent:$agent | stats count() as requests", - "queryType": "stats" - } - ], - "fieldConfig": { - "defaults": { - "unit": "short", - "decimals": 0, - "color": { "mode": "thresholds" }, - "thresholds": { - "mode": "absolute", - "steps": [{ "color": "green", "value": null }] + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "builtIn": true, + "legacyOptions": { + "type": "dashboard" } - }, - "overrides": [] - }, - "options": { - "reduceOptions": { - "calcs": ["lastNotNull"], - "fields": "", - "values": false - }, - "colorMode": "value", - "graphMode": "none", - "textMode": "auto" - } - }, - { - "id": 2, - "type": "stat", - "title": "Agents logging", - "description": "Agents with at least one would-deny request in the range.", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" - }, - "gridPos": { "h": 5, "w": 6, "x": 6, "y": 0 }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" - }, - "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | agent:$agent | stats by (agent) count() as requests | stats count() as agents", - "queryType": "stats" } - ], - "fieldConfig": { - "defaults": { - "unit": "short", - "decimals": 0, - "color": { "mode": "thresholds" }, - "thresholds": { - "mode": "absolute", - "steps": [{ "color": "green", "value": null }] - } - }, - "overrides": [] - }, - "options": { - "reduceOptions": { - "calcs": ["lastNotNull"], - "fields": "", - "values": false - }, - "colorMode": "value", - "graphMode": "none", - "textMode": "auto" } - }, - { - "id": 3, - "type": "stat", - "title": "Proxied requests · all agents (control)", - "description": "Every squid request line in the range; zero means the log feed is down.", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" - }, - "gridPos": { "h": 5, "w": 12, "x": 12, "y": 0 }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" + ], + "variables": [ + { + "kind": "QueryVariable", + "spec": { + "name": "agent", + "current": { + "text": "All", + "value": "$__all" }, - "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" | stats count() as requests", - "queryType": "stats" + "label": "Agent", + "hide": "dontHide", + "refresh": "onTimeRangeChanged", + "skipUrlSync": false, + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "refId": "agent", + "type": "fieldValue", + "field": "agent", + "query": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\"", + "limit": 200 + } + }, + "regex": "", + "sort": "alphabeticalAsc", + "options": [], + "multi": true, + "includeAll": true, + "allowCustomValue": true } - ], - "fieldConfig": { - "defaults": { - "unit": "short", - "decimals": 0, - "color": { "mode": "thresholds" }, - "thresholds": { - "mode": "absolute", - "steps": [{ "color": "green", "value": null }] - } - }, - "overrides": [] - }, - "options": { - "reduceOptions": { - "calcs": ["lastNotNull"], - "fields": "", - "values": false - }, - "colorMode": "value", - "graphMode": "none", - "textMode": "auto" } - }, - { - "id": 4, - "type": "table", - "title": "Hosts by agent", - "description": "Each host an agent reached that restricted mode would refuse, with its request count.", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" - }, - "gridPos": { "h": 12, "w": 24, "x": 0, "y": 5 }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" - }, - "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | agent:$agent | stats by (agent, dest, port) count() as requests | sort by (requests) desc", - "queryType": "stats" - } + ], + "timeSettings": { + "timezone": "utc", + "from": "now-24h", + "to": "now", + "autoRefresh": "1m", + "autoRefreshIntervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" ], - "transformations": [ - { - "id": "organize", - "options": { - "excludeByName": { "Time": true }, - "renameByName": { - "agent": "Agent", - "dest": "Host", - "port": "Port", - "requests": "Requests" + "hideTimepicker": false, + "fiscalYearStartMonth": 0 + }, + "elements": { + "panel-1": { + "kind": "Panel", + "spec": { + "id": 1, + "title": "Requests", + "description": "Every request squid logged in the range; zero means the log feed is down.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | stats count() as requests", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "stat", + "version": "", + "spec": { + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + } } } } - ], - "fieldConfig": { - "defaults": { "unit": "short", "decimals": 0 }, - "overrides": [] }, - "options": { - "showHeader": true, - "sortBy": [{ "displayName": "Requests", "desc": true }] - } - }, - { - "id": 5, - "type": "timeseries", - "title": "Would-deny requests over time", - "description": "Would-deny requests per agent over the range.", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" - }, - "gridPos": { "h": 8, "w": 24, "x": 0, "y": 17 }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" + "panel-2": { + "kind": "Panel", + "spec": { + "id": 2, + "title": "Agents active", + "description": "Distinct agents that sent a request through the proxy in the range.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | stats count_uniq(agent) as agents", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } }, - "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | agent:$agent | stats by (agent) count() as requests", - "queryType": "statsRange", - "legendFormat": "{{agent}}" - } - ], - "fieldConfig": { - "defaults": { - "unit": "short", - "decimals": 0, - "color": { "mode": "palette-classic" }, - "custom": { - "drawStyle": "bars", - "lineWidth": 1, - "fillOpacity": 60, - "showPoints": "never", - "spanNulls": false, - "axisSoftMin": 0 + "vizConfig": { + "kind": "VizConfig", + "group": "stat", + "version": "", + "spec": { + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + } + } } - }, - "overrides": [] + } }, - "options": { - "legend": { - "displayMode": "list", - "placement": "bottom", - "showLegend": true, - "calcs": [] - }, - "tooltip": { "mode": "multi", "sort": "desc" } + "panel-3": { + "kind": "Panel", + "spec": { + "id": 3, + "title": "Refused (403)", + "description": "Requests the proxy refused: a destination that is not allowed.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | filter status:403 | stats count() as refused", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "stat", + "version": "", + "spec": { + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "orange", + "value": null + } + ] + } + }, + "overrides": [] + } + } + } + } + }, + "panel-4": { + "kind": "Panel", + "spec": { + "id": 4, + "title": "Credential challenges (407)", + "description": "First requests answered with a login challenge, before the client retried.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | filter status:407 | stats count() as challenges", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "stat", + "version": "", + "spec": { + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + } + } + } + } + }, + "panel-5": { + "kind": "Panel", + "spec": { + "id": 5, + "title": "Data transferred", + "description": "Bytes squid sent back to agents in the range.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | stats sum(bytes) as bytes", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "stat", + "version": "", + "spec": { + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "fieldConfig": { + "defaults": { + "unit": "bytes", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + } + } + } + } + }, + "panel-6": { + "kind": "Panel", + "spec": { + "id": 6, + "title": "Would-deny requests", + "description": "Requests let through that restricted mode would refuse; see the would-deny tab.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | filter agent:$agent | stats count() as requests", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "stat", + "version": "", + "spec": { + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "orange", + "value": null + } + ] + } + }, + "overrides": [] + } + } + } + } + }, + "panel-7": { + "kind": "Panel", + "spec": { + "id": 7, + "title": "Requests over time by status", + "description": "Requests per HTTP status the proxy answered with.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | stats by (status) count() as requests", + "queryType": "statsRange", + "legendFormat": "{{status}}" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "timeseries", + "version": "", + "spec": { + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "palette-classic" + }, + "custom": { + "drawStyle": "bars", + "lineWidth": 1, + "fillOpacity": 60, + "showPoints": "never", + "spanNulls": false, + "axisSoftMin": 0 + } + }, + "overrides": [] + } + } + } + } + }, + "panel-8": { + "kind": "Panel", + "spec": { + "id": 8, + "title": "Requests by agent", + "description": "Requests per agent in the range, busiest first.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | stats by (agent) count() as requests | sort by (requests) desc | limit 15", + "queryType": "stats", + "legendFormat": "{{agent}}" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "bargauge", + "version": "", + "spec": { + "options": { + "displayMode": "basic", + "orientation": "horizontal", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showUnfilled": true, + "valueMode": "text" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "value": null, + "color": "blue" + } + ] + }, + "color": { + "mode": "fixed", + "fixedColor": "blue" + } + }, + "overrides": [] + } + } + } + } + }, + "panel-9": { + "kind": "Panel", + "spec": { + "id": 9, + "title": "Data transferred by agent", + "description": "Bytes sent back to each agent in the range, most first.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | stats by (agent) sum(bytes) as bytes | sort by (bytes) desc | limit 15", + "queryType": "stats", + "legendFormat": "{{agent}}" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "bargauge", + "version": "", + "spec": { + "options": { + "displayMode": "basic", + "orientation": "horizontal", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showUnfilled": true, + "valueMode": "text" + }, + "fieldConfig": { + "defaults": { + "unit": "bytes", + "decimals": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "value": null, + "color": "blue" + } + ] + }, + "color": { + "mode": "fixed", + "fixedColor": "blue" + } + }, + "overrides": [] + } + } + } + } + }, + "panel-10": { + "kind": "Panel", + "spec": { + "id": 10, + "title": "Top destinations", + "description": "Hosts agents reached, with requests, bytes and distinct agents.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | stats by (dest) count() as requests, sum(bytes) as bytes, count_uniq(agent) as agents | sort by (requests) desc | limit 25", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [ + { + "kind": "organize", + "spec": { + "id": "organize", + "options": { + "excludeByName": { + "Time": true + }, + "renameByName": { + "dest": "Host", + "requests": "Requests", + "bytes": "Bytes", + "agents": "Agents" + } + } + } + } + ], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "table", + "version": "", + "spec": { + "options": { + "showHeader": true, + "sortBy": [ + { + "displayName": "Requests", + "desc": true + } + ] + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0 + }, + "overrides": [] + } + } + } + } + }, + "panel-11": { + "kind": "Panel", + "spec": { + "id": 11, + "title": "Refused (403)", + "description": "Requests the proxy refused: a destination that is not allowed.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | filter status:403 | stats count() as refused", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "stat", + "version": "", + "spec": { + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "orange", + "value": null + } + ] + } + }, + "overrides": [] + } + } + } + } + }, + "panel-12": { + "kind": "Panel", + "spec": { + "id": 12, + "title": "Agents refused", + "description": "Distinct agents with at least one refused request in the range.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | filter status:403 | stats count_uniq(agent) as agents", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "stat", + "version": "", + "spec": { + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "orange", + "value": null + } + ] + } + }, + "overrides": [] + } + } + } + } + }, + "panel-13": { + "kind": "Panel", + "spec": { + "id": 13, + "title": "Refused hosts by agent", + "description": "Each host an agent was refused, with its request count.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | filter status:403 | stats by (agent, dest) count() as requests | sort by (requests) desc", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [ + { + "kind": "organize", + "spec": { + "id": "organize", + "options": { + "excludeByName": { + "Time": true + }, + "renameByName": { + "agent": "Agent", + "dest": "Host", + "requests": "Requests" + } + } + } + } + ], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "table", + "version": "", + "spec": { + "options": { + "showHeader": true, + "sortBy": [ + { + "displayName": "Requests", + "desc": true + } + ] + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0 + }, + "overrides": [] + } + } + } + } + }, + "panel-14": { + "kind": "Panel", + "spec": { + "id": 14, + "title": "Refused requests over time", + "description": "Refused requests per agent over the range.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | filter status:403 | stats by (agent) count() as requests", + "queryType": "statsRange", + "legendFormat": "{{agent}}" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "timeseries", + "version": "", + "spec": { + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "palette-classic" + }, + "custom": { + "drawStyle": "bars", + "lineWidth": 1, + "fillOpacity": 60, + "showPoints": "never", + "spanNulls": false, + "axisSoftMin": 0 + } + }, + "overrides": [] + } + } + } + } + }, + "panel-15": { + "kind": "Panel", + "spec": { + "id": 15, + "title": "Recent refused requests", + "description": "The refused request lines themselves, newest first.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"TCP_\" !\"would_deny user=\" | extract_regexp \"(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)\" | extract_regexp \"^(?:[a-z]+://)?(?P[^/:]+)\" from url | filter agent:$agent | filter status:403", + "queryType": "instant" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "logs", + "version": "", + "spec": { + "options": { + "showTime": true, + "wrapLogMessage": true, + "prettifyLogMessage": false, + "enableLogDetails": true, + "sortOrder": "Descending", + "dedupStrategy": "none" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + } + } + } + } + }, + "panel-16": { + "kind": "Panel", + "spec": { + "id": 16, + "title": "Would-deny requests", + "description": "Requests let through that restricted mode would have refused, in the range.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | filter agent:$agent | stats count() as requests", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "stat", + "version": "", + "spec": { + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "orange", + "value": null + } + ] + } + }, + "overrides": [] + } + } + } + } + }, + "panel-17": { + "kind": "Panel", + "spec": { + "id": 17, + "title": "Agents logging", + "description": "Agents with at least one would-deny request in the range.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | filter agent:$agent | stats count_uniq(agent) as agents", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "stat", + "version": "", + "spec": { + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + } + } + } + } + }, + "panel-18": { + "kind": "Panel", + "spec": { + "id": 18, + "title": "Hosts by agent", + "description": "Each host an agent reached that restricted mode would refuse, with its request count.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | filter agent:$agent | stats by (agent, dest, port) count() as requests | sort by (requests) desc", + "queryType": "stats" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [ + { + "kind": "organize", + "spec": { + "id": "organize", + "options": { + "excludeByName": { + "Time": true + }, + "renameByName": { + "agent": "Agent", + "dest": "Host", + "port": "Port", + "requests": "Requests" + } + } + } + } + ], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "table", + "version": "", + "spec": { + "options": { + "showHeader": true, + "sortBy": [ + { + "displayName": "Requests", + "desc": true + } + ] + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0 + }, + "overrides": [] + } + } + } + } + }, + "panel-19": { + "kind": "Panel", + "spec": { + "id": 19, + "title": "Would-deny requests over time", + "description": "Would-deny requests per agent over the range.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | filter agent:$agent | stats by (agent) count() as requests", + "queryType": "statsRange", + "legendFormat": "{{agent}}" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "timeseries", + "version": "", + "spec": { + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "palette-classic" + }, + "custom": { + "drawStyle": "bars", + "lineWidth": 1, + "fillOpacity": 60, + "showPoints": "never", + "spanNulls": false, + "axisSoftMin": 0 + } + }, + "overrides": [] + } + } + } + } + }, + "panel-20": { + "kind": "Panel", + "spec": { + "id": 20, + "title": "Recent would-deny requests", + "description": "The would-deny lines themselves, newest first.", + "links": [], + "data": { + "kind": "QueryGroup", + "spec": { + "queries": [ + { + "kind": "PanelQuery", + "spec": { + "query": { + "kind": "DataQuery", + "group": "victoriametrics-logs-datasource", + "version": "v0", + "datasource": { + "name": "@logsDatasourceUid@" + }, + "spec": { + "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | filter agent:$agent", + "queryType": "instant" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "logs", + "version": "", + "spec": { + "options": { + "showTime": true, + "wrapLogMessage": true, + "prettifyLogMessage": false, + "enableLogDetails": true, + "sortOrder": "Descending", + "dedupStrategy": "none" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + } + } + } + } } }, - { - "id": 6, - "type": "logs", - "title": "Recent would-deny requests", - "description": "The would-deny lines themselves, newest first.", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" - }, - "gridPos": { "h": 10, "w": 24, "x": 0, "y": 25 }, - "targets": [ - { - "refId": "A", - "datasource": { - "type": "victoriametrics-logs-datasource", - "uid": "@logsDatasourceUid@" + "layout": { + "kind": "TabsLayout", + "spec": { + "tabs": [ + { + "kind": "TabsLayoutTab", + "spec": { + "title": "overview", + "layout": { + "kind": "GridLayout", + "spec": { + "items": [ + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 0, + "width": 4, + "height": 4, + "element": { + "kind": "ElementReference", + "name": "panel-1" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 4, + "y": 0, + "width": 4, + "height": 4, + "element": { + "kind": "ElementReference", + "name": "panel-2" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 8, + "y": 0, + "width": 4, + "height": 4, + "element": { + "kind": "ElementReference", + "name": "panel-3" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 12, + "y": 0, + "width": 4, + "height": 4, + "element": { + "kind": "ElementReference", + "name": "panel-4" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 16, + "y": 0, + "width": 4, + "height": 4, + "element": { + "kind": "ElementReference", + "name": "panel-5" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 20, + "y": 0, + "width": 4, + "height": 4, + "element": { + "kind": "ElementReference", + "name": "panel-6" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 4, + "width": 24, + "height": 8, + "element": { + "kind": "ElementReference", + "name": "panel-7" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 12, + "width": 12, + "height": 9, + "element": { + "kind": "ElementReference", + "name": "panel-8" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 12, + "y": 12, + "width": 12, + "height": 9, + "element": { + "kind": "ElementReference", + "name": "panel-9" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 21, + "width": 24, + "height": 12, + "element": { + "kind": "ElementReference", + "name": "panel-10" + } + } + } + ] + } + } + } }, - "expr": "_SYSTEMD_UNIT:\"squid.service\" \"would_deny user=\" | extract \"would_deny user= method= host= port= result=\" | agent:$agent", - "queryType": "instant" - } - ], - "options": { - "showTime": true, - "wrapLogMessage": true, - "prettifyLogMessage": false, - "enableLogDetails": true, - "sortOrder": "Descending", - "dedupStrategy": "none" + { + "kind": "TabsLayoutTab", + "spec": { + "title": "refused", + "layout": { + "kind": "GridLayout", + "spec": { + "items": [ + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 0, + "width": 12, + "height": 4, + "element": { + "kind": "ElementReference", + "name": "panel-11" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 12, + "y": 0, + "width": 12, + "height": 4, + "element": { + "kind": "ElementReference", + "name": "panel-12" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 4, + "width": 24, + "height": 12, + "element": { + "kind": "ElementReference", + "name": "panel-13" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 16, + "width": 24, + "height": 8, + "element": { + "kind": "ElementReference", + "name": "panel-14" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 24, + "width": 24, + "height": 10, + "element": { + "kind": "ElementReference", + "name": "panel-15" + } + } + } + ] + } + } + } + }, + { + "kind": "TabsLayoutTab", + "spec": { + "title": "would-deny", + "layout": { + "kind": "GridLayout", + "spec": { + "items": [ + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 0, + "width": 12, + "height": 4, + "element": { + "kind": "ElementReference", + "name": "panel-16" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 12, + "y": 0, + "width": 12, + "height": 4, + "element": { + "kind": "ElementReference", + "name": "panel-17" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 4, + "width": 24, + "height": 12, + "element": { + "kind": "ElementReference", + "name": "panel-18" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 16, + "width": 24, + "height": 8, + "element": { + "kind": "ElementReference", + "name": "panel-19" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 24, + "width": 24, + "height": 10, + "element": { + "kind": "ElementReference", + "name": "panel-20" + } + } + } + ] + } + } + } + } + ] } } - ] + } } diff --git a/nix/module-eval/grafana.nix b/nix/module-eval/grafana.nix index f05def3d..38606dc9 100644 --- a/nix/module-eval/grafana.nix +++ b/nix/module-eval/grafana.nix @@ -453,25 +453,43 @@ let && lib.all (m: lib.hasInfix "\"${m}\"" recorded) queried; } { - # The egress board ships, and the `extract` pattern its queries use is the - # field layout of the `would_deny` line squid logs: a changed `logformat` - # is a board of empty panels. - name = "the egress dashboard ships, and reads the field layout of squid's would_deny log line"; + # The egress board ships, and its queries read the two squid log lines as + # squid writes them: the would_deny line's field layout, and the default + # `squid` access format the overview and refused tabs parse. A changed + # `logformat` or `access_log` is a board of empty panels. + name = "the egress dashboard ships, and reads the field layout of squid's log lines"; ok = let provider = lib.head grafanaWithAuthelia.containers.swarm-grafana.config.services.grafana.provision.dashboards.settings.providers; shipped = lib.attrNames provider.options.path.entries; board = builtins.fromJSON (builtins.readFile ../host-modules/swarm-grafana/dashboards/egress.json); - exprs = lib.concatMap (p: map (t: t.expr or "") (p.targets or [ ])) board.panels; - pattern = "would_deny user= method= host= port= result="; - agentVar = lib.findFirst (v: v.name == "agent") null board.templating.list; + exprs = map (e: (lib.head e.spec.data.spec.queries).spec.query.spec.expr) ( + lib.attrValues board.spec.elements + ); + tabs = map (t: t.spec.title) board.spec.layout.spec.tabs; + wouldDeny = "would_deny user= method= host= port= result="; + access = "(?PTCP_[A-Z_]+)/(?P[0-9]{3}) (?P[0-9]+) (?P[A-Z]+) (?P\\\\S+) (?P\\\\S+)"; + agentVar = lib.findFirst (v: v.spec.name == "agent") null board.spec.variables; squid = builtins.readFile ../host-modules/hive-squid.nix; in lib.elem "egress.json" shipped - && lib.length (lib.filter (e: lib.hasInfix pattern e) exprs) == 5 + && + tabs == [ + "overview" + "refused" + "would-deny" + ] + # every panel sits in a tab, and every tab item names a panel + && + lib.sort (a: b: a < b) ( + lib.concatMap (t: map (i: i.spec.element.name) t.spec.layout.spec.items) board.spec.layout.spec.tabs + ) == lib.sort (a: b: a < b) (lib.attrNames board.spec.elements) + && lib.length (lib.filter (e: lib.hasInfix wouldDeny e) exprs) == 6 + && lib.length (lib.filter (e: lib.hasInfix access e) exprs) == 14 && agentVar != null - && lib.hasInfix pattern agentVar.query.query - && lib.hasInfix "logformat would_deny would_deny user=%[un method=%rm host=%>rd port=%>rP result=" squid; + && lib.hasInfix access agentVar.spec.query.spec.query + && lib.hasInfix "logformat would_deny would_deny user=%[un method=%rm host=%>rd port=%>rP result=" squid + && lib.hasInfix "access_log syslog:daemon.info squid !manager" squid; } { # The standing check on the collector's PRIORITY mapping — whether a line