1、Kafka服务的自动发现配置
#创建目录mkdir -p /usr/local/prometheus/targets/kafka#创建yml文件[root@xxg-sit-monitor-15 kafka]# cat kafka.yml - targets: - "10.4.62.33:9308" - "10.4.62.53:9308" - "10.4.62.13:9308"#修改prometheus.yml文件[root@xxg-sit-monitor-15 prometheus]# vim prometheus.yml ... - job_name: 'kafka_exporter' file_sd_configs: - files: - /usr/local/prometheus/targets/kafka/*.yml refresh_interval: 1m#重新加载配置文件[root@xxg-sit-monitor-15 prometheus]# systemctl restart prometheus
2、Redis服务的自动发现配置
#创建目录mkdir -p /usr/local/prometheus/targets/redis#创建redis.yml文件[root@xxg-sit-monitor-15 redis]# cat redis.yml - targets: - redis://10.4.62.33:9002 - redis://10.4.62.33:9005 - redis://10.4.62.13:9001 - redis://10.4.62.13:9004 - redis://10.4.62.53:9003 - redis://10.4.62.53:9006#修改prometheus.yml文件[root@xxg-sit-monitor-15 prometheus]# vim prometheus.yml ... - job_name: 'redis_exporter_targets' file_sd_configs: - files: - /usr/local/prometheus/targets/redis/redis.yml relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 10.4.62.33:9121 - job_name: 'redis_exporter' static_configs: - targets: - 10.4.62.33:9121#重新加载配置文件[root@xxg-sit-monitor-15 prometheus]# systemctl restart prometheus
3、Mysql服务的自动发现配置
#创建目录mkdir -p /usr/local/prometheus/targets/mysql#创建mysql.yml文件[root@xxg-sit-monitor-15 mysql]# cat mysql.yml - targets: - "10.4.62.55:9104"#修改prometheus.yml文件[root@xxg-sit-monitor-15 prometheus]# vim prometheus.yml ... - job_name: 'Mysql' file_sd_configs: - files: - /usr/local/prometheus/targets/mysql/*.yml refresh_interval: 5m#重新加载配置文件[root@xxg-sit-monitor-15 prometheus]# systemctl restart prometheus
4、Zookeerper服务的自动发现配置
#创建目录mkdir /usr/local/prometheus/targets/zookeeper#创建zookeeper.yml文件[root@xxg-sit-monitor-15 zookeeper]# cat zookeeper.yml - targets: - "10.4.62.13:9141" - "10.4.62.33:9141"#修改prometheus.yml文件[root@xxg-sit-monitor-15 prometheus]# vim prometheus.yml ... - job_name: 'zookeeper_exporter' file_sd_configs: - files: - /usr/local/prometheus/targets/zookeeper/*.yml refresh_interval: 5m#重新加载配置文件[root@xxg-sit-monitor-15 prometheus]# systemctl restart prometheus
5、consul服务的自动发现配置
#创建目录mkdir -p /usr/local/prometheus/targets/consul/#创建consul.yml文件[root@xxg-sit-monitor-15 consul]# cat consul.yml - targets: - "10.4.62.13:9107"#修改prometheus文件[root@xxg-sit-monitor-15 prometheus]# vim prometheus.yml ... - job_name: 'Consul' file_sd_configs: - files: - /usr/local/prometheus/targets/consul/*.yml refresh_interval: 5m#重新加载配置文件systemctl restart prometheus.service