---
# Vector EDGE agent pipeline (DaemonSet) — thin publisher, single source of
# truth. Mounted via existingConfigMaps (NOT the chart's customConfig, whose
# Helm `tpl` pass collides with Vector's own {{ }} / ${ } syntax). Tails all pod
# logs, attaches only routing tokens, publishes to JetStream. No parsing.
data_dir: /vector-data-dir

api:
  enabled: false

sources:
  kubernetes_logs:
    type: kubernetes_logs

transforms:
  # Routing metadata only: NATS-subject-safe namespace + container tokens.
  keymeta:
    type: remap
    inputs:
      - kubernetes_logs
    source: |
      ns = to_string(.kubernetes.pod_namespace || "unknown") ?? "unknown"
      .ns_token = replace(ns, r'[^a-zA-Z0-9_-]', "_")
      cont = to_string(.kubernetes.container_name || "unknown") ?? "unknown"
      .cont_token = replace(cont, r'[^a-zA-Z0-9_-]', "_")

sinks:
  to_jetstream:
    type: nats
    inputs:
      - keymeta
    url: nats://nats.logging.svc.cluster.local:4222
    connection_name: vector-agent
    subject: "logs.k8s.{{ ns_token }}.{{ cont_token }}"
    jetstream:
      enabled: true
    auth:
      strategy: user_password
      user_password:
        user: log-producer
        password: ${NATS_PRODUCER_PASSWORD}
    encoding:
      codec: json
