Docker Swarm logging

This guide describes how you can set up log forwarding from your Docker Swarm environments to Apica Ascent. To forward logs from Docker Swarm to Apica Ascent, do the following.

Deploy fluent-bit container

Create the following files:

parsers.conf

[PARSER]
    Name   json
    Format json

fluent-bit.conf

Update the Apica Ascent host and Authorization Header in the file. The token can be obtained from Apica Ascent UI as described here.

[SERVICE]
    Flush        1
    Parsers_File /fluent-bit/etc/parsers.conf
    Log_Level    error

# collect docker logs using fluend logging driver
[INPUT]
    Name forward
    Listen 0.0.0.0
    port 24224

# try parsing log as json and lift its keys to the first-level
[FILTER]
    Name parser
    Match *
    Parser json
    Key_Name log
    Reserve_Data On

[OUTPUT]
    name     http
    match    *
    host     <Apica-Ascent-endpoint>
    port     443
    URI      /v1/json_batch
    Format   json
    tls      on
    tls.verify  off
    net.keepalive  off
    compress      gzip
    Header Authorization Bearer <Token>

docker-compose.fluent.yaml

Ensure that the Fluent Bit Docker Compose uses the parsers.conf and fluent-bit.conf which we prepared in the previous step.

Run the following command to get fluent-bit running in your Docker Swarm cluster.

Ensure that the fluent-bit container is running in the cluster.

Update services to add logging driver

Add the global logging configuration to your docker-compose files as shown below

Update the services in docker-compose files to add logging configuration and environment variables. The Namespaceand AppName set in the service definition defines how the logs from the service are indexed in Apica Ascent.

Examples

If your default Docker Compose file looks like this:

After you’ve added the logging configuration, your Docker Compose file should look like this.

Run the following command to run the container.

Your Docker Swarm logs will now be ingested into Apica Ascent.

Last updated

Was this helpful?