Installing Prometheus
Install Prometheus only on the server1 node only.
- Go to the Prometheus directory.
1cd /opt/prometheus/prometheus-2.45.4.linux-arm64/
- Configure the prometheus.yml file.
- Open the file.
1vi prometheus.yml - Press i to enter the insert mode and modify the file as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
# my global config 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). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: "prometheus" # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ["localhost:9060"] - job_name: node_exporter honor_timestamps: true scrape_interval: 1s scrape_timeout: 1s metrics_path: /metrics scheme: http follow_redirects: true static_configs: - targets: ["agent1:9100","agent2:9100","agent3:9100"] - job_name: 'loads_metric' static_configs: - targets: ['server1:9090'] metrics_path: '/loadIndicator/get/byCurrTimeForPrometheus' scheme: 'http' honor_labels: true scrape_interval: 1s - job_name: 'loads_metric_detail' static_configs: - targets: ['server1:9090'] metrics_path: '/loadStatus/get/byCurrTimeForPrometheus' scheme: 'http' honor_labels: true scrape_interval: 1s
If the compute nodes are not agent1, agent2, and agent3, modify the following lines based on the actual node names:
1- targets: ["agent1:9100","agent2:9100","agent3:9100"]
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the file.
- Start Prometheus.
1nohup ./prometheus --web.listen-address="0.0.0.0:9060" &
- Check whether the deployment is successful.
1 2
# Call the API. http://server1:9060/targets
As shown in the preceding figure, loads_metric, loads_metric_detail, and node_exporter are all in the UP state.
When the LoadsMetricApplication process is running on server1 and Node Exporter is running on the compute nodes, the preceding APIs must be in the UP state.
- Stops the Prometheus service.
- Find the process ID of the Prometheus service.
ps -aux | grep prometheus
- Run the kill command to stop Prometheus.
kill ID
- Find the process ID of the Prometheus service.
Parent topic: Installing Prometheus, Grafana, and Node Exporter