# prometheus-sd-nacos **Repository Path**: tensorflow/prometheus-sd-nacos ## Basic Information - **Project Name**: prometheus-sd-nacos - **Description**: 使用nacos的服务发现功能,自动获取实例配置监控 - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 9 - **Created**: 2021-12-03 - **Last Updated**: 2021-12-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # prometheus-sd-nacos #### 介绍 使用nacos的服务发现功能,自动获取实例配置监控,将某服务的实例列表写入文件。 #### 使用方法 1. 镜像已推送至阿里仓库 2. 修改 conf/config.json 文件 ``` { "interval": 10, "nacosHost": "http://10.10.60.61:8848/nacos", "namespaceID": "test", "group": "DEFAULT_GROUP", "cluster": "", "services": [ { "name": "gateway", "prometheusJobConfPath": "./job_conf_files/job-gateway.json" }, { "name": "opensrv", "prometheusJobConfPath": "./job_conf_files/job-opensrv.json" } ] } ``` 3. 启动 ``` docker-compose up -d ``` 4. 配置prometheus,使其使用生成的配置文件 ``` scrape_configs: # The job name is added as a label `job=` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090'] # xxx业务 应用 - job_name: 'gateway' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. metrics_path: '/prometheus' # the file contents are also re-read periodically at the specified refresh interval file_sd_configs: - files: ['job_conf_files/job-gateway.json'] # xxx 业务应用 - job_name: 'opensrv' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. metrics_path: '/prometheus' # the file contents are also re-read periodically at the specified refresh interval file_sd_configs: - files: ['job_conf_files/job-opensrv.json'] ```