Grafana (full use of the existing monitoring/ stack, per OSS policy):
- datasources.yml: BotPostgres (uid bot-postgres) over the shared network;
grafana service joins 'shared' + carries the datasource env
- db_init.py: idempotent read-only role obs_reader (USAGE on schema public +
SELECT on bot_traces/bot_trace_events; skipped when
OBS_READER_PASSWORD empty; ALTER ROLE for rotation) + composite index
ix_bot_trace_events_stage_time (stage, created_at DESC) — senior-engineer
review applied with the column-name fix (event_type -> stage); (trace_id)
already covered by the existing (trace_id, created_at) index
- dashboards/bot-observability.json: KPI row (real traffic, events, Jev/
fallback errors, Jev p95, tokens, commits, archive guard), events/day,
per-stage p50/p95, mention statuses (arbiter+fallback aggregates + legacy
rows), DeepSeek arbiter actions, tokens/day, model-drift vs jev-1.13.0,
user-choice A/B, STT + audio.enhance health, archive size guard
- dashboards/bot-trace-explorer.json: trace table + full event drill-down
via the trace_id variable
ERP page (admin-only, Persian RTL, recharts@^3 for React 19):
- backend bot_metrics.py: read-only require_role('admin') endpoints
(summary/routing/quality/jev/stt/traces + trace detail); aggregates count
real traffic only (calibration/demo/chat_id=0 excluded)
- frontend BotMonitorPage at /bot-monitor (KPI cards, daily events,
status donut, arbiter actions, user-choice A/B, STT/enhance tables,
stage latency, tokens chart, traces table + detail drawer with payload
viewer); entry link from the admin panel; MobileTabBar hidden there
- api.ts: typed botMetrics client section
Tooling/docs:
- tools/seed_observability_demo.py: deterministic demo traces (source='demo',
every current pipeline stage incl. audio.enhance/jev.failure/arbitration/
fallback/user choices) — excluded from real-traffic aggregates
- monitoring/README.md + bot/docs/DEPLOY-AND-MONITORING.md: setup, seed and
rollback notes; alerts deliberately deferred (owner decision 2026-10-24)
Verified locally: obs_reader SELECT ok / INSERT denied; panels' SQL run as
obs_reader with data; datasource health OK; both dashboards survive a grafana
restart; endpoints 200 as admin and 403 without role; tsc + vite build clean;
page renders in-browser (admin session); bot startup provisions role+index.
77 lines
3.3 KiB
Bash
77 lines
3.3 KiB
Bash
# ============================================================
|
|
# ERP stack configuration — copy to .env and fill in real values.
|
|
# .env is git-ignored; NEVER commit real credentials.
|
|
# Local dev: cp .env.example .env (defaults work as-is)
|
|
# Production VPS: /srv/erp/.env with STRONG values for every entry —
|
|
# docker-compose.prod.yml refuses to boot without them.
|
|
# ============================================================
|
|
|
|
# --- Public hosts (production; local defaults live in docker-compose.yml) ---
|
|
APP_HOST=aramesh.bennu-api-bahrestan.ir
|
|
API_HOST=api.bennu-api-bahrestan.ir
|
|
AUTH_HOST=casdoor.bennu-api-bahrestan.ir
|
|
S3_HOST=s3.bennu-api-bahrestan.ir
|
|
STORAGE_HOST=storage.bennu-api-bahrestan.ir
|
|
|
|
# --- Traefik / Let's Encrypt ---
|
|
TRAEFIK_ACME_EMAIL=you@example.com
|
|
|
|
# --- Environment: "prod" enables the fail-fast startup checks in the API ---
|
|
ENVIRONMENT=prod
|
|
|
|
# --- PostgreSQL (app + Casdoor share the instance) ---
|
|
POSTGRES_PASSWORD=CHANGE_ME_strong_db_password
|
|
|
|
# --- MinIO object storage root credentials ---
|
|
MINIO_ROOT_USER=CHANGE_ME_minio_user
|
|
MINIO_ROOT_PASSWORD=CHANGE_ME_long_random_minio_password
|
|
|
|
# --- Casdoor OIDC application (must match the Casdoor application record) ---
|
|
CASDOOR_CLIENT_SECRET=CHANGE_ME_casdoor_client_secret
|
|
CASDOOR_ADMIN_PASSWORD=CHANGE_ME_casdoor_console_admin_password
|
|
|
|
# --- CORS: exact browser origins allowed to call the API (comma-separated) ---
|
|
CORS_ORIGINS=https://aramesh.bennu-api-bahrestan.ir
|
|
|
|
# --- Developer Mode (X-User-* header identity + login panel) ---
|
|
# MUST stay false in production. Only for local debugging without tokens.
|
|
DEV_LOGIN_ENABLED=false
|
|
|
|
# --- Deploy webhook (Gitea push → rebuild; see infra/deploy-webhook/) ---
|
|
GITEA_WEBHOOK_SECRET=CHANGE_ME_long_random_webhook_secret
|
|
|
|
# --- Backups (db-backup sidecar; see docker-compose.yml) ---
|
|
BACKUP_DIR=/srv/erp/backups
|
|
BACKUP_INTERVAL_SECONDS=86400
|
|
BACKUP_KEEP_DAYS=14
|
|
|
|
# --- Monitoring stack (see monitoring/README.md) ---
|
|
# API log format for Loki ingestion ("text" locally, "json" in production)
|
|
LOG_FORMAT=json
|
|
# GlitchTip (error tracking). GLITCHTIP_HOST must be a public DNS name —
|
|
# the browser SDK posts errors there.
|
|
GLITCHTIP_SECRET_KEY=CHANGE_ME_random_django_secret
|
|
GLITCHTIP_DOMAIN=https://errors.bennu-api-bahrestan.ir
|
|
GLITCHTIP_HOST=errors.bennu-api-bahrestan.ir
|
|
GLITCHTIP_DB_PASSWORD=CHANGE_ME_glitchtip_db_password
|
|
GLITCHTIP_FROM_EMAIL=noreply@bennu-api-bahrestan.ir
|
|
GLITCHTIP_EMAIL_URL=consolemail://
|
|
# Grafana (dashboards) — UI is loopback-only (:3001) unless you add Traefik labels
|
|
GRAFANA_ADMIN_PASSWORD=CHANGE_ME_grafana_password
|
|
GRAFANA_ROOT_URL=http://localhost:3001/
|
|
# Bot-observability datasource (Grafana → app Postgres, read-only role).
|
|
# The bot provisions the obs_reader role with this password at startup
|
|
# (empty = role skipped; datasource then can't connect).
|
|
PROCUREMENT_BOT_OBS_READER_PASSWORD=
|
|
OBS_READER_USER=obs_reader
|
|
# OpenPanel (product analytics) — client id/secret from the OpenPanel project
|
|
OPENPANEL_API_URL=http://openpanel-api:3333
|
|
OPENPANEL_CLIENT_ID=
|
|
OPENPANEL_CLIENT_SECRET=
|
|
# Public origin of the OpenPanel dashboard/API the BROWSER talks to
|
|
# (e.g. https://stats.bennu-api-bahrestan.ir — see monitoring/README.md)
|
|
OPENPANEL_PUBLIC_URL=
|
|
# Sentry/GlitchTip DSNs created in the GlitchTip UI after first boot
|
|
SENTRY_DSN_BACKEND=
|
|
SENTRY_DSN_FRONTEND=
|