Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elk service to see output and dashboard metrics #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS*
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,55 @@ docker \
-e "ELASTICSEARCH_USER=$ES_USERNAME" \
-e "ELASTICSEARCH_PASSWORD=$ES_PASSWORD" \
basi/grafana


docker \
service create \
--name elk \
--network monitoring \
--label com.docker.stack.namespace=monitoring \
--container-label com.docker.stack.namespace=monitoring \
--publish 5601:5601 \
--publish 9200:9200 \
--publish 5044:5044 \
sebp/elk
```

Once everyting is running you just need to connect to grafana and import the [Docker Swarm & Container Overview](https://grafana.net/dashboards/609)

In case you don't have an Elasticsearch instance with logs and errors you could provide an invalid configuration. But I suggest you to have it correctly configured to get all the dashboard offers.

You can use the provided `docker-compose.yml` file as an example. You can deploy the full stack with the command:
You can use the provided `docker-compose.yml` file as an example. You can deploy the full stack with the command

If you get error `failed to find usable hardware address...` on the elasticsearch container, then most likely this can be the fix

`sudo sysctl -w vm.max_map_count=262144` `

```bash
docker stack deploy --compose-file docker-compose.yml monitoring
```
```

### Add Data Sources

Navigate to graphana UI using http://<docker-host/docker-swarm-host>:3000 (Default creds: admin/admin)

- Add prometheus as data source

![prometheus](./images/prometheus-datasource.png)

- Add elasticsearch as data source

![elasticsearch](./images/elasticsearch-datasource.png)

- Import [Docker Swarm & Container Overview](https://grafana.net/dashboards/609)

![Import Dashboard](./images/import-dashboard.png)

- Dashboard looks like this

![Dashboard](./images/dashboard.png)



### Docker Engine Metrics
In case you have activated the metrics endpoint in your docker swarm cluster you could import the [Docker Engine Metrics](https://grafana.net/dashboards/1229) dashboard as well, which offers complementary data about the docker daemon itself.
Expand Down
201 changes: 201 additions & 0 deletions docker-compose-alternate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
version: "3"

networks:
monitoring:

volumes:
prometheus:
driver: rexray

services:
cadvisor:
image: google/cadvisor:${CADVISOR_VERSION:-v0.24.1}
networks:
- monitoring
volumes:
- /var/run/docker.sock:/var/run/docker.sock,readonly
- /:/rootfs
- /var/run:/var/run
- /sys:/sys
- /var/lib/docker/:/var/lib/docker
deploy:
mode: global
resources:
limits:
cpus: '0.10'
memory: 128M
reservations:
cpus: '0.10'
memory: 64M

node-exporter:
image: basi/node-exporter:${NODE_EXPORTER_VERSION:-v1.13.0}
networks:
- monitoring
volumes:
- /proc:/host/proc
- /sys:/host/sys
- /:/rootfs
- /etc/hostname:/etc/host_hostname
environment:
HOST_HOSTNAME: /etc/host_hostname
command: -collector.procfs "/host/proc" -collector.sysfs /host/sys -collector.textfile.directory /etc/node-exporter/ -collectors.enabled 'conntrack,diskstats,entropy,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,stat,textfile,time,vmstat,ipvs' # -collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
deploy:
mode: global
resources:
limits:
cpus: '0.10'
memory: 32M
reservations:
cpus: '0.10'
memory: 16M

docker-exporter:
image: basi/socat:${DOCKER_EXPORTER_VERSION:-v0.1.0}
networks:
- monitoring
deploy:
mode: global
resources:
limits:
cpus: '0.05'
memory: 6M
reservations:
cpus: '0.05'
memory: 4M

alertmanager:
image: basi/alertmanager:${ALERTMANAGER_VERSION:-v0.1.0}
networks:
- monitoring
# - logging
ports:
- "9093:9093"
environment:
SLACK_API: ${SLACK_API:-YOURTOKENGOESHERE}
LOGSTASH_URL: http://logstash:8080/
command: -config.file=/etc/alertmanager/config.yml
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: '0.01'
memory: 32M
reservations:
cpus: '0.01'
memory: 16M

prometheus:
image: basi/prometheus-swarm:${PROMETHEUS_SWARM_VERSION:-v0.4.1}
ports:
- "9090"
networks:
- monitoring
command: -config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -web.console.libraries=/etc/prometheus/console_libraries -web.console.templates=/etc/prometheus/consoles -alertmanager.url=http://alertmanager:9093
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: '0.50'
memory: 1024M
reservations:
cpus: '0.50'
memory: 128M

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.2.2
ports:
- "9200:9200"
- "9300:9300"
environment:
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
# disable X-Pack
# see https://www.elastic.co/guide/en/x-pack/current/xpack-settings.html
# https://www.elastic.co/guide/en/x-pack/current/installing-xpack.html#xpack-enabling
xpack.security.enabled: "false"
xpack.monitoring.enabled: "false"
xpack.graph.enabled: "false"
xpack.watcher.enabled: "false"
networks:
- monitoring
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: '0.50'
memory: 2048M
reservations:
cpus: '0.50'
memory: 512M

logstash:
image: docker.elastic.co/logstash/logstash:5.2.2
volumes:
- ./logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml
- ./logstash/pipeline:/usr/share/logstash/pipeline
ports:
- "5000:5000"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
networks:
- monitoring
depends_on:
- elasticsearch
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: '0.50'
memory: 1024M
reservations:
cpus: '0.50'
memory: 128M

kibana:
image: docker.elastic.co/kibana/kibana:5.2.2
volumes:
- ./kibana/config/:/usr/share/kibana/config
ports:
- "5601:5601"
networks:
- monitoring
depends_on:
- elasticsearch
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: '0.50'
memory: 256M
reservations:
cpus: '0.50'
memory: 128M

grafana:
image: basi/grafana:${GRAFANA_VERSION:-v4.1.1}
ports:
- "3000:3000"
networks:
- monitoring
environment:
GF_SERVER_ROOT_URL: http://grafana.${CLUSTER_DOMAIN}
GF_SECURITY_ADMIN_PASSWORD: $GF_PASSWORD
PROMETHEUS_ENDPOINT: http://prometheus:9090
ELASTICSEARCH_ENDPOINT: $ES_ADDRESS
ELASTICSEARCH_USER: $ES_USERNAME
ELASTICSEARCH_PASSWORD: $ES_PASSWORD
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: '0.50'
memory: 64M
reservations:
cpus: '0.50'
memory: 32M
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,14 @@ services:
reservations:
cpus: '0.50'
memory: 32M
elk:
image: sebp/elk
ports:
- "5601:5601"
- "9200:9200"
- "5044:5044"
networks:
- monitoring
deploy:
mode: replicated
replicas: 1
Loading