1、Kafka服务的自动发现配置

  1. #创建目录
  2. mkdir -p /usr/local/prometheus/targets/kafka
  3. #创建yml文件
  4. [root@xxg-sit-monitor-15 kafka]# cat kafka.yml
  5. - targets:
  6. - "10.4.62.33:9308"
  7. - "10.4.62.53:9308"
  8. - "10.4.62.13:9308"
  9. #修改prometheus.yml文件
  10. [root@xxg-sit-monitor-15 prometheus]# vim prometheus.yml
  11. ...
  12. - job_name: 'kafka_exporter'
  13. file_sd_configs:
  14. - files:
  15. - /usr/local/prometheus/targets/kafka/*.yml
  16. refresh_interval: 1m
  17. #重新加载配置文件
  18. [root@xxg-sit-monitor-15 prometheus]# systemctl restart prometheus

2、Redis服务的自动发现配置

  1. #创建目录
  2. mkdir -p /usr/local/prometheus/targets/redis
  3. #创建redis.yml文件
  4. [root@xxg-sit-monitor-15 redis]# cat redis.yml
  5. - targets:
  6. - redis://10.4.62.33:9002
  7. - redis://10.4.62.33:9005
  8. - redis://10.4.62.13:9001
  9. - redis://10.4.62.13:9004
  10. - redis://10.4.62.53:9003
  11. - redis://10.4.62.53:9006
  12. #修改prometheus.yml文件
  13. [root@xxg-sit-monitor-15 prometheus]# vim prometheus.yml
  14. ...
  15. - job_name: 'redis_exporter_targets'
  16. file_sd_configs:
  17. - files:
  18. - /usr/local/prometheus/targets/redis/redis.yml
  19. relabel_configs:
  20. - source_labels: [__address__]
  21. target_label: __param_target
  22. - source_labels: [__param_target]
  23. target_label: instance
  24. - target_label: __address__
  25. replacement: 10.4.62.33:9121
  26. - job_name: 'redis_exporter'
  27. static_configs:
  28. - targets:
  29. - 10.4.62.33:9121
  30. #重新加载配置文件
  31. [root@xxg-sit-monitor-15 prometheus]# systemctl restart prometheus

3、Mysql服务的自动发现配置

  1. #创建目录
  2. mkdir -p /usr/local/prometheus/targets/mysql
  3. #创建mysql.yml文件
  4. [root@xxg-sit-monitor-15 mysql]# cat mysql.yml
  5. - targets:
  6. - "10.4.62.55:9104"
  7. #修改prometheus.yml文件
  8. [root@xxg-sit-monitor-15 prometheus]# vim prometheus.yml
  9. ...
  10. - job_name: 'Mysql'
  11. file_sd_configs:
  12. - files:
  13. - /usr/local/prometheus/targets/mysql/*.yml
  14. refresh_interval: 5m
  15. #重新加载配置文件
  16. [root@xxg-sit-monitor-15 prometheus]# systemctl restart prometheus

4、Zookeerper服务的自动发现配置

  1. #创建目录
  2. mkdir /usr/local/prometheus/targets/zookeeper
  3. #创建zookeeper.yml文件
  4. [root@xxg-sit-monitor-15 zookeeper]# cat zookeeper.yml
  5. - targets:
  6. - "10.4.62.13:9141"
  7. - "10.4.62.33:9141"
  8. #修改prometheus.yml文件
  9. [root@xxg-sit-monitor-15 prometheus]# vim prometheus.yml
  10. ...
  11. - job_name: 'zookeeper_exporter'
  12. file_sd_configs:
  13. - files:
  14. - /usr/local/prometheus/targets/zookeeper/*.yml
  15. refresh_interval: 5m
  16. #重新加载配置文件
  17. [root@xxg-sit-monitor-15 prometheus]# systemctl restart prometheus

5、consul服务的自动发现配置

  1. #创建目录
  2. mkdir -p /usr/local/prometheus/targets/consul/
  3. #创建consul.yml文件
  4. [root@xxg-sit-monitor-15 consul]# cat consul.yml
  5. - targets:
  6. - "10.4.62.13:9107"
  7. #修改prometheus文件
  8. [root@xxg-sit-monitor-15 prometheus]# vim prometheus.yml
  9. ...
  10. - job_name: 'Consul'
  11. file_sd_configs:
  12. - files:
  13. - /usr/local/prometheus/targets/consul/*.yml
  14. refresh_interval: 5m
  15. #重新加载配置文件
  16. systemctl restart prometheus.service