edit

Configuring Docker Flow Monitor

Docker Flow Monitor can be configured through Docker environment variables and/or by creating a new image based on vfarcic/docker-flow-monitor.

Startup Arguments

Environment variables prefixed will ARG_ are used instead Prometheus startup arguments.

The formatting rules for the ARG variables are as follows:

  1. Variable name has to be prefixed with ARG_.
  2. Underscores (_) will be replaced with dots (.).
  3. Capital letters will be transformed to lower case.

For example, if environment variables ARG_WEB_ROUTE-PREFIX=/monitor and ARG_WEB_EXTERNAL-URL=http://localhost/monitor are defined, Prometheus will be started with the arguments web.route-prefix=/monitor and web.external-url=http://localhost/monitor. The result would be Prometheus initialization equivalent to the command that follows.

prometheus --web.route-prefix=/monitor --web.external-url=http://localhost/monitor

ARG variables defined by default are as follows.

ARG_CONFIG_FILE=/etc/prometheus/prometheus.yml
ARG_STORAGE_TSDB_PATH=/prometheus
ARG_WEB_CONSOLE_LIBRARIES=/usr/share/prometheus/console_libraries
ARG_WEB_CONSOLE_TEMPLATES=/usr/share/prometheus/consoles

Configuration

Environment variables prefixed with GLOBAL__, ALERTING__, SCRAPE_CONFIGS__, REMOTE_WRITE__, and REMOTE_READ__ are used to configure Prometheus.

The formatting rules for these variable are as follows:

  1. Environment keys will be transformed to lowercase.
  2. Double underscore is used to go one level deeper in a yaml dictionary.
  3. A single underscore followed by a number indicates the position of an array.

Examples

The following are examples of using environmental variables to configure Prometheus. Pleaes consult the Prometheus configuration documentation for all configuration options.

  • GLOBAL__SCRAPE_INTERVAL=10s
global:
  scrape_interval: 10s
  • GLOBAL__EXTERNAL_LABELS=cluster=swarm
global:
  external_labels:
    cluster: swarm
    type: production

This is NOT GLOBAL__EXTERNAL_LABELS__CLUSTER=swarm because CLUSTER is not a standard Prometheus configuration. The external_labels option is a list of key values as shown in their documentation:

external_labels:
  [ <labelname>: <labelvalue> ... ]
  • REMOTE_WRITE_1__URL=http://first.acme.com/write, REMOTE_WRITE_1__REMOTE_TIMEOUT=10s, REMOTE_WRITE_2__URL=http://second.acme.com/write
remote_write:
- url: http://acme.com/write
  remote_timeout: 30s
- url: http://second.acme.com/write

Trailing numbers in the REMOTE_WRITE_1 and REMOTE_WRITE_2 prefixes dictates the position of the array of dictionaries.

  • REMOTE_WRITE_1__WRITE_RELABEL_CONFIGS_1__SOURCE_LABELS_1=label1
remote_write:
- write_relabel_configs:
  - source_labels: [label1]

Scrape Environment Configuration

It is possible to add servers that are not part of the Docker Swarm Cluster just adding the variables SCRAPE_PORT and SERVICE_NAME on the environment. The project is going to use the static_configs configuration.

SCRAPE_PORT_1=1234
SERVICE_NAME_1=myservice.acme.com
SCRAPE_PORT_2=1234
SERVICE_NAME_2=myservice2.acme.com

You can also add a service via api using the reconfigure entry point.

curl `[IP_OF_ONE_OF_SWARM_NODES]:8080/v1/docker-flow-monitor/reconfigure?scrapePort=[PORT]&serviceName=[IP_OR_DOMAIN]&scrapeType=static_configs

Please consult Prometheus Configuration for more information about the available options.

Scrapes

Additional scrapes can be added through files prefixed with scrape_. By default, all such files located in /run/secrets are automatically added to the scrape_configs section of the configuration. The directory can be changed by setting a different value to the environment variable CONFIGS_DIR.

The simplest way to add scrape configs is to use Docker secrets or configs.