Seldon:如何使用我自己的 Grafana 和 Prometheus 实例?

Ril*_*Hun 5 grafana kubernetes prometheus seldon seldon-core

我想使用监控命名空间中已有的 Prometheus 和 Grafana 实例来模拟seldon-core-analytics正在执行的操作。我正在使用 prometheus 社区 helm Charts 并安装kube-prometheus-stack 在 k8s 上。这是我到目前为止所做的:

在该values.yaml文件中,在 prometheus 配置下,我添加了以下注释:

annotations:
  prometheus.io/scrape: "true"
  prometheus.io/path: "/prometheus
Run Code Online (Sandbox Code Playgroud)

接下来,我查看了prometheus-config.yaml他们的 Github 存储库,并将配置复制并粘贴到 configmap 文件中。

另外,创建了一个 ServiceMonitor

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: seldon-servicemonitor-default
  labels:
    seldon-monitor: seldon-default
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app.kubernetes.io/managed-by: seldon-core
  endpoints:
    - interval: 15s
      path: /metrics
      port: http
    - interval: 15s
      path: /prometheus
      port: http
  namespaceSelector:
    matchNames:
      - seldon
      - default
      - monitoring
Run Code Online (Sandbox Code Playgroud)

到目前为止,上述步骤没有错误,但普罗米修斯实例似乎无法从我部署在不同命名空间上的模型中获取指标。我还需要执行哪些其他配置,以便我自己的 Prometheus 和 Grafana 实例可以从我很少部署的模型中收集和可视化指标?该文档并没有真正解释如何在您自己的实例上执行此操作,并且他们通过其向您提供的实例seldon-core-analytics尚未准备好用于生产。

ane*_*yte 2

Prometheus 中的配置seldon-core-analytics相当标准。它基于内置的 Kubernetes 服务发现,并使用注释来查找抓取目标:

annotations:
  prometheus.io/scrape: true
  prometheus.io/path: /metrics
  prometheus.io/scheme: http
  prometheus.io/port: 9100
Run Code Online (Sandbox Code Playgroud)

其示例配置中,prometheus 将以带有注释的 Pod、服务和端点为目标prometheus.io/scrape: true。其他三个标签用于覆盖每个目标的默认抓取参数。因此,如果您有示例中的配置,则只需在 pod 上添加其中一些注释即可。

工作方式kube-prometheus-stack不同。它使用prometheus 运算符和 CRD 来塑造配置。设计文档描述了每个 CRD 的用途。

您需要创建ServiceMonitor资源才能为新服务定义抓取规则。ServiceMonitor本身应该具有在 key 下的 prometheus 资源(另一个 CRD)中定义的标签serviceMonitorSelector。在这些情况下很难为您提供有效的示例,但是这个简短的指南应该足以理解该怎么做。

我建议您描述您拥有的其中一个ServiceMonitor,然后在 下创建一个新的更改标签matchLabelsServiceMonitor不要更改新对象中的命名空间,prometheus 运算符默认不会在其他命名空间中查找s。要ServiceMonitor在所有命名空间中发现目标,该目标namespaceSelector必须为空:

spec:
  namespaceSelector:
    any: true
Run Code Online (Sandbox Code Playgroud)