Docker agent configuration

The Middleware.io Host Agent can be extensively configured using environment variables. These variables allow you to fine-tune data collection, logging, and integration behavior.

Environment Variables

The following table lists the most commonly used environment variables for configuring the Middleware.io Host Agent.

Environment VariableDescriptionDefault ValueExample Usage
MW_API_KEY(Required) Your unique Middleware.io API key for authenticating the agent.(None)-e MW_API_KEY="your_api_key_here"
MW_TARGET(Required) The ingestion URL for your Middleware.io instance where the agent should send data.(None)-e MW_TARGET="https://ingest.middleware.io/v1/"
MW_HOST_TAGSComma-separated list of custom tags to apply to the host and all metrics/logs collected from it. Useful for filtering and organizing data.(None)-e MW_HOST_TAGS="env:prod,location:us-east-1"
MW_LOG_LEVELSets the logging verbosity for the agent. Useful for debugging.info-e MW_LOG_LEVEL="debug" (Options: error, warn, info, debug, trace)
MW_COLLECT_METRICSEnables or disables metric collection. Set to false to disable.true-e MW_COLLECT_METRICS="false"
MW_COLLECT_LOGSEnables or disables log collection. Set to false to disable.true-e MW_COLLECT_LOGS="false"
MW_COLLECT_TRACESEnables or disables trace collection. Note: This primarily controls the agent's ability to receive traces from language-specific APM agents. Individual APM agents need to be configured separately.true-e MW_COLLECT_TRACES="false"
MW_AGENT_SERVICEA custom name for the agent service. This can help differentiate agents in your dashboard if you have multiple running.mw-host-agent-e MW_AGENT_SERVICE="my-docker-host-agent"
MW_AGENT_LOG_PATHSComma-separated list of additional host log file paths (full paths) that the agent should monitor and collect.(None)-e MW_AGENT_LOG_PATHS="/var/log/nginx/error.log,/opt/app/logs/server.log"
HTTP_PROXYHTTP proxy to use for outbound connections.(None)-e HTTP_PROXY="http://proxy.example.com:8080"
HTTPS_PROXYHTTPS proxy to use for outbound connections.(None)-e HTTPS_PROXY="https://proxy.example.com:8080"
NO_PROXYComma-separated list of hosts or domains that should bypass the proxy.localhost,127.0.0.1-e NO_PROXY="localhost,10.0.0.0/8"
MW_HOSTNAMEOverrides the hostname reported by the agent. By default, it uses the container's hostname or the host's actual hostname if --hostname $(hostname) is used.(System hostname)-e MW_HOSTNAME="my-custom-docker-host"
MW_CONTAINER_EXCLUDE_LISTComma-separated list of container names or image names to exclude from monitoring. Wildcards (*) are supported. Example: ^nginx.*,my-app-v2 or nginx*,redis(None)-e MW_CONTAINER_EXCLUDE_LIST="^monitoring-*,^kube-*"
MW_CONTAINER_INCLUDE_LISTComma-separated list of container names or image names to explicitly include for monitoring. If provided, only containers matching this list will be monitored. Wildcards (*) are supported. Example: ^app-*,my-database(None - all included)-e MW_CONTAINER_INCLUDE_LIST="^my-web-app-*,^my-api-service-*"
MW_COLLECT_PROCESSESEnables or disables process metric collection on the host.true-e MW_COLLECT_PROCESSES="false"
MW_METRIC_INTERVAL_SECONDSInterval (in seconds) at which metrics are collected.10-e MW_METRIC_INTERVAL_SECONDS="30"
MW_LOG_BUFFER_SIZEMaximum number of log lines to buffer before sending.1000-e MW_LOG_BUFFER_SIZE="2000"

Volume Mounts

Proper volume mounts are critical for the agent to access the necessary host and Docker resources. Ensure these are correctly configured as shown in the installation examples:

  • /var/run/docker.sock:/var/run/docker.sock:ro: Essential for the agent to communicate with the Docker daemon and discover containers.
  • /proc:/proc:ro: Provides access to host process and system information for metrics.
  • /sys:/sys:ro: Provides access to system-level information.
  • /etc/os-release:/etc/os-release:ro: Helps the agent identify the host's operating system.
  • /var/lib/docker/containers:/var/lib/docker/containers:ro: Required for the agent to read container logs from their respective log files.
  • /var/log:/var/log:ro: (Optional) For collecting general host logs, such as system logs or application logs residing outside of Docker containers.

Important Note on Permissions: Ensure the user running the Docker daemon (and thus the agent container) has appropriate permissions to access these host paths. The :ro (read-only) mode is recommended for security where applicable.

Network Configuration

  • Host Network Mode: For some advanced scenarios, or if you need the agent to bind directly to host network interfaces, you might consider using network_mode: host in Docker Compose or --network host with docker run. However, the default bridge network mode is generally sufficient for basic data collection as long as the agent can reach the Middleware.io ingestion endpoint.
    • Caution: Using host network mode bypasses Docker's network isolation, which has security implications. Only use if strictly necessary and understood.
  • Firewall Rules: Ensure that your host's firewall (e.g., ufw, firewalld, iptables) allows outbound connections from the Docker host to the MW_TARGET URL (typically port 443 for HTTPS).

Integrations (Containerized Applications)

The Middleware.io Host Agent primarily collects infrastructure and container-level data. To get Application Performance Monitoring (APM) traces from your applications running inside Docker containers, you'll need to instrument your application code with language-specific Middleware.io APM agents.

These APM agents automatically detect the running Middleware.io Host Agent and send traces to it, which are then forwarded to your Middleware.io dashboard.

  • Java APM Agent: [Link to Java APM Agent Docs]
  • Node.js APM Agent: [Link to Node.js APM Agent Docs]
  • Python APM Agent: [Link to Python APM Agent Docs]
  • ... (and so on for other supported languages)

Refer to the respective APM agent documentation for detailed installation and configuration instructions for your specific application environment within Docker.