Understanding the Agent Config Files

Out of the box, the Sysdig agent will gather and report on a wide variety of pre-defined metrics. It can also accommodate any number of custom parameters for additional metrics collection. 

The agent relies on a pair of configuration files to define metrics collection parameters:

dragent.default.yaml The core configuration file. You can look at it to understand more about the default configurations provided.
Location: "/opt/draios/etc/dragent.default.yaml."
Warning: This file should never be edited. 
dragent.yaml The configuration file  where parameters can be added, either directly in YAML as name/value pairs, or using environment variables such as 'ADDITIONAL_CONF."
Location: "/opt/draios/etc/dragent.yaml."

The "dragent.yaml" file can be accessed and edited in several ways, depending on how the agent was installed.  This document describes  how to modify dragent.yaml.

Access and Edit the Config File

There are various ways to add or edit parameters in dragent.yaml.

Option 1: Access dragent.yaml directly (for testing)

It is possible to edit the container’s file directly on the host.
Add parameters directly in YAML. 

  1. Access dragent.yaml directly at "/opt/draios/etc/dragent.yaml."

  2. Edit the file. Use proper YAML syntax.
    See also <Example:simple> and <Example:complex>. 

  3. Restart the agent for changes to take effect
  •  Native agent: service dragent restart
  • Container agent: docker restart sysdig-agent

Option 2: Edit the sysdig-agent configmap or daemonset file (Kubernetes)

Sysdig provides two ways to install agents as DaemonSets on a system running Kubernetes. Each method uses Sysdig configuration files to connect with and manipulate the underlying dragent.yaml file.  
See also: Sysdig Install: Kubernetes

Add parameters directly in YAML. 

Edit the files locally and apply with the changes with kubectl -f.

  1. Access either the configmap.yaml or the daemonset-v1.yaml, depending on your installation.
  2. Edit the file as needed.
  3. Apply the changes:
    kubectl apply -f sysdig-agent-configmap.yaml 
    kubectl apply -f sysdig-agent-daemonset-v1.yaml
    Running agents will automatically pick the new configuration after Kubernetes pushes the changes across all the nodes in the cluster.

Option 3: Add parameters to a Docker run command (Docker)

Add -e ADDITIONAL_CONF=”<VARIABLES>” to a Docker run command, where <VARIABLES> contains all the customized parameters you want to include, in a single-line format. 

How to Convert YAML Parameters to Single-Line Format

To insert ADDITIONAL_CONF parameters in a Docker run command or a daemonset file, you must convert the YAML code into a single-line format. 

You can do the conversion manually for short snippets. To convert longer portions of YAML, use echo|sed commands.

The basic procedure:

  1. Write your configuration in YAML, as it would be entered directly in dragent.yaml
  2. In a bash shell, use echo and sed to convert to a single line. 
    sed script: " | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g'
  3. Insert theresulting line into a Docker run command or add it to the daemonset file as an ADDITIONAL_CONF

Example: Simple

Insert parameters to turn off StatsD collection and blacklist port 6666. 

YAML format 

  enabled: false
  - 6666

Single-line format (manual) 

Use spaces, hyphens, and  \n correctly when manually converting to a single line:

ADDITIONAL_CONF="statsd:\n  enabled: false\nblacklisted_ports:\n  - 6666" 

Here the single line is incorporated into a full agent startup Docker command.

docker run --name sysdig-agent  --privileged --net host --pid host -e ACCESS_KEY=1234-your-key-here-1234 -e TAGS=dept:sales,local:NYC -e ADDITIONAL_CONF="statsd:\n  enabled: false\nblacklisted_ports:\n  - 6666" -v /var/run/docker.sock:/host/var/run/docker.sock -v /dev:/host/dev -v /proc:/host/proc:ro -v /boot:/host/boot:ro -v /lib/modules:/host/lib/modules:ro -v /usr:/host/usr:ro sysdig/agent

Insert parameters to override the default configuration for a RabbitMQ app check.

Example: Complex

YAML format 

  - name: rabbitmq
      port: 15672
      rabbitmq_api_url: "http://localhost:15672/api/"
      rabbitmq_user: myuser
      rabbitmq_pass: mypassword
        - MyQueue1
        - MyQueue2

Single-line format (echo |sed) 

From a bash shell, issue the echo command and sed script. 

echo "app_checks:
  - name: rabbitmq
      port: 15672
      rabbitmq_api_url: "http://localhost:15672/api/"
      rabbitmq_user: myuser
      rabbitmq_pass: mypassword
        - MyQueue1
        - MyQueue2
" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g

This results in the single-line format to be used with ADDITIONAL_CONF in a Docker command or daemonset file. 

"app_checks:\n - name: rabbitmq\n  pattern:\n    port: 15672\n  conf:\n    rabbitmq_api_url: http://localhost:15672/api/\n    rabbitmq_user: myuser\n    rabbitmq_pass: mypassword\n    queues:\n      - MyQueue1\n      - MyQueue2\n"
Have more questions? Submit a request