# Paranoid profile: maximum caution, minimum throughput.
# Generated by `click-dog init --profile paranoid`.
# Use for sensitive or load-constrained clusters where read-side load must
# be tightly bounded. Every limit here is tighter than the production
# defaults; expect higher backoff on incidents and fewer spans exported
# per cycle.

clickhouse:
  host: localhost              # one Click-Dog per ClickHouse node, reading its local span log
  port: 9000
  database: system
  username: click_dog_monitor  # read-only monitoring user (SELECT on the span and query logs)
  password: ${CLICKHOUSE_PASSWORD}
  query_timeout_s: 5
  max_open_conns: 1           # serialize CH queries; max read-side protection
  max_idle_conns: 1
  max_memory_usage: 52428800  # 50MB per query (half the default)

# filters.query_text_mode controls whether raw SQL crosses the export boundary.
# Use normalized_only or none for privacy-sensitive production environments.
# See docs/filtering.md#query-text-export-modes.
exporters:
  otel:
    - collector_address: otel.example.com:4317
      service_name: click-dog-monitor
      secure: true

monitor:
  enabled: true
  min_trace_duration_ms: 5000   # 5s: only the slowest traces
  check_interval_s: 60          # twice the default polling cadence
  lookback_buffer_s: 30
  max_spans_per_cycle: 100      # one tenth the default
  batch_size: 50
  batch_delay_ms: 100
  dedup_cache_size: 5000
  # monitor.max_query_length skips spans whose SQL exceeds this many chars,
  # before they reach the exporter. Setting it tighter here makes the
  # exporter-side `exporters.otel[*].max_query_length` truncation moot,
  # so we omit that knob entirely to avoid two values disagreeing.
  max_query_length: 10000
  # Trip (open) on any pair of failures, demand two consecutive successes
  # before recovering to the closed (normal-flow) state. Long reset window
  # so a flapping cluster gets quiet time. See docs/resilience.md for the
  # full state-machine description.
  circuit_breaker:
    enabled: true
    failure_threshold: 2
    success_threshold: 2
    reset_timeout_s: 120
  # Aggressive backoff: 3x growth, longer reset window before snapping back.
  backoff:
    enabled: true
    max_interval_s: 600
    backoff_factor: 3.0
  # Canary stays armed during incidents so operators retain visibility into
  # whether long queries exist even when the breaker is open. See
  # docs/troubleshooting.md#canary-queries-in-degraded-mode.
  canary:
    enabled: true
    threshold_duration_ms: 60000

filters:
  # Never export raw SQL in the paranoid profile. If ClickHouse cannot provide
  # a normalized preview, query text is omitted rather than falling back.
  query_text_mode: normalized_only
  # Both lists are ACTIVE here (unlike minimal's commented block): paranoid's
  # max_spans_per_cycle budget would otherwise fill with engine-internal spans
  # instead of the slow query spans it exists to catch, and aggressive dropping
  # is the profile's whole point. Engine ops carry no clickhouse.query_id.
  blacklist_queries:
    - "^SYSTEM"
    - "^INSERT INTO.*\\.inner\\."
  blacklist_operations:
    - "MergeTreeSource"
    - "MergeTreeMarksLoader"
    - "MergeTreeIndex"
    - "MergeTreeSequentialSource"
    - "VFSWrite"
    - "WriteBufferFromS3"
    - "ConcurrentJoin"
    - "QueryPipelineEx"

log_level: warn
