From 80c3de0aad68927d28d56b10b54c41ebd2fbbba6 Mon Sep 17 00:00:00 2001 From: Alexander Zubarev Date: Thu, 6 Aug 2026 18:32:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?alert-processor=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alert-processor/.env | 93 ++++++++++++++++++++++++++++++++ alert-processor/Dockerfile | 15 ++++++ alert-processor/requirements.txt | 10 ++++ 3 files changed, 118 insertions(+) create mode 100644 alert-processor/.env create mode 100644 alert-processor/Dockerfile create mode 100644 alert-processor/requirements.txt diff --git a/alert-processor/.env b/alert-processor/.env new file mode 100644 index 0000000..1e94789 --- /dev/null +++ b/alert-processor/.env @@ -0,0 +1,93 @@ +APP_NAME=alert-processor +APP_HOST=0.0.0.0 +APP_PORT=8081 + +INTERNAL_API_TOKEN=super_internal_token +REQUIRE_INTERNAL_API_TOKEN=true + +REDIS_ENABLED=true +REDIS_URL=redis://llm-zabbix-redis:6379/0 +REDIS_KEY_PREFIX=alert +REDIS_FINGERPRINT_TTL_SECONDS=86400 +REDIS_EVENT_TTL_SECONDS=604800 + +SUPPRESS_ENABLED=true +SUPPRESS_WINDOW_SECONDS=900 +SUPPRESS_APPLY_TO_AVERAGE=true + +FLAP_ENABLED=true +FLAP_WINDOW_SECONDS=120 +FLAP_THRESHOLD=4 +FLAP_APPLY_TO_AVERAGE=true + +CORRELATION_ENABLED=true +CORRELATION_WINDOW_SECONDS=180 +CORRELATION_SUPPRESS_CHILDREN=true +CORRELATION_KIND_RULES_PATH=/app/config/event_kind_rules.yaml +CORRELATION_ROOT_CAUSE_PATH=/app/config/root_cause_map.yaml + +MATRIX_ENABLED=true +MATRIX_HOMESERVER_URL=https://mr.example.org +MATRIX_ROOM_ID=!roomid:mr.example.org +MATRIX_ACCESS_TOKEN=initial_access_token +MATRIX_REFRESH_TOKEN=initial_refresh_token +MATRIX_OAUTH_TOKEN_ENDPOINT=https://ms.example.org/oauth2/token +MATRIX_OAUTH_CLIENT_ID=id_client +MATRIX_OAUTH_CLIENT_SECRET= +MATRIX_ACCESS_TOKEN_EXPIRES_IN_SECONDS=300 +MATRIX_REFRESH_MARGIN_SECONDS=60 +MATRIX_TOKEN_STATE_FILE=/app/.matrix_token_state.json +MATRIX_MESSAGE_TYPE=m.notice +MATRIX_REQUEST_TIMEOUT_SECONDS=10 +MATRIX_VERIFY_TLS=true + +MAIL_ENABLED=true +MAIL_SMTP_HOST=smtp.example.org +MAIL_SMTP_PORT=587 +MAIL_SMTP_USERNAME=monitoring@example.org +MAIL_SMTP_PASSWORD=change_me +MAIL_FROM=monitoring@example.org +MAIL_TO=ops@example.org +MAIL_USE_STARTTLS=true +MAIL_USE_TLS=false +MAIL_TIMEOUT_SECONDS=15 +MAIL_SUBJECT_PREFIX=[LLM-Zabbix] + +ZABBIX_API_ENABLED=true +ZABBIX_API_URL=https://zb.example.org/api_jsonrpc.php +ZABBIX_API_TOKEN=change_me_zabbix_api_token +ZABBIX_WEB_URL=https://zb.example.org +ZABBIX_API_TIMEOUT_SECONDS=10 +ZABBIX_API_VERIFY_TLS=true +ZABBIX_GRAPH_PERIOD_HOURS=1 +ZABBIX_GRAPH_TIMEZONE=Europe/Moscow +ZABBIX_ENRICH_ONLY_NOTIFY=true + +LLM_ENABLED=true +LLM_BASE_URL=http://host.docker.internal:11434 +LLM_MODEL=qwen3.5:4b +LLM_TIMEOUT_SECONDS=300 +LLM_VERIFY_TLS=true +LLM_TEMPERATURE=0.1 +LLM_MAX_STEPS=4 +LLM_MAX_COMMANDS=4 + +LLM_TRIAGE_ENABLED=true +LLM_TRIAGE_CACHE_TTL_SECONDS=3600 + +LLM_CORRELATION_ENABLED=true +LLM_CORRELATION_MIN_CONFIDENCE=medium + +QUEUE_ENABLED=true +QUEUE_NAME=alert:queue:events +QUEUE_PROCESSING_NAME=alert:queue:processing +QUEUE_DEADLETTER_NAME=alert:queue:deadletter +QUEUE_BLOCK_TIMEOUT_SECONDS=5 +QUEUE_MAX_ATTEMPTS=3 +QUEUE_DEDUP_TTL_SECONDS=86400 +QUEUE_REQUEUE_PROCESSING_ON_STARTUP=true + +AUDIT_ENABLED=true +AUDIT_KEY_PREFIX=alert:audit +AUDIT_TTL_SECONDS=604800 +AUDIT_MAX_STAGE_RECORDS=200 \ No newline at end of file diff --git a/alert-processor/Dockerfile b/alert-processor/Dockerfile new file mode 100644 index 0000000..d58f5d2 --- /dev/null +++ b/alert-processor/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.12-slim + +WORKDIR /app + +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY app ./app + +EXPOSE 8081 + +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8081"] \ No newline at end of file diff --git a/alert-processor/requirements.txt b/alert-processor/requirements.txt new file mode 100644 index 0000000..eefe01b --- /dev/null +++ b/alert-processor/requirements.txt @@ -0,0 +1,10 @@ +fastapi>=0.115,<1.0 +uvicorn[standard]>=0.30,<1.0 +pydantic>=2.7,<3.0 +python-dotenv>=1.0,<2.0 +redis[hiredis]>=5.0,<6.0 +httpx>=0.27,<1.0 +aiosmtplib>=3.0,<4.0 +matplotlib>=3.9,<4.0 +tzdata>=2024.1 +PyYAML>=6.0,<7.0 \ No newline at end of file