Simple setup to monitor my machine using
node_exporter: Exposes my machine metrics at http://localhost:9100/metrics
prometheus: A storage for metrics.
It scrapes the metrics from endpoint /metrics at defined interval to get the current state of the metrics and
stores values in prometheus tsdb
grafana: Visual representation of metrics used for analysing and alerting. It is queried using PromQl.

setup

Install required binaries from here: https://prometheus.io/download/

Node exporter

Prometheus

  • Create a prometheus.yml to define where to scrape from and at what interval
    scrape_configs:
  #The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'local_prometheus'
    #Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s
    static_configs:
      - targets: ['127.0.0.1:9100']
  • start:
docker run -p 9090:9090 --net=host -d -v ~/k8s_terraform/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
  • Verify on browser http://localhost:9090
    Click on status -> targets and verify container connections and is up.

setup_prometheus

Grafana
Here is how you can monitor by exploring your system metrics.

  • start:
docker run -d -p 3000:3000 grafana/grafana-oss:latest

local_prometheus