banner
 Sayyiku

Sayyiku

Chaos is a ladder
telegram
twitter

Deploy Prometheus Node Exporter Grafana and cAdvisor with Docker (2023)

image

image

Docker Compose File#

git clone https://github.com/Sayyiku/DataEye.git
mkdir -p promgrafnode/prometheus
mkdir -p promgrafnode/grafana/provisioning
touch promgrafnode/docker-compose.yml
touch promgrafnode/prometheus/prometheus.yml

docker-compose up -d

image

Deploying Node Exporter on the Target Host#

docker run -d -p 9100:9100 \
  -v "/root/docker/node-exporter/proc:/host/proc:ro" \
  -v "/root/docker/node-exporter/sys:/host/sys:ro" \
  -v "/root/docker/node-exporter/:/rootfs:ro" \
  --net="host" \
  --name node-exporter \
  prom/node-exporter

prometheus.yml#

global:
  scrape_interval: 1m

scrape_configs:
  - job_name: "prometheus"
    scrape_interval: 1m
    static_configs:
    - targets: ["localhost:9090"]

  - job_name: "node"
    static_configs:
    - targets: ["node-exporter:9100"]

  - job_name: "cadvisor"
    scrape_interval: 5s
    static_configs:
    - targets: ["your ip:8081"]

  - job_name: "AWS-SG"
    scrape_interval: 5s
    static_configs:
    - targets: ["your ip:9100"]

  - job_name: "Spaceberg-20T"
    scrape_interval: 5s
    static_configs:
    - targets: ["your ip:9100"]

Prometheus and Node Exporter Architecture#

Prometheus and Node Exporter work together. You can run Prometheus and Node Exporter on the same machine. However, you may want to run Node Exporter on many other remote Linux hosts.

After installing Node Exporter, you can reference the Node Exporter instances and all the nodes you want to monitor in the Prometheus configuration file. These may be Linux virtual machines running in your environment.

Prometheus collects data from the Node Exporter HTTP endpoint located on the remote Prometheus instance. You can enable additional collectors and collect the desired metrics and access them with Prometheus.

The Prometheus UI allows you to view service discovery and test the targets added to the Prometheus configuration. In the Prometheus configuration file, you define the endpoints and ports to connect the Prometheus server to the configured Node Exporter instances. Similarly, you can verify your connections in the Prometheus user interface.

Configuring Grafana to Monitor URLs with Prometheus Server#

After the containers are started and running, you must add the Prometheus data source to Grafana. Open Grafana and click on the settings gear in the bottom left corner. Then click on Prometheus and configure Grafana with the URL of the Prometheus server.

image

Add data source

image

image

Add the IP and port of the Prometheus server URL to extract metrics in Prometheus format.

image

Visualizing Prometheus Node Exporter Metrics with Grafana Dashboards#

On Grafana.com, download an ID or JSON template to create a quick and easy dashboard as it eliminates the heavy lifting in manual dashboard creation.

image

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.