throttling, abuse-protection & logging/monitoring pass

This commit is contained in:
2026-08-23 23:44:00 +03:30
parent cb18c93a3e
commit 80298b47b1
33 changed files with 4202 additions and 23 deletions

View File

@@ -0,0 +1,63 @@
{
"title": "Tadrisino Django Logs",
"uid": "tadrisino-django-logs",
"timezone": "browser",
"schemaVersion": 39,
"version": 1,
"time": { "from": "now-6h", "to": "now" },
"refresh": "10s",
"templating": {
"list": [
{
"name": "level",
"type": "query",
"datasource": { "type": "loki", "uid": "Loki" },
"query": "label_values({job=\"django\"}, level)",
"refresh": 2,
"includeAll": true,
"multi": true,
"current": { "text": "All", "value": "$__all" }
},
{
"name": "search",
"type": "textbox",
"label": "Search text",
"current": { "text": "", "value": "" }
}
]
},
"panels": [
{
"id": 1,
"title": "Log volume by level",
"type": "timeseries",
"datasource": { "type": "loki", "uid": "Loki" },
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 0 },
"targets": [
{
"expr": "sum by (level) (count_over_time({job=\"django\", level=~\"$level\"} |= `$search` [1m]))",
"refId": "A"
}
]
},
{
"id": 2,
"title": "Django application logs",
"type": "logs",
"datasource": { "type": "loki", "uid": "Loki" },
"gridPos": { "h": 16, "w": 24, "x": 0, "y": 8 },
"options": {
"showTime": true,
"showLabels": true,
"wrapLogMessage": true,
"sortOrder": "Descending"
},
"targets": [
{
"expr": "{job=\"django\", level=~\"$level\"} |= `$search`",
"refId": "A"
}
]
}
]
}

View File

@@ -0,0 +1,13 @@
# به Grafana می‌گه داشبوردهای JSON رو از /var/lib/grafana/dashboards
# (که در docker-compose.yml به docker/grafana/dashboards mount شده) بخونه.
apiVersion: 1
providers:
- name: Django Logs
orgId: 1
folder: ""
type: file
disableDeletion: false
updateIntervalSeconds: 30
options:
path: /var/lib/grafana/dashboards

View File

@@ -0,0 +1,15 @@
# Loki رو به‌صورتِ خودکار به‌عنوانِ دیتاسورسِ پیش‌فرضِ Grafana اضافه می‌کنه
# (نیازی به تنظیمِ دستی در UI نیست).
apiVersion: 1
datasources:
- name: Loki
type: loki
access: proxy
url: http://loki:3100
# UID رو صریح ست می‌کنیم چون داشبورد (django-logs.json) با همین UID
# (uid: "Loki") به این دیتاسورس ارجاع می‌ده؛ بدونِ این، Grafana خودش
# یک UID تصادفی تولید می‌کرد و ارجاعِ داشبورد resolve نمی‌شد.
uid: Loki
isDefault: true
editable: true