Overview
The KloudMate Agent configuration controls agent behavior, authentication, remote configuration updates, and platform-specific settings. This configuration is separate from the OpenTelemetry Collector configuration to enable independent management and updates.Configuration Structure
The agent configuration is defined by theConfig struct in Go:
~/workspace/source/internal/config/config.go:14-26
Configuration Parameters
Authentication
Authentication key for KloudMate backend services.Sources:
- CLI flag:
--api-key - Environment:
KM_API_KEY - Config file:
keyfield
Endpoints
OpenTelemetry exporter endpoint URL for sending telemetry data.Sources:
- CLI flag:
--collector-endpoint - Environment:
KM_COLLECTOR_ENDPOINT - Config file:
endpointfield
https://otel.kloudmate.com:4318Format: Must be a valid HTTP/HTTPS URL with optional portExamples:API endpoint for fetching configuration updates.Sources:See implementation in
- CLI flag:
--update-endpoint - Environment:
KM_UPDATE_ENDPOINT - Config file: Not configurable via file
ExporterEndpointDerivation Logic:
The update URL is automatically constructed from the exporter endpoint:- Extract root domain from exporter endpoint
- Prepend
api.subdomain - Append
/agents/config-checkpath
~/workspace/source/internal/config/config.go:28-52Explicitly setting this value overrides the auto-derivation behavior.
Update Behavior
Interval in seconds between configuration update checks.Sources:
- CLI flag:
--config-check-interval - Environment:
KM_CONFIG_CHECK_INTERVAL - Config file:
intervalfield (duration format)
60 (seconds)Range: 10 to 3600 seconds recommendedExamples:Lower intervals enable faster configuration updates but increase API requests. For production,
60-300 seconds is recommended.File Paths
Path to the agent configuration YAML file.Sources:
- CLI flag:
--agent-config - Environment:
KM_AGENT_CONFIG
- Linux/Unix: Not used (flags/env only)
- macOS: Not used (flags/env only)
- Windows: Not used (flags/env only)
- Docker: Not used (flags/env only)
This parameter specifies where to find the agent config file for initial loading, not where to store runtime config.
Path to the OpenTelemetry Collector configuration YAML file.Sources:See implementation in
- CLI flag:
--config - Environment:
KM_COLLECTOR_CONFIG
- Linux/Unix
- macOS
- Windows
- Docker
~/workspace/source/internal/config/config.go:54-70Docker Mode
Enable Docker-specific configuration and monitoring.Sources:
- CLI flag:
--docker-mode - Environment:
KM_DOCKER_MODE
falseEffects:- Uses Docker-specific collector configuration template
- Enables
docker_statsreceiver for container metrics - Monitors Docker socket for container events
- Adjusts file paths for containerized environment
Docker daemon socket endpoint for container monitoring.Sources:
- CLI flag:
--docker-endpoint - Environment:
KM_DOCKER_ENDPOINT
unix:///var/run/docker.sockFormats:Kubernetes Configuration
For Kubernetes deployments, additional configuration is available:~/workspace/source/internal/config/config_k8s.go:18-37
Kubernetes-Specific Parameters
Kubernetes namespace where the agent is deployed.Environment:
KM_NAMESPACEDefault: km-agentUnique identifier for the Kubernetes cluster.Environment:
KM_CLUSTER_NAMEUsage: Added as k8s.cluster.name attribute to all telemetry data.Kubernetes deployment mode for the agent.Values:
daemonset: Node-level monitoring (default)deployment: Cluster-level monitoringboth: Both DaemonSet and Deployment
Name of ConfigMap containing DaemonSet collector configuration.Default:
km-daemonset-configName of ConfigMap containing Deployment collector configuration.Default:
km-deployment-configName of the KloudMate agent DaemonSet.Default:
km-agent-daemonsetName of the KloudMate agent Deployment.Default:
km-agent-deploymentEnvironment Variables Reference
- Required
- Optional
- Kubernetes
Configuration Examples
Minimal Configuration
agent-config.yaml
Production Configuration
agent-config.yaml
Docker Configuration
agent-config.yaml
Docker Compose
Kubernetes Configuration
ConfigMap
DaemonSet Environment
Configuration Loading
The agent loads configuration through theLoadConfig() method:
~/workspace/source/internal/config/config.go:73-117
Validation
The agent performs the following validation checks:API Key Validation
API Key Validation
- Must be non-empty when connecting to authenticated endpoints
- No format restrictions (supports various key formats)
- Passed as
Authorizationheader to all API requests
Endpoint Validation
Endpoint Validation
- Must be a valid URL with HTTP or HTTPS scheme
- Port is optional (defaults to scheme default)
- Hostname must be resolvable
- Update URL is auto-derived if not explicitly set
Interval Validation
Interval Validation
- Must be a positive integer (seconds)
- Recommended range: 10-3600 seconds
- Too low values may cause API rate limiting
Path Validation
Path Validation
- Configuration directory must be writable
- Parent directories are created automatically
- Collector config file must be valid YAML
Remote Configuration Updates
The agent periodically checks for configuration updates:Send Status Update
POST request to See implementation in
ConfigUpdateURL with agent status:~/workspace/source/internal/updater/updater.go:64-121Troubleshooting
Configuration Not Loading
Configuration Not Loading
Symptom: Agent starts but doesn’t use configuration fileCauses:
- File doesn’t exist at expected path
- Invalid YAML syntax
- Incorrect file permissions
Environment Variables Not Expanded
Environment Variables Not Expanded
Symptom: Literal
${VAR} appearing in configurationCauses:- Environment variable not set
- Wrong syntax for variable expansion
Remote Updates Not Working
Remote Updates Not Working
Symptom: Configuration never updates from serverCauses:
- Update URL not reachable
- Invalid API key
- Firewall blocking outbound requests
Next Steps
Collector Configuration
Configure OpenTelemetry Collector pipelines
Configuration Structure
Understand configuration architecture