Using environment variables or secrets for configuration
Option 1: Using docker Labels
When creating your Docker image you can add a label to tell the CoScale agent how to monitor this image when it’s detected. To make this work in an environment where sensitive data is stored in a secrets, you can tell the agent to read usernames and passwords from environment variables.
In this example we have created an image with RabbitMQ running on it, we added a Docker label to automatically run the RabbitMQ plugin on the container once it starts. We tell the agent to get the password from an environment variable $RABBIT_MQ_PASSWORD by defining
$RABBIT_MQ_PASSWORD in the Docker LABEL.
In this example we have created an image with RabbitMQ running on it, we added a Docker label to automatically run the RabbitMQ plugin on the container once it starts. We tell the agent to get the password from a secret on the filesystem located at
/run/secrets/rabbitmq_password by defining
$/run/secrets/rabbitmq_password in the Docker LABEL.
Option 2: Using a packaged agent
Our agent can get its configuration values for plugins from environment values configured on the server. This allows you to use the same agent for a lot of servers without having to generate a new agent for different configuration setups. An example where this might be used is with database plugin where the status user password isn’t the same on all machines.
1. Create environment file
/etc/default/coscale-agent and add the following content
2. Configure agent
In the plugin configuration you set the configuration settings to the variable names you created. In this example I’m configuring the MySQL database plugin with custom variables.
3. Restart the Agent
Restart the agent, afterwards the config will be read from file.