The previous article described how Node Exporter is used, which combines Prometheus and Grafana to collect and visualize node information.
Start Node Exporter
Start Node Exporter by default on port 9100
liumiaocn:node_exporter-0.18.1.darwin-amd64 liumiao$ ./node_exporter --web.disable-exporter-metrics INFO[0000] Starting node_exporter (version=0.18.1, branch=HEAD, revision=3db77732e925c08f675d7404a8c46466b2ece83e) source="node_exporter.go:156" INFO[0000] Build context (go=go1.11.10, user=root@4a30727bb68c, date=20190604-16:47:36) source="node_exporter.go:157" INFO[0000] Enabled collectors: source="node_exporter.go:97" INFO[0000] - boottime source="node_exporter.go:104" INFO[0000] - cpu source="node_exporter.go:104" INFO[0000] - diskstats source="node_exporter.go:104" INFO[0000] - filesystem source="node_exporter.go:104" INFO[0000] - loadavg source="node_exporter.go:104" INFO[0000] - meminfo source="node_exporter.go:104" INFO[0000] - netdev source="node_exporter.go:104" INFO[0000] - textfile source="node_exporter.go:104" INFO[0000] - time source="node_exporter.go:104" INFO[0000] Listening on :9100 source="node_exporter.go:170"
Start Prometheus
Start Prometheus and grab Node Exporter data every 10 seconds
liumiaocn:config liumiao$ cat prometheus-node.yml global: scrape_interval: 10s evaluation_interval: 10s scrape_configs: - job_name: 'node' static_configs: - targets: ['192.168.31.242:9100'] labels: group: 'node_exporter' liumiaocn:config liumiao$
Note: Replace the above IP with the IP of your own machine, because here is Proetheus started using Docker mode and Node Exporter started using binary mode directly, so set it using IP directly here.
Start command: docker run-d-p 9090:9090-v `pwd`/prometheus-node.yml:/etc/prometheus/prometheus.yml --name Prometheus prom/prometheus
The execution log is as follows:
liumiaocn:config liumiao$ docker run -d -p 9090:9090 -v `pwd`/prometheus-node.yml:/etc/prometheus/prometheus.yml --name prometheus prom/prometheus 2a8c9511f6ba5e2b66424b4b484d58c28b5bd46a30ef1a8966144b79146e0d0f liumiaocn:config liumiao$ docker ps |grep prometheus 2a8c9511f6ba prom/prometheus "/bin/prometheus --c..." 35 seconds ago Up 34 seconds 0.0.0.0:9090->9090/tcp prometheus liumiaocn:config liumiao$
Connection Confirmation
Use / targets to confirm the connection status between Prometheus and Node Exporter. As shown in the figure below, State shows UP, indicating that it is able to connect properly.You can also see the names of the group and job in the configuration file in Lables.
Of course, you can also confirm the information of up in console, enter up and perform a search to confirm the following information
Visual Display
UI for Prometheus
You can use the simple UI provided by Prometheus to confirm changes in metrics, such as changes in available memory within five minutes
Grafana
You can also use Grafana for visual presentations.Detailed usage and setup methods can be found in:
Start Grafana:docker run-d -p 3000:3000 --name grafana grafana/grafana:6.5.1
It is then easy to construct a presentation of the visual indicators you need by referring to the Grafana usage description above.