# OCETS edge collector — main Telegraf configuration.
# Layout per OCETS-GUIDE-1.1 §5.1: this file contains ONLY agent settings,
# canonical identity tags, and outputs. All inputs live in telegraf.d/
# (edge-device.conf now; generated field-device files later).
#
# Validation ritual after every change (OCETS-GUIDE-1.1 §17):
#   telegraf --config /etc/telegraf/telegraf.conf \
#     --config-directory /etc/telegraf/telegraf.d --test

[global_tags]
  # Canonical identity from the Plant Registry (registry/solar-example.yaml).
  # Stable logical IDs — never hostname, IP, or hardware serial.
  # Field-device inputs added later override these with their own
  # device/role tags at plugin level.
  plant = "solar-example"
  device = "edge-collector-01"
  role = "collector"
  energy_form = "operational"

[agent]
  interval = "30s"
  round_interval = true
  metric_batch_size = 1000
  # Buffer for upstream outages: at current metric volume this holds
  # several hours before oldest metrics are dropped.
  metric_buffer_limit = 50000
  flush_interval = "30s"
  flush_jitter = "5s"
  # OCETS-CORE-1.1 §5.2 / §15.1: hostname is not canonical identity.
  omit_hostname = true

# Edge MQTT broker (local Mosquitto). The central collector subscribes
# to this broker over private network. Topic pattern per OCETS-GUIDE-1.1 §6;
# the topic is transport, NOT canonical identity.
[[outputs.mqtt]]
  servers = ["tcp://127.0.0.1:1883"]
  topic = 'telemetry/{{ .Tag "plant" }}/{{ .Tag "device" }}/{{ .Name }}'
  username = "edge-collector"
  password = "${OCETS_MQTT_PASSWORD}"   # from /etc/default/telegraf, not this file
  qos = 1
  retain = false
  data_format = "influx"
