小编ahu*_*us1的帖子

使用 prometheus 抓取 kubernetes 容器的 HTTP 和 HTTPS 端口指标

我们希望 Prometheus 安装能够抓取 Pod 中两个容器的指标。一个容器通过 HTTPS 在端口 443 公开指标,而另一个容器通过 HTTP 在端口 8080 公开指标。两个容器在同一路径提供指标,即/metrics.

如果我们将prometheus.io/scheme声明为 http 或 https,则只会抓取一个容器。对于另一个我们总是收到:如果我们根本server returned HTTP status 400 Bad Request 不定义prometheus.io/scheme,也会发生同样的情况。然后,Prometheus 将为两个端口使用 http,并且对于在端口 443 公开指标的容器会失败,因为它只期望 HTTPS 请求。

有没有办法告诉普罗米修斯如何准确地抓取我们部署中的各个容器?获取两个容器的指标有哪些可行的解决方法?

版本

库伯内特斯:1.10.2

普罗米修斯:2.2.1

部署摘录

apiVersion: apps/v1
kind: Deployment
metadata:
  name: xxx
  namespace: xxx
spec:
  selector:
    matchLabels:
      app: xxx
  template:
    metadata:
      labels:
        app: xxx
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/path: "/metrics"
    spec:
      containers:
      - name: container-1
        image: xxx
        ports:
        - containerPort: 443
      - name: container-2 …
Run Code Online (Sandbox Code Playgroud)

kubernetes prometheus

0
推荐指数
1
解决办法
6939
查看次数

标签 统计

kubernetes ×1

prometheus ×1