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.



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.


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

  scrape_interval: 10s
  • GLOBAL__EXTERNAL_LABELS=cluster=swarm
    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:

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

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


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.

Scrape Secret Configuration

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.

Scrape Label Configuration

When using a version of Docker Flow Swarm Listener, DFSL, newer than 18.02.06-31, you can configure DFSL to send node node hostnames to Docker Flow Monitor, DFM. This can be done by setting DF_INCLUDE_NODE_IP_INFO to true in the DFSL environment. DFM will automatically display the node hostnames as a label for each prometheus target. The DF_SCRAPE_TARGET_LABELS env variable allows for additional labels to be displayed. For example, if a service has env variables com.df.env=prod and com.df.domain=frontend, you can set DF_SCRAPE_TARGET_LABELS=env,domain in DFM to display the prod and frontend labels in prometheus.