doujiao1905 2018-12-21 19:48 采纳率: 100%
浏览 377
已采纳

使用Marathon / Mesos进行Prometheus动态端口服务发现

I've been unable to find an answer to this after days of Googling. I have a service running in Marathon/Mesos. I have a Prometheus cluster scraping metrics. My Marathon metrics port config looks like this:

{
  "containerPort": 8081,
  "hostPort": 0,
  "servicePort": 31301,
  "protocol": "tcp",
  "labels": {
    "metrics": "/metrics"
  }
}

Prometheus, configured with just a boilerplate marathon-sd config, successfully finds this target, but it then listens for metrics on: __address__ = [NodeIP]:31301; so it's listening on the host's IP with the service port, rather than the dynamically assigned host port, while the service port only matters for Marathon-LB.

I know that Marathon defines the environment variable $PORT0 in the container to be the host port, however I can't figure out how to access this from the Prometheus SD config, nor how to access other fields dynamically configured by Marathon like Endpoints. Does anyone have any suggestions? I can't/don't want to assign a static hostPort because I have more containers than there are physical nodes in the cluster, as is sort of the point with container orchestration.

  • 写回答

1条回答 默认 最新

  • duanjie2940 2018-12-27 00:32
    关注

    It is a known bug in Prometheus: it uses the servicePort Marathon app definition property instead of the hostPort one. It is fixed in the v2.6.0.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案