Git Product home page Git Product logo

prometheus-auto-discovery's Introduction

prometheus-auto-discovery

Prometheus - Auto discover nodes using consul.

A configration solution for Docker hosts and containers with Prometheus, Consul and NodeExporter.

Installation

Clone this repository on your host, cd into prometheus-auto-discovery directory and ./bootstrap :

git clone https://github.com/maddygoround/prometheus-auto-discovery
cd prometheus-auto-discovery
./bootstrap.sh

Prerequisites:

  • Docker Compose >= 1.29

Containers:

  • Prometheus (metrics database) http://<host-ip>:9090
  • NodeExporter (host metrics collector)
  • Consul-server (containers metrics collector) http://<host-ip>:8500

Once promethes and consul-server containers are up, you can direct to cd nodes and start the node containers which contains ndoe_expoter and consul agent.

cd nodes
docker-compose up 

Consul agent will connect to the consul server. promethes will read the list of nodes from the consul server and pull the metrics from each one of the nodes.

In case you want to deploy multiple nodes

cd nodes
docker-compose up --scale node-exporter=3

How does it works

The ./bootstrap.sh deploys promethes and consul server agent. prometheus takes the confirgration from promethes.yml file. prometheus.yml is configured to read all the host machine from consul-server's endpoint based on the tag of the host registerd with consul

prometheus.yml

global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']

  - job_name: 'consul'
    consul_sd_configs:
      - server: 'consul:8500'
    relabel_configs:
      - source_labels: [__meta_consul_tags]
        regex: .*,prometheus,.*
        action: keep
      - source_labels: [__meta_consul_service]
        target_label: job

The docker-compose within the ./nodes folder deploys the a container which contains node expoter and consul client agent.

consul clinet agent register themself with consul-server. To make this happen consul-server and consul-client container (which also contains node expoter) needs to share the same docker network.

Prometheus, consul-server and node expoter all share the same doccker network called "promnet"

Authors

License

MIT License

prometheus-auto-discovery's People

Contributors

maddygoround avatar

Watchers

 avatar  avatar

Forkers

micabe

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.