MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Elastic Tutorials: Collects Docker metrics and logs using Elastic Agent

This Integration collects metrics and logs fromย Docker containers. The default data streams for metrics collection are:ย container,ย cpu,ย diskio,ย healthcheck,ย info,ย memoryย andย network. Theย imageย metricset is not enabled by default. Theย container_logsย data stream for containers’ logs collection is enabled by default.

Compatibility

The Docker module is currently tested on Linux and Mac with the community edition engine, versions 1.11 and 17.09.0-ce. It is not tested on Windows, but it should also work there.

Step 1 – Install Docker

Step 2 – Enable Integration

Elastic Browse integrations page with docker search finding the Docker integration
Elastic Add Docker integration form with metrics and logs enabled, Agent policy 2 selected

Step 3 – Work on Agent Configuration changes


$ cd /opt/Elastic/Agent
$ systemctl stop elastic-agent
# Replace the content of elastic-agent.yml which you recieved from Kibana.
$ vi elastic-agent.yml
$ systemctl restart elastic-agent
$ systemctl status elastic-agent
Code language: PHP (php)

Step 4 – Create docker containers

$  docker run -itd ubuntu
Docker ps output listing three running ubuntu containers

Step 5 – Verify Containers

Kibana Metrics Docker Overview dashboard showing 3 running containers with CPU and memory usage
Elastic Observability Metrics Explorer graphing container.memory.usage over the last 30 minutes

Running from within Docker


The docker Integration will try to connect to the docker socket, by default at unix:///var/run/docker.sock. If Elastic Agent is running inside docker, you'll need to mount the unix socket inside the container:

docker run -d \
  --name=metricbeat \
  --user=root \
  --volume="/var/run/docker.sock:/var/run/docker.sock:ro" \
  docker.elastic.co/beats/metricbeat:latest metricbeat -e \
  -E output.elasticsearch.hosts=["elasticsearch:9200"]

For log collection since the discovery of the containers happen automatically, again access to unix:///var/run/docker.sock will be needed so as Agent to be able to watch for Container events. In addition, access is required to the containers' logs files which by default follows the pattern of /var/lib/docker/containers/${docker.container.id}/*-json.log If Elastic Agent is running inside docker, you'll need to mount the logs' directory too inside the container:

docker run -d \
  --name=metricbeat \
  --user=root \
  --volume="/var/run/docker.sock:/var/run/docker.sock:ro" \
  --volume="/var/lib/docker/containers:/var/lib/docker/containers:ro" \
  docker.elastic.co/beats/metricbeat:latest metricbeat -e \
  -E output.elasticsearch.hosts=["elasticsearch:9200"]

In all cases make sure that Agent has the proper permissions to access these files.Code language: JavaScript (javascript)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

ELK Demo Tutorial

Demo Video Sure! Here’s a compelling promotional content piece that highlights both the Intermediate and Advanced ELK (Elasticsearch, Logstash, Kibana) training courses by Rajesh Kumar, available at…

Read More

How to deploy Elasticsearch, Fluentd and Kibana (EFK) in Kubernetes?

Logging Operator EFK(Elasticsearch, Fluentd, and Kibana) Logging Operator is an operator created in Golang to set up and manage EFK(Elasticsearch, Fluentd, and Kibana) cluster inside Kubernetes and…

Read More

What is ELK Stack and use cases of ELK Stack?

What is ELK Stack? The ELK Stack, also known as the Elasticsearch, Logstash, and Kibana Stack, is a powerful set of open-source tools used for log and…

Read More

Top 10 Log Management Tools: Features, Pros, Cons & Comparison

Introduction Log Management Tools are specialized platforms designed to collect, store, search, analyze, and visualize logs generated by applications, servers, containers, cloud services, and network devices. Logs…

Read More

Why Your Games Run Clearly with the ELK Stack

Learn how ELK Stack tools like Logstash, Elasticsearch, and Kibana help developers detect and resolve gameplay lags and freezes across all platforms. How the ELK Stack Helps…

Read More

How to install kibana and configure with Elasticsearch

Download & Extract kibana 8.x Configure kibana 8.x Download, Extract, Install and Configure kibana 9.x vi config/kibana.yml ./bin/kibana –allow-root Provide Enrollment Kye of ElasticSearch Login to Kibana…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x