Skip to main content

Docker

A Docker container for the ElastiFlow Unified Flow Collector is available on Docker Hub. docker-compose is a good way to run the container. It allows for the various environment variables, used to configure the collector, to be easily managed in one place without having to enter them on the command line.

docker-compose.yml#

The following docker-compose.yml file provides an example with common settings that will likely need to be configured to process flow records and send them to Elasticsearch.

version: '3'
services:
# ElastiFlow Unified Flow Collector
flow-collector:
image: elastiflow/flow-collector:5.1.1
container_name: flow-collector
restart: 'unless-stopped'
network_mode: 'host'
volumes:
- /etc/elastiflow:/etc/elastiflow
environment:
#EF_FLOW_ACCOUNT_ID: ''
#EF_FLOW_LICENSE_KEY: ''
#EF_FLOW_LICENSED_CORES:
#EF_FLOW_LOGGER_LEVEL: 'info'
#EF_FLOW_LOGGER_ENCODING: 'json'
#EF_FLOW_LOGGER_FILE_LOG_ENABLE: 'false'
#EF_FLOW_LOGGER_FILE_LOG_DIR: '/var/log/elastiflow/flowcoll'
#EF_FLOW_LOGGER_FILE_LOG_COUNT: 4
#EF_FLOW_LOGGER_FILE_LOG_INTERVAL: 'daily'
#EF_FLOW_LOGGER_FILE_LOG_SIZE: '100MB'
#EF_FLOW_SERVER_UDP_IP: '0.0.0.0'
#EF_FLOW_SERVER_UDP_PORT: 9995
#EF_FLOW_SERVER_UDP_PACKET_STREAM_MAX_SIZE:
#EF_FLOW_SERVER_UDP_READ_BUFFER_MAX_SIZE: 33554432
#EF_FLOW_DECODER_SETTINGS_PATH: '/etc/elastiflow'
#EF_FLOW_DECODER_IPFIX_ENABLE: 'true'
#EF_FLOW_DECODER_NETFLOW5_ENABLE: 'true'
#EF_FLOW_DECODER_NETFLOW9_ENABLE: 'true'
#EF_FLOW_DECODER_SFLOW5_ENABLE: 'true'
#EF_FLOW_DECODER_SFLOW_FLOWS_ENABLE: 'true'
#EF_FLOW_DECODER_SFLOW_FLOWS_KEEP_SAMPLES: 'false'
#EF_FLOW_DECODER_SFLOW_COUNTERS_ENABLE: 'true'
#EF_FLOW_DECODER_TRANSLATE_KEEP_IDS: 'default'
#EF_FLOW_DECODER_ENRICH_DNS_ENABLE: 'false'
#EF_FLOW_DECODER_ENRICH_DNS_CACHE_SIZE: 524288
#EF_FLOW_DECODER_ENRICH_DNS_RESOLVE_EXPORTER: 'true'
#EF_FLOW_DECODER_ENRICH_DNS_RESOLVE_PRIVATE: 'true'
#EF_FLOW_DECODER_ENRICH_DNS_RESOLVE_PUBLIC: 'true'
#EF_FLOW_DECODER_ENRICH_DNS_USERDEF_ENABLE: 'false'
#EF_FLOW_DECODER_ENRICH_DNS_USERDEF_PATH: 'settings/hostnames_user_defined.yml'
#EF_FLOW_DECODER_ENRICH_NETIF_GET_ATTRS: 'true'
#EF_FLOW_DECODER_ENRICH_NETIF_CACHE_SIZE: 262144
#EF_FLOW_DECODER_ENRICH_SNMP_ENABLE: 'false'
#EF_FLOW_DECODER_ENRICH_SNMP_PORT: 161
#EF_FLOW_DECODER_ENRICH_SNMP_VERSION: 2
#EF_FLOW_DECODER_ENRICH_SNMP_COMMUNITY: 'public'
#EF_FLOW_DECODER_ENRICH_SNMP_TIMEOUT: 2
#EF_FLOW_DECODER_ENRICH_SNMP_RETRIES: 1
#EF_FLOW_DECODER_ENRICH_APP_CACHE_SIZE: 262144
#EF_FLOW_DECODER_ENRICH_APP_USERDEF_ENABLE: 'false'
#EF_FLOW_DECODER_ENRICH_APP_USERDEF_PRIVATE: 'true'
#EF_FLOW_DECODER_ENRICH_APP_USERDEF_PUBLIC: 'true'
#EF_FLOW_DECODER_ENRICH_APP_USERDEF_PATH: 'settings/apps_user_defined.yml'
#EF_FLOW_DECODER_ENRICH_ASN_PREF: 'lookup'
#EF_FLOW_DECODER_ENRICH_RISKIQ_ASN_ENABLE: 'false'
#EF_FLOW_DECODER_ENRICH_RISKIQ_ASN_ENDPOINT: 'https://api.passivetotal.org/v2/netflow/as/download'
#EF_FLOW_DECODER_ENRICH_RISKIQ_ASN_REFRESH_INTERVAL: 1440
#EF_FLOW_DECODER_ENRICH_RISKIQ_THREAT_ENABLE: 'false'
#EF_FLOW_DECODER_ENRICH_RISKIQ_THREAT_ENDPOINT: 'https://api.passivetotal.org/v2/netflow/blocklist/download'
#EF_FLOW_DECODER_ENRICH_RISKIQ_THREAT_REFRESH_INTERVAL: 1440
#EF_FLOW_DECODER_ENRICH_RISKIQ_API_USER: ''
#EF_FLOW_DECODER_ENRICH_RISKIQ_API_KEY: ''
#EF_FLOW_DECODER_ENRICH_RISKIQ_API_TIMEOUT: 30
#EF_FLOW_DECODER_ENRICH_MAXMIND_ASN_ENABLE: 'false'
#EF_FLOW_DECODER_ENRICH_MAXMIND_ASN_CACHE_SIZE: 262144
#EF_FLOW_DECODER_ENRICH_MAXMIND_ASN_PATH: 'maxmind/GeoLite2-ASN.mmdb'
#EF_FLOW_DECODER_ENRICH_MAXMIND_GEOIP_ENABLE: 'false'
#EF_FLOW_DECODER_ENRICH_MAXMIND_GEOIP_CACHE_SIZE: 262144
#EF_FLOW_DECODER_ENRICH_MAXMIND_GEOIP_PATH: 'maxmind/GeoLite2-City.mmdb'
#EF_FLOW_DECODER_ENRICH_MAXMIND_GEOIP_VALUES: 'city,country,country_code,location,timezone'
#EF_FLOW_DECODER_ENRICH_MAXMIND_GEOIP_LANG: 'en'
#EF_FLOW_DECODER_ENRICH_SAMPLERATE_CACHE_SIZE: 32768
#EF_FLOW_DECODER_ENRICH_SAMPLERATE_USERDEF_ENABLE: 'false'
#EF_FLOW_DECODER_ENRICH_SAMPLERATE_USERDEF_PATH: 'settings/sample_rate.yml'
#EF_FLOW_DECODER_ENRICH_COMMUNITYID_ENABLE: 'true'
#EF_FLOW_DECODER_ENRICH_COMMUNITYID_SEED: 0
#EF_FLOW_DECODER_ENRICH_CONVERSATIONID_ENABLE: 'true'
#EF_FLOW_DECODER_ENRICH_CONVERSATIONID_SEED: 0
#EF_FLOW_DECODER_ENRICH_JOIN_ASN: 'true'
#EF_FLOW_DECODER_ENRICH_JOIN_GEOIP: 'true'
#EF_FLOW_DECODER_ENRICH_JOIN_SEC: 'true'
#EF_FLOW_DECODER_ENRICH_JOIN_NETATTR: 'true'
#EF_FLOW_DECODER_DURATION_PRECISION: 'ms'
#EF_FLOW_DECODER_TIMESTAMP_PRECISION: 'ms'
#EF_FLOW_DECODER_PERCENT_NORM: 100
#EF_FLOW_DECODER_ENRICH_EXPAND_CLISRV: 'true'
#EF_FLOW_DECODER_ENRICH_KEEP_CPU_TICKS: 'false'
#EF_FLOW_RECORD_STREAM_MAX_SIZE:
# stdout
#EF_FLOW_OUTPUT_STDOUT_ENABLE: 'false'
#EF_FLOW_OUTPUT_STDOUT_FORMAT: 'json_pretty'
# monitor
#EF_FLOW_OUTPUT_MONITOR_ENABLE: 'false'
#EF_FLOW_OUTPUT_MONITOR_INTERVAL: 300
# Elasticsearch
EF_FLOW_OUTPUT_ELASTICSEARCH_ENABLE: 'true'
#EF_FLOW_OUTPUT_ELASTICSEARCH_ECS_ENABLE: 'false'
#EF_FLOW_OUTPUT_ELASTICSEARCH_BATCH_DEADLINE: 2000
#EF_FLOW_OUTPUT_ELASTICSEARCH_BATCH_MAX_BYTES: 8388608
#EF_FLOW_OUTPUT_ELASTICSEARCH_POOL_SIZE:
#EF_FLOW_OUTPUT_ELASTICSEARCH_TIMESTAMP_SOURCE: 'end'
#EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_PERIOD: 'daily'
#EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_SUFFIX: ''
#EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_ENABLE: 'true'
EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_OVERWRITE: 'true'
EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_SHARDS: 1
EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_REPLICAS: 0
#EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_REFRESH_INTERVAL: '10s'
#EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_CODEC: 'best_compression'
#EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_ILM_LIFECYCLE: ''
#EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_ILM_ROLLOVER_ALIAS: ''
#EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_ISM_POLICY: ''
#EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_PIPELINE_DEFAULT: '_none'
#EF_FLOW_OUTPUT_ELASTICSEARCH_INDEX_TEMPLATE_PIPELINE_FINAL: '_none'
# A comma separated list of Elasticsearch nodes to use. DO NOT include "http://" or "https://"
EF_FLOW_OUTPUT_ELASTICSEARCH_ADDRESSES: '127.0.0.1:9200'
EF_FLOW_OUTPUT_ELASTICSEARCH_USERNAME: 'elastic'
EF_FLOW_OUTPUT_ELASTICSEARCH_PASSWORD: 'changeme'
#EF_FLOW_OUTPUT_ELASTICSEARCH_CLOUD_ID: ''
#EF_FLOW_OUTPUT_ELASTICSEARCH_API_KEY: ''
#EF_FLOW_OUTPUT_ELASTICSEARCH_TLS_ENABLE: 'false'
#EF_FLOW_OUTPUT_ELASTICSEARCH_TLS_SKIP_VERIFICATION: 'false'
#EF_FLOW_OUTPUT_ELASTICSEARCH_TLS_CA_CERT_FILEPATH: '/etc/elastiflow/certs/ca/ca.crt'
#EF_FLOW_OUTPUT_ELASTICSEARCH_RETRY_ENABLE: 'true'
#EF_FLOW_OUTPUT_ELASTICSEARCH_RETRY_ON_TIMEOUT_ENABLE: 'true'
#EF_FLOW_OUTPUT_ELASTICSEARCH_MAX_RETRIES: 3
#EF_FLOW_OUTPUT_ELASTICSEARCH_RETRY_BACKOFF: 1000
# RiskIQ
#EF_FLOW_OUTPUT_RISKIQ_ENABLE: 'false'
#EF_FLOW_OUTPUT_RISKIQ_HOST: ''
#EF_FLOW_OUTPUT_RISKIQ_PORT:
#EF_FLOW_OUTPUT_RISKIQ_CUSTOMER_UUID: ''
#EF_FLOW_OUTPUT_RISKIQ_CUSTOMER_ENCRYPTION_KEY: ''
#EF_FLOW_OUTPUT_RISKIQ_POOL_SIZE:

image#

The name of the current released image is elastiflow/flow-collector:5.1.1.

restart#

restart is set to unless-stopped so that the collector will restart automatically if it fails for some reason.

network_mode#

There is a old issue with Docker that persists still, where an inbound packet's source IP address is not persisted across the Docker bridge interface. This is not an issue for sFlow as the exporter's IP is extracted from the agent_address in the sFlow header. However for Netflow and IPFIX the source IP from the IP header is all that is available to determine which device sent the records. The Docker bridge messes this up.

To work around this issue network_mode must be set to host.

important

On macOS Docker containers do not run natively on the operating system. They actually run in a behind the scenes linux VM. In the case host networking would be the network stack of the VM and not of macOS itself. This means the bridged mode networking must be used and the necessary port mapping defined. Because of the source IP issues mentioned above, you will not be able to do much on macOS other than basic testing.

volumes#

There are a few scenarios where it is necessary to make files on the host file system available to the collector.

In the example above, /etc/elastiflow on the host's filesystem is mapped into the same path within the container. After downloading the GeoLite2-City and GeoLite2-ASN maxmind databases from the Maxmind website, they can be placed at /etc/elastiflow/maxmind on the host's filesystem and will be able to be accessed by the collector within the container.

note

It is also possible to build a new container, adding additional files as needed. This may the best choice if running the container in a dynamically orchestrated environment (e.g. running in Kubernetes). However for an instance dedicated to a specific host, using bind mounted volumes can be very convenient.

environment variables#

The ElastiFlow Unified Flow Collector is configured using environment variables. The settings above provide an example configuration that represents the most likely settings to consider and modify when deploying the collector.

For a complete reference of all configuration options please refer to the Configuration Environment Variable Reference.

Running the Container#

After completing configuration of the collector in the docker-compose.yml file, you can start the container using one of the following commands...

From within the same path as the docker-compose.yml file:

docker-compose up -d

From a path different from the location of the docker-compose.yml file:

docker-compose -f /PATH/TO/docker-compose.yml up -d

To view the logs written by the container run:

docker logs -f NAME_OF_CONTAINER

To stop the container run:

docker-compose down

or:

docker-compose -f /PATH/TO/docker-compose.yml down