方法一: 在prometheus.yml文件中设置参数
在prometheus.yml中添加以下配置,即可使用浏览器访问本机的节点IP加9090端口,查看监控的指标。
# prometheus的配置文件
global:
scrape_interval: 15s
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'myjob'
scheme: http
static_configs:
- targets: ['localhost:9091'] # 添加本机节点IP加上对应的端口号
方法二: 修改浏览器访问地址
将本机地址从localhost改为127.0.0.1,即可正常访问。
例如,原地址为:http://localhost:9090/targets,现在修改为:http://127.0.0.1:9090/targets,即可正常访问。