crawler_alert, monitoring: AI crawler metrics and dashboards
Some checks failed
deploy / ansible (push) Failing after 1m17s

crawler-alert.py --metrics (5-minute timer) reads what the Traefik
access log gained since the last run, judges every request that names
an AI bot exactly like the weekly report (vendor IP ranges, forward-
confirmed rDNS, Meta's ASN) and writes cumulative counters to the
node_exporter textfile directory. Verdicts are cached per bot and IP
for a week, so DNS only sees new addresses; range files are refetched
once a day. It covers every router, while the mails keep watching
Forgejo only.

New dashboard "AI crawlers", and a row of it on the overview.

The overview's load gauge divided node_load1 by a count with fewer
labels, which matches nothing; aggregate both sides by host.

Assisted-by: Claude:opus-5-5
This commit is contained in:
Sergei Poljanski 2026-11-13 07:21:57 +04:00
commit bc0dac9188
Signed by: asxpi
GPG key ID: 4F8851660FA4121B
7 changed files with 1924 additions and 6 deletions

View file

@ -403,7 +403,7 @@
"type": "prometheus",
"uid": "prometheus"
},
"expr": "node_load1 / count by (host) (node_cpu_seconds_total{mode=\"idle\"})",
"expr": "sum by (host) (node_load1) / count by (host) (node_cpu_seconds_total{mode=\"idle\"})",
"legendFormat": "{{host}}",
"refId": "A",
"instant": true,
@ -769,7 +769,7 @@
"uid": "prometheus"
},
"expr": "topk(12, container_memory_working_set_bytes{name!=\"\"})",
"legendFormat": "{{host}} \u00b7 {{name}}",
"legendFormat": "{{host}} · {{name}}",
"refId": "A",
"instant": true,
"range": false
@ -826,7 +826,7 @@
"uid": "prometheus"
},
"expr": "topk(8, sum by (host, name) (rate(container_cpu_usage_seconds_total{name!=\"\"}[$__rate_interval])))",
"legendFormat": "{{host}} \u00b7 {{name}}",
"legendFormat": "{{host}} · {{name}}",
"refId": "A",
"instant": false,
"range": true
@ -1321,7 +1321,7 @@
"uid": "prometheus"
},
"expr": "(time() - restic_backup_last_success_timestamp_seconds) / 3600",
"legendFormat": "restic \u00b7 {{host}} \u00b7 {{repo}}",
"legendFormat": "restic · {{host}} · {{repo}}",
"refId": "A",
"instant": true,
"range": false
@ -1332,7 +1332,7 @@
"uid": "prometheus"
},
"expr": "(time() - s3_replicate_last_success_timestamp_seconds) / 3600",
"legendFormat": "replica hel1 \u2192 fsn1",
"legendFormat": "replica hel1 → fsn1",
"refId": "B",
"instant": true,
"range": false
@ -1488,6 +1488,579 @@
"enableLogDetails": true,
"dedupStrategy": "signature"
}
},
{
"type": "row",
"title": "AI crawlers",
"id": 30,
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 59
},
"panels": []
},
{
"type": "piechart",
"title": "Who is asking (time range)",
"id": 31,
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(crawler_ai_requests_total{verdict=\"verified\"}[$__range]))",
"legendFormat": "AI · verified",
"refId": "A",
"instant": true,
"range": false
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(crawler_ai_requests_total{verdict=\"spoofed\"}[$__range]))",
"legendFormat": "AI · spoofed",
"refId": "B",
"instant": true,
"range": false
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(crawler_ai_requests_total{verdict=~\"unknown|proxied|private\"}[$__range]))",
"legendFormat": "AI · unverifiable",
"refId": "C",
"instant": true,
"range": false
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(crawler_class_requests_total{class=\"other-bot\"}[$__range]))",
"legendFormat": "other bots",
"refId": "D",
"instant": true,
"range": false
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(crawler_class_requests_total{class=\"browser-like\"}[$__range]))",
"legendFormat": "browser-like",
"refId": "E",
"instant": true,
"range": false
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(crawler_class_requests_total{class=\"none\"}[$__range]))",
"legendFormat": "no user agent",
"refId": "F",
"instant": true,
"range": false
}
],
"gridPos": {
"h": 8,
"w": 6,
"x": 0,
"y": 60
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "short"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "verified"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "green"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "spoofed"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "red"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "proxied"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "blue"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "unknown"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "yellow"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "private"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "purple"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "AI · verified"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "green"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "AI · spoofed"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "red"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "AI · unverifiable"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "yellow"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "other bots"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "orange"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "browser-like"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "purple"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "no user agent"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "text"
}
}
]
}
]
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"pieType": "donut",
"legend": {
"displayMode": "table",
"placement": "right",
"showLegend": true,
"values": [
"value",
"percent"
]
},
"tooltip": {
"mode": "single"
}
},
"description": "From the Traefik access log, every router (crawler-alert.py --metrics, 5-minute timer). A request naming an AI bot counts as verified only if its source IP is in the vendor's published ranges, or passes forward-confirmed reverse DNS, or (Meta) sits in the vendor's own ASN. spoofed = the claim failed that check; unverifiable = via Cloudflare, no PTR, or over the DNS budget.",
"links": [
{
"title": "Crawler details",
"url": "/d/asxpio-crawlers?${__url_time_range}"
}
]
},
{
"type": "timeseries",
"title": "AI crawler requests by verdict (per minute)",
"id": 32,
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (verdict) (rate(crawler_ai_requests_total[$__rate_interval])) * 60",
"legendFormat": "{{verdict}}",
"refId": "A",
"instant": false,
"range": true
}
],
"gridPos": {
"h": 8,
"w": 9,
"x": 6,
"y": 60
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "short",
"custom": {
"stacking": {
"mode": "normal"
},
"fillOpacity": 40,
"lineWidth": 1
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "verified"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "green"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "spoofed"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "red"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "proxied"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "blue"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "unknown"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "yellow"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "private"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "purple"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "AI · verified"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "green"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "AI · spoofed"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "red"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "AI · unverifiable"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "yellow"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "other bots"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "orange"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "browser-like"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "purple"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "no user agent"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "text"
}
}
]
}
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"description": "From the Traefik access log, every router (crawler-alert.py --metrics, 5-minute timer). A request naming an AI bot counts as verified only if its source IP is in the vendor's published ranges, or passes forward-confirmed reverse DNS, or (Meta) sits in the vendor's own ASN. spoofed = the claim failed that check; unverifiable = via Cloudflare, no PTR, or over the DNS budget."
},
{
"type": "bargauge",
"title": "Verified AI crawlers by vendor (time range)",
"id": 33,
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sort_desc(sum by (vendor) (increase(crawler_ai_requests_total{verdict=\"verified\"}[$__range])))",
"legendFormat": "{{vendor}}",
"refId": "A",
"instant": true,
"range": false
}
],
"gridPos": {
"h": 8,
"w": 9,
"x": 15,
"y": 60
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-GrYlRd"
},
"unit": "short",
"decimals": 0,
"min": 0
},
"overrides": []
},
"options": {
"displayMode": "gradient",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"values": false
},
"showUnfilled": true,
"valueMode": "color"
}
}
],
"graphTooltip": 1,
@ -1501,4 +2074,4 @@
"tags": []
}
]
}
}