Skip to content

Commit

Permalink
Merge pull request #113 from CoScale/feature/COD-12104
Browse files Browse the repository at this point in the history
COD-12104: Add documentation for secrets and environment variables
  • Loading branch information
kidk authored Apr 20, 2018
2 parents 5a16665 + c6b5722 commit 1200bc1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion HOWTO
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Ex: `<a href="http://app.coscale.com" db-href="/alerts/manage/" class="js-dashbo

{% endhighlight %}

`xml` can be replaced with any language, full list available on http://rouge.jneen.net/
`xml` can be replaced with any language, full list available on https://github.com/jneen/rouge/wiki/List-of-supported-languages-and-lexers
2 changes: 1 addition & 1 deletion _docs_advanced/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ All data is stored in a cluster of PostgreSQL and Cassandra databases. Metric da

## Security & Firewall

By default, all CoScale agents communicate with the CoScale platform over a secured SSL connection, using the default port 443. The agent communicates with one host, api.coscale.com (37.187.86.75). CoScale only requires your firewall to allow outgoing connections to api.coscale.com on TCP port 443. No incoming connections are required.
By default, all CoScale agents communicate with the CoScale platform over a secured SSL connection, using the default port 443. The agent communicates with one host, api.coscale.com (46.105.51.99, 5.39.67.37, 178.33.227.57 and 176.31.230.12). CoScale only requires your firewall to allow outgoing connections to api.coscale.com on TCP port 443. No incoming connections are required.

All installed agent plugins are digitally signed by CoScale. This signature is verified when installing or updating plugins.

Expand Down
34 changes: 29 additions & 5 deletions _docs_agent/linux/environment-variables.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
---
layout: page
title: Environment variables configuration
title: Using environment variables or secrets for configuration
description: Configure the CoScale agent and plugins using environment variables.
---

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.
## 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.

{% include alert.html type="warning" text="At the moment we only support Linux." %}
### Example 1
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.

{% highlight bash %}
FROM rabbitmq:3.6

RUN rabbitmq-plugins enable rabbitmq_management

# Here we set USERNAME and PASSWWORD in the RabbitMQ configuration taken from environment variables
LABEL com.coscale.monitoring='[{"PluginType":"RABBITMQ","Configuration":{"HOSTNAME":["localhost"],"PORT":["15672"],"USERNAME":["$RABBIT_MQ_USERNAME"],"PASSWORD":["$RABBIT_MQ_PASSWORD"]}}]'
{% endhighlight %}

### Example 2
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.

## How to get started
{% highlight bash %}
FROM rabbitmq:3.6

RUN rabbitmq-plugins enable rabbitmq_management

# Here we set USERNAME and PASSWWORD in the RabbitMQ configuration taken from secrets on the disk
LABEL com.coscale.monitoring='[{"PluginType":"RABBITMQ","Configuration":{"HOSTNAME":["localhost"],"PORT":["15672"],"USERNAME":["$/run/secrets/rabbitmq_username"],"PASSWORD":["$/run/secrets/rabbitmq_password"]}}]'
{% endhighlight %}

## 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.

{% include alert.html type="warning" text="At the moment we only support Linux." %}
### 1. Create environment file
Create a `/etc/default/coscale-agent` and add the following content

Expand All @@ -22,7 +47,6 @@ export CS_MYSQL_PORT=3306
export CS_MYSQL_USER=user
export CS_MYSQL_PASSWORD=password
export CS_MYSQL_DATABASE=product

{% endhighlight %}

### 2. Configure agent
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1200bc1

Please sign in to comment.