DealDocumentScreening/deploy/observability/vector-config.yaml
febux 85db70887d Fix Vector config and OpenObserve auth for live E2E verification
Ticket 10 verification surfaced runtime issues that static validation
missed; all verified against running Docker stack (Vector 0.43 + OO 0.92.2):

- Rewrite VRL for Vector 0.43: no coalesce/default funcs, merge!/replace!
  for guarded fallible calls, no two-value parse_json destructuring
- Quote env-interpolated sink credentials (empty env left a bare YAML null)
- Fix logs sink URI: OO needs /api/{org}/{stream}/_json (stream segment
  was missing, causing 404); logs now land in contract_check stream
- Replace OPENOBSERVE_AUTH_TOKEN with root email/password Basic auth:
  prometheus_remote_write ignores request.headers, so remote-write got 401
- Update .env.example, DEPLOY.md, ARCHITECTURE.md, ticket 05 accordingly

Verified live: logs with service + correlation_id searchable in
OpenObserve; contract_check_* metrics queryable via its Prometheus API;
no outbound port 4318 connections from app containers.
2026-09-06 19:41:04 +03:00

109 lines
3.4 KiB
YAML

# Vector configuration for the `observer` profile (passive observability).
#
# Vector reads container logs from the local Docker socket and scrapes service
# /metrics endpoints inside the compose network, then forwards logs and metrics
# to OpenObserve. The application itself does not push telemetry.
# -----------------------------------------------------------------------------
# Sources
# -----------------------------------------------------------------------------
sources:
docker_logs:
type: docker_logs
# Read from the local Docker socket mounted by compose.
docker_host: unix:///var/run/docker.sock
include_labels:
- com.docker.compose.project=dealdocumentscreening
service_metrics:
type: prometheus_scrape
endpoints:
- http://api:8000/metrics
- http://worker-extract:9101/metrics
- http://worker-analyze:9102/metrics
- http://worker-prescreen:9104/metrics
- http://worker-billing:9105/metrics
- http://worker-notify:9103/metrics
scrape_interval_secs: 15
# The token is optional: an empty METRICS_BEARER_TOKEN leaves /metrics open.
authorization:
strategy: bearer
token: "${METRICS_BEARER_TOKEN-}"
# -----------------------------------------------------------------------------
# Transforms
# -----------------------------------------------------------------------------
transforms:
enrich_logs:
type: remap
inputs:
- docker_logs
source: |
# Derive a short service label from the container metadata
# (docker_logs always provides container_name).
.container = .container_name
.service = .container_name
# If the log line is JSON from our structured logger, merge its fields
# without overwriting Vector/container metadata.
raw = .message
if is_string(raw) {
parsed = parse_json(raw) ?? null
if is_object(parsed) {
. = merge!(parsed, .)
service = parsed.service
if service != null {
.service = service
}
correlation_id = parsed.correlation_id
if correlation_id != null {
.correlation_id = correlation_id
}
}
}
# Trim the compose project prefix for a cleaner service label.
if is_string(.service) {
.service = replace!(.service, r'^contract_check-', "")
}
# -----------------------------------------------------------------------------
# Sinks
# -----------------------------------------------------------------------------
sinks:
openobserve_logs:
type: http
inputs:
- enrich_logs
uri: http://openobserve:5080/openobserve/api/default/contract_check/_json
method: post
auth:
strategy: basic
user: "${OPENOBSERVE_ROOT_USER_EMAIL-}"
password: "${OPENOBSERVE_ROOT_USER_PASSWORD-}"
encoding:
codec: json
batch:
max_events: 100
timeout_secs: 1
request:
headers:
Content-Type: application/json
openobserve_metrics:
type: prometheus_remote_write
inputs:
- service_metrics
# OpenObserve answers Vector's healthcheck probe with 405; this is
# harmless — actual remote-write POSTs succeed (200).
endpoint: http://openobserve:5080/openobserve/api/default/prometheus/api/v1/write
auth:
strategy: basic
user: "${OPENOBSERVE_ROOT_USER_EMAIL-}"
password: "${OPENOBSERVE_ROOT_USER_PASSWORD-}"
batch:
max_events: 100
timeout_secs: 1