Overview
KloudMate Agent uses a dual-configuration approach to separate agent management from OpenTelemetry Collector configuration. This design enables remote configuration updates, platform-specific optimizations, and seamless configuration management.Configuration Architecture
Agent Configuration
Controls agent behavior, authentication, and update mechanisms
Collector Configuration
Defines OpenTelemetry pipelines, receivers, processors, and exporters
Configuration Hierarchy
The agent loads configuration from multiple sources in the following priority order:File Locations
Agent Configuration File
The agent configuration file location varies by deployment mode:The agent automatically creates the configuration directory if it doesn’t exist (file permissions:
0755).Collector Configuration File
The OpenTelemetry Collector configuration is platform-specific:- Host Mode
- Docker Mode
- Kubernetes DaemonSet
Default path:
/etc/kmagent/config.yamlUses host-col-config.yaml template with:- Host metrics collection (CPU, memory, disk, network)
- OTLP receiver for application telemetry
- Resource detection and enrichment
Configuration File Formats
Agent Configuration (YAML)
The agent configuration file uses a simplified YAML format:~/workspace/source/configs/agent-config.yaml
API key for authentication with KloudMate backend. Supports environment variable expansion.
OpenTelemetry collector endpoint URL (HTTP/S).
Configuration check interval for remote updates.
Debug exporter verbosity level:
none, basic, normal, detailed.Collector Configuration (YAML)
The collector configuration follows the standard OpenTelemetry Collector format:Structure
All collector configurations use environment variable substitution for sensitive values like
${env:KM_API_KEY}.Configuration Loading Process
The agent follows this initialization sequence:Parse CLI Arguments
Extract flags and determine configuration file path from
--agent-config or KM_AGENT_CONFIG environment variable.See implementation in ~/workspace/source/cmd/kmagent/main.go:179-230Load Agent Config
Read agent configuration file (if exists) and merge with CLI flags and environment variables.See implementation in
~/workspace/source/internal/config/config.go:73-117Determine Collector Config Path
Resolve platform-specific collector configuration path based on OS and deployment mode.
Load Collector Config
Read OpenTelemetry Collector configuration YAML and parse into internal structure.
Validate Configuration
Ensure all required fields are present and values are valid before starting the collector.
Environment Variable Substitution
Both configuration files support environment variable expansion:Configuration Validation
The agent performs validation during startup:Required Fields Validation
Required Fields Validation
Ensures critical configuration fields are present:
ExporterEndpoint: Must be a valid HTTP/HTTPS URLAPIKey: Must be non-empty for authenticated endpointsOtelConfigPath: Must be readable if specified
Path Validation
Path Validation
Verifies configuration file paths:
- Configuration directory must be writable
- Collector config file must exist and be valid YAML
- Parent directories are created automatically with
0755permissions
URL Validation
URL Validation
Validates endpoint URLs:
- Exporter endpoint must use HTTP or HTTPS scheme
- Update endpoint is derived from exporter endpoint if not explicitly set
- Hostname extraction follows pattern:
otel.kloudmate.dev→api.kloudmate.dev
~/workspace/source/internal/config/config.go:28-52Collector Config Validation
Collector Config Validation
OpenTelemetry Collector validates:
- All referenced components are registered
- Pipeline connections are valid
- Processor configurations are correct
- Exporter endpoints are reachable
Configuration Update Mechanism
The agent supports dynamic configuration updates without restart: Configuration updates are atomic operations using file rename to prevent corruption. See implementation in~/workspace/source/internal/updater/updater.go:123-159
Next Steps
Agent Configuration
Detailed agent configuration reference
Collector Configuration
OpenTelemetry Collector configuration guide