如何使用外部 web api 与 docker 中的 prometheus 通信

问题描述

我是监控新手。我正在尝试使用 grafana 学习普罗米修斯,我从 docker 安装了普罗米修斯,并将 prometheus.yml 设置在共享的 Windows 文件夹中。

然后我访问 http://localhost:9090,prometheus 服务器就启动了。

然后我启动了一个WebApi C#来测试,这个windows中的webapi运行在http://localhost:5000。

当我再次访问 prometheus 服务器时,我的 WebApi 总是宕机

enter image description here

我的普罗米修斯,yml

 scrape_configs:     # The job name is added as a label
 `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'    
    static_configs:
    - targets: ['localhost:9090']
        
  - job_name: 'WebApiTemplate'    
    static_configs:
     - targets: 
        - localhost:5000
     metrics_path: /metrics-text

如何正确配置prometheus.yml?

是否需要将我的 webApi 放在 docker 中才能正常工作?

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)