Files
MathApp/docker/alloy/config.alloy

57 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// پیکربندیِ حداقلیِ Grafana Alloy — جایگزینِ Promtail (که EOL شده،
// مارچ ۲۰۲۶). دقیقاً همون کاری که promtail-config.yml قبلی می‌کرد:
// فایلِ لاگِ JSON اپِ Django رو tail می‌کنه، level/logger رو به‌عنوانِ
// لیبل استخراج می‌کنه، و به Loki push می‌کنه. هیچ لاگِ جدیدی تولید
// نمی‌کنه و پیامِ لاگ‌ها دست‌نخورده می‌مونه.
// مرحله‌ی ۱: پیدا کردنِ فایل‌های لاگ روی ولومِ مشترک (django_logs)
local.file_match "django_logs" {
path_targets = [{
__path__ = "/var/log/django/*.log",
job = "django",
app = "tadrisino",
}]
}
// مرحله‌ی ۲: خوندنِ همون فایل‌ها
loki.source.file "django_logs" {
targets = local.file_match.django_logs.targets
forward_to = [loki.process.django_logs.receiver]
}
// مرحله‌ی ۳: پردازش — استخراجِ level/logger/timestamp از JSONِ هر خط
// (فرمتِ config.log_formatters.JSONLogFormatter) و ست‌کردنِ اونا به‌عنوانِ
// لیبل، دقیقاً هم‌ارزِ stage.json + stage.labels + stage.timestamp در
// promtail-config.yml قبلی.
loki.process "django_logs" {
stage.json {
expressions = {
level = "",
logger = "",
timestamp = "",
}
}
stage.labels {
values = {
level = "",
logger = "",
}
}
// استفاده از timestampِ خودِ لاگ (نه زمانِ رسیدنِ خط به Alloy)
stage.timestamp {
source = "timestamp"
format = "RFC3339"
}
forward_to = [loki.write.local.receiver]
}
// مرحله‌ی ۴: ارسال به Loki
loki.write "local" {
endpoint {
url = "http://loki:3100/loki/api/v1/push"
}
}