Blog Post

Tech Talk
3 MIN READ

Docker Collector Deployment Improvements

edward_garza's avatar
12 months ago

This post will provide additional configurations not covered in the LogicMonitor “Installing the Collector in a Container” support guide.

Docker specific documentation can be found here https://docs.docker.com/engine.

This post will not cover the Docker specific configurations such as creating a network.

Support Guide Docker Container Collector Installation

If you follow the support guide linked above to deploy a collector in a Docker container, you will be able to monitor resources using the Docker collector.

However, if you have deployed a collector in a Docker container, and only followed the support guide linked above, you may have noticed the following items:

  1. The collector container is deployed to the default bridge network and this is not recommended for production use cases.
  2. The collector container by default is not set to perform any restarts.
  3. The collector container is not assigned an IP upon startup which will impact how LogicMonitor identifies the collector container resource if restarted with a different IP.
  4. The collector container is not provisioned to handle ingestion of syslog and netflow data.
  5. When viewing the collector in the “Collectors” tab, the collector is not linked to a resource.
  6. The “Device Name” of the collector is the container ID and a meaningful container hostname would be preferred.
  7. The collector is not listed anywhere in the Resource Tree, including “Devices by Type/Collectors”.
  8. If you look at the “Collectors” dashboard, the collector container metrics are not present.

Screenshot Showing the Docker Collector Not Linked to a Resource

Screenshot Showing Docker Collector Nowhere to be Found in Resource Tree

Screenshot Showing Missing Docker Collector Metrics in “Collectors” Dashboard

Improvements to the Docker Container Collector Installation

The improvements for the items listed above are simple to implement.

Here’s an existing example of a Docker command to deploy the collector in a Docker container that was created using only the support guide linked above.

### Example Docker Command Built Using Support Guide

sudo docker run --name 'docker_collector' -d \

-e account='YOUR_PORTAL_NAME' \

-e access_id='YOUR_ACCESS_ID' \

-e access_key='YOUR_ACCESS_KEY' \

-e collector_size='medium' \

-e description='Docker Collector' \

logicmonitor/collector:latest

Items 1, 2, 3, 4, and 6 in the list above are handled with additional Docker flags that should be added to the Docker example built using the support guide linked above.

Let’s improve on the support guide example to resolve items 1, 2, 3, 4, and 6.

Item 1 requires defining a network for the Docker container.

This post assumes you already have a Docker network defined that you will attach the container to. The code example uses a network name of “logicmonitor”.

Item 2 requires defining a Docker container restart policy.

Docker has different options for the restart policy so adjust the code example to suit your environmental needs.

Item 3 requires defining an IP for the Docker container.

This post assumes you already have a Docker network defined where you will assign the container an IP valid for the network defined in your environment. The code example uses an IP of “172.20.0.7”.

Item 4 requires defining port forwarding between the Docker host and the Docker container.

The code example is using the default ports for syslog and netflow. Adjust to match the ports used in your environment.

Item 6 requires defining a meaningful hostname for the Docker container.

Here are the improvements added to the support guide code example to resolve items 1, 2, 3, 4, and 6.
 

### Improved to Define Container Network, Restart Policy, IP, 

### Port Forwarding, and hostname

sudo docker run --name 'docker_collector' -d \

-e account='YOUR_PORTAL_NAME' \

-e access_id='YOUR_ACCESS_ID' \

-e access_key='YOUR_ACCESS_KEY' \

-e collector_size='medium' \

-e description='Docker Collector' \

--network logicmonitor \            ## Item 1

--restart always \                  ## Item 2

--ip 172.20.0.7 \                   ## Item 3

-p 514:514/udp \                    ## Item 4: syslog

-p 2055:2055/udp \                  ## Item 4: netflow

--hostname 'docker_collector' \     ## Item 6

logicmonitor/collector:latest

After you have deployed the collector with the additional Docker configurations to handle items 1, 2, 3, 4, and 6, items 5, 7, and 8 are resolved by adding the Docker container as a monitored resource in the LogicMonitor portal.

Use the IP of the Docker container when adding the collector into monitoring.

Adding the Docker container as a monitored resource will:

  • Resolve item 5 by linking the Collector “Device Name” to the monitored Docker container resource
  • Resolve item 7 by adding the Docker container to the Resource Tree and “Devices by Type/Collectors” group
  • Resolve item 8 as the “Collector” datasources will be applied to the monitored Docker container and the metrics will be displayed in the Collectors dashboard

Screenshot Showing the Docker Collector Linked to a Resource

Screenshot Showing Docker Collector in Resource Tree

Screenshot Showing Docker Collector Metrics in “Collectors” Dashboard

Published 12 months ago
Version 1.0

1 Comment

  • If you create the docker network as a macvlan type network, the container’s interface will be directly connected to the same switch your host is plugged into. Essentially making it the same as a physical linux machine plugged directly into your network. Pretty good primer on docker networking (I swear that guy is not me): 


    Host network type would also work well since it would make the collector’s container have the same IP address and mac as the host machine, which is the closest analog to just running it on the host.