安装Prometheus仅需在server1上安装。
1
|
cd /opt/prometheus/prometheus-2.45.4.linux-arm64/ |
1
|
vi prometheus.yml
|
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 |
若计算节点不为agent1/agent2/agent3,请按照实际集群规划修改如下行。
1
|
- targets: ["agent1:9100","agent2:9100","agent3:9100"] |
1
|
nohup ./prometheus --web.listen-address="0.0.0.0:9060" & |
1 2 |
# 调用接口
http://server1:9060/targets
|
显示界面如上,loads_metric、loads_metric_detail以及node_exporter均为UP状态。
在server1的LoadsMetricApplication进程和计算节点Node Exporter已启动的情况下,Prometheus界面如上接口应均为UP状态。
ps -aux | grep prometheus
kill ID