Contents
Metricbeat-ELK-Grafana is one Compose file, three small config folders and a Grafana dashboard. The README calls it a minimal local stack: Metricbeat sends host metrics to Logstash, Logstash writes them to Elasticsearch, and Grafana reads them back.
The quickest way to understand a pipeline like this is to follow one value through it. I picked memory usage, the field system.memory.used.pct behind the Memory Usage panel, and traced it through the files one hop at a time. Along the way I note what I would change before trusting the stack with anything real.
Hop one: Metricbeat samples it every ten seconds
# metricbeat/modules.d/system.yml
- module: system
metricsets:
- cpu
- memory
- network
- process
- process_summary
- filesystem
period: 10s
processes: ['.*']
enabled: truememory is one of six metricsets, and all of them run every 10 seconds. The processes regex matches every process on the machine, so the process metricset reports each one on every cycle. The output side lives in metricbeat.yml:
# metricbeat/metricbeat.yml
output.logstash:
hosts: ["logstash:5044"]
processors:
- add_host_metadata: ~
- add_cloud_metadata: ~logstash is the Compose service name, so no IP address appears anywhere. The two processors attach host details, and cloud details when there are any, to each event before it leaves.
Hop two: Logstash passes it through
input {
beats {
port => 5044
}
}
filter {
# minimal parsing; keep as-is for Metricbeat
}
output {
elasticsearch {
hosts => ["http://elasticsearch:9200"]
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
}
stdout { codec => rubydebug }
}The filter block is empty, so the event goes through untouched. The only decision is in the output: the index name is the beat name plus the date. For Metricbeat that is a daily index, metricbeat-YYYY.MM.dd. The stdout line prints every event to Logstash's log, which is useful for proving data flows and noisy after that.
Hop three: Elasticsearch stores it
Elasticsearch runs as a single node with a 512 MB heap and a named volume, esdata. To check that the metric arrived, the import guide suggests listing the indices:
curl localhost:9200/_cat/indicesNothing in the repo loads Metricbeat's index template. The README lists template setup as a next step. Kibana is in the stack and metricbeat.yml has a setup.kibana block, but the Compose command never runs metricbeat setup. So Elasticsearch guesses the field types, and the dashboard is written for that: its two terms panels query system.filesystem.mount_point.keyword and process.name.keyword, the sub-fields dynamic mapping creates for strings.
Hop four: Grafana finds it on startup
# grafana/provisioning/datasources/datasource.yml
datasources:
- name: Elasticsearch
type: elasticsearch
url: http://elasticsearch:9200
isDefault: true
jsonData:
timeField: "@timestamp"
esVersion: 7A second file, provisioning/dashboards/dashboard.yml, tells Grafana to scan /var/lib/grafana/dashboards every ten seconds, and Compose mounts ./grafana/dashboards at that path. The dashboard JSON is therefore loaded on startup, which makes the manual import steps in DASHBOARD_IMPORT_GUIDE.md look redundant.
The Memory Usage panel is a query against metricbeat-*: the average of system.memory.used.pct, grouped by a date histogram on @timestamp. That is the whole journey.
What I would change first
- Turn security on. Elasticsearch and Kibana both set
xpack.security.enabled=false, ports 9200 and 5601 are published, and Grafana's admin password isadminin both the Compose file and the import guide. Enable security, move secrets out of the file and publish ports on127.0.0.1only. - Make the versions agree. Every image is pinned, which is good. They disagree, though: Elasticsearch, Kibana and Metricbeat are 8.4.1, Logstash is 7.7.0, the README says 7.17 for all four, and the datasource says
esVersion: 7. - Cap memory. Only Elasticsearch has a heap setting. No service has a container memory limit, and Logstash and Kibana have no heap setting either.
- Point Metricbeat at the host. Compose mounts
/proc,/sys/fs/cgroupand/under/hostfs, but nothing in the config mentions/hostfs. The process and filesystem panels may describe the container, not the host. - Drop the debug output. Remove the
stdoutline once data flows. Nothing expires old daily indices, and the README's stop command,docker-compose down -v, deletes the whole data volume. - Check two panels. CPU Usage has its only query marked
"hide": true, and the CPU and load panels hard-code the datasource UIDP31C819B24CF3C3C7, whiledatasource.ymlnever sets auid.
Where this setup stops
For watching one machine on a laptop, this is enough. Logstash adds a moving part with no job here: with an empty filter, Metricbeat could write to Elasticsearch directly. It earns its place only when you need to parse or route events, and the filter block is where that work would go. Past that point the list above is the minimum, and I would add a retention policy before the disk fills.
Found this useful? Share it with your team.