如何使用prometheus监控pod,/指标不起作用

问题描述 投票:0回答:1

我通过 minikube 部署了带有 k8s 的 pod,通过 helm 安装了 prometheus 和 grafana;

我的 pod 已经配置注释,现在 prometheus 可以找到我的 pod,但是状态已关闭,错误是“服务器返回 HTTP 状态 404”

kind: Pod
apiVersion: v1
metadata:
  name: open-platform-db6fd987-lr9d2
  generateName: open-platform-db6fd987-
  namespace: default
  uid: 556dffd6-1f59-439d-b942-963a07fcb2b4
  resourceVersion: '161857'
  creationTimestamp: '2023-09-02T13:06:29Z'
  labels:
    app: open-platform
    pod-template-hash: db6fd987
  annotations:
    prometheus.io/scrape: 'true'

完整的url是'http://10.244.0.68:8101/metrics',路径和端口是默认配置,我只配置'prometheus.io/scrape: 'true''

并且urldashboard.domain+'/apis/metrics.k8s.io/v1beta1/namespaces/default/pods/open-platform-db6fd987-lr9d2'可以获取数据 我无法理解路径“/metrics”现在可以工作吗?也许我需要做一些其他工作? enter image description here

我尝试将端口修改为80,并将路径修改为“/metrics/resource”,但都不起作用;

我有一个问题,自部署以来每个 Pod 都暴露了“/metrics”?

我希望状态可以切换,我的目标是监控 pod 的 cpu 利用率和节流,因为我需要研究节流......但现在卡住了。

kubernetes prometheus metrics monitor
1个回答
0
投票

按照 此 README 操作时,当 Prometheus 在端口 8101 上公开时,您的配置应如下所示

apiVersion: v1
kind: Pod
metadata:
  # other config goes here
  annotations:
    prometheus.io/scrape: "true"
    prometheus.io/port: "8101"
    prometheus.io/path: "/metrics"
© www.soinside.com 2019 - 2024. All rights reserved.