Monitor Server using Prometheus and Grafana
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
- start: ./node_exporter
- verify: curl http://localhost:9100/metrics
Prometheus
- Create a prometheus.yml to define where to scrape from and at what intervalscrape_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:9090Click on status -> targets and verify container connections and is up.
Grafana
Here is how you can monitor by exploring your system metrics.
- start:
docker run -d -p 3000:3000 grafana/grafana-oss:latest
- Login to dashboard at http://localhost:3000.Add endpooint in data source i.e http://localhost:9090, because Prometheus and Grafana are running on the same server.