Agents OTel sur droplets et VMs
Chaque hote monitore execute un agent OpenTelemetry local. L’agent collecte les metriques hote, les logs systeme, les logs Docker et relaie les traces/metriques/logs applicatifs vers l’endpoint central.
Fichiers a copier sur chaque hote
Section titled “Fichiers a copier sur chaque hote”Depuis ce repo:
otel-collector/agent.config.ymlotel-collector/compose.agent.ymlotel-collector/agent.env.example
Sur l’hote cible:
sudo mkdir -p /opt/otel-agentsudo cp agent.config.yml /opt/otel-agent/agent.config.ymlsudo cp compose.agent.yml /opt/otel-agent/compose.ymlsudo cp agent.env.example /opt/otel-agent/agent.envsudo chown -R $USER:$USER /opt/otel-agentcd /opt/otel-agentConfiguration
Section titled “Configuration”Edite agent.env:
OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.<domaine>OTEL_AGENT_USERNAME=agentOTEL_AGENT_PASSWORD=<mot-de-passe-agent>
DEPLOYMENT_ENVIRONMENT=productionSERVICE_NAMESPACE=infraCLOUD_PROVIDER=digitaloceanLe mot de passe doit correspondre au hash BASIC_AUTH_HASH configure dans .env sur la monitoring box.
Demarrage
Section titled “Demarrage”docker compose up -dVerifications
Section titled “Verifications”docker compose psdocker compose logs --tail=100 otel-agentDans Grafana:
- metriques hote dans VictoriaMetrics,
- logs dans Loki,
- traces dans Tempo si une app locale exporte vers l’agent.
Configuration des apps locales sur l’hote
Section titled “Configuration des apps locales sur l’hote”Pour envoyer les signaux a l’agent local plutot qu’au collector central:
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318OTEL_SERVICE_NAME=my-serviceOTEL_RESOURCE_ATTRIBUTES=deployment.environment=production,service.namespace=my-appsL’agent relaie ensuite vers l’endpoint central securise.