Setup the Prometheus server for collecting metrics, Grafana for visualization and Node Exporter for monitoring the Ubuntu

0 votes
I need to setup the Prometheus server for collecting metrics, Grafana for visualization and Node Exporter for monitoring the Ubuntu 16.04 Linux host system. How do I achieve this?
Oct 23 in Docker by Hannah
• 16,420 points
44 views

1 answer to this question.

0 votes

You can use a docker-compose file similar to one the one I have added bellow. Have a look at it:

version: '3'
networks:
  monitor-net:
    driver: bridge
volumes:
    prometheus_data: {}
    grafana_data: {}
services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    volumes:
      - ./prometheus/:/etc/prometheus/
      - prometheus_data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/etc/prometheus/console_libraries'
      - '--web.console.templates=/etc/prometheus/consoles'
      - '--storage.tsdb.retention=200h'
      - '--web.enable-lifecycle'
    # restart: unless-stopped
    expose:
      - 9090
    ports:
      - "9090:9090"
    networks:
      - monitor-net
  nodeexporter:
    image: prom/node-exporter:latest
    container_name: nodeexporter
    user: root
    privileged: true
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($|/)'
    restart: unless-stopped
    expose:
      - 9100
    networks:
      - monitor-net
  grafana:
   image: grafana/grafana:latest
   container_name: grafana
   volumes:
     - grafana_data:/var/lib/grafana
     - ./grafana/datasources:/etc/grafana/datasources
     - ./grafana/dashboards:/etc/grafana/dashboards
     - ./grafana/setup.sh:/setup.sh
   entrypoint: /setup.sh
   environment:
     - GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
     - GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
     - GF_USERS_ALLOW_SIGN_UP=false
   restart: unless-stopped
   expose:
     - 3000
   ports:
     - 3000:3000
   networks:
     - monitor-net
answered Oct 23 by Eric

Related Questions In Docker

0 votes
1 answer
0 votes
1 answer
0 votes
4 answers

what is network namespace and how we can access network namespace for the container?

Hey @Ali, I'll just combine @Eric, @Jackie ...READ MORE

answered Dec 20, 2018 in Docker by Kalgi
• 42,410 points
577 views
0 votes
1 answer
0 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
1,050 views
0 votes
1 answer

Docker compose to bring up a Prometheus server

I think this docker-compose should be helpful. ...READ MORE

answered Oct 23 in Docker by Eric
142 views
0 votes
1 answer