monitoring.silences module
Mongo-backed alert silences for ChatOps.
Goals: - Fail-open: never raise; return safe defaults - Lazy init with env-only config (avoid global config import cycles) - TTL on until_ts so expired silences auto-clean - Active flag to allow manual unsilence before TTL
ENV: - ALERTS_DB_ENABLED or METRICS_DB_ENABLED: enable DB access - MONGODB_URL, DATABASE_NAME - ALERTS_SILENCES_COLLECTION (default: alerts_silences) - SILENCE_MAX_DAYS (default: 7) - SILENCES_MAX_ACTIVE (default: 50)
- monitoring.silences.parse_duration_to_seconds(text, *, max_days=7)[מקור]
Parse duration like ”30s“, ”5m“, ”2h“, ”3d“ to seconds, bounded by max_days. Returns None on invalid.
- monitoring.silences.create_silence(*, pattern, duration_seconds, created_by, reason='', severity=None, force=False)[מקור]
Create a new active silence. Returns stored document on success, else None.