我想使用监控命名空间中现有的 Prometheus 和 Grafana 实例来模拟 seldon-core-analytics
是在做。我正在使用普罗米修斯社区 Helm 图表并安装了 kube-prometheus-stack
在 k8s 上。这是我到目前为止所做的:
在 values.yaml
文件,在 prometheus 配置下,我添加了以下注释:
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/prometheus
接下来,我看了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
到目前为止,上述步骤没有错误,但似乎 prometheus 实例无法从我部署在不同命名空间上的模型中抓取指标。我还需要做哪些其他配置,以便我自己的 Prometheus 和 Grafana 实例可以从我很少部署的模型中收集和可视化指标?该文档并没有真正解释如何在您自己的实例上执行此操作,而他们通过 seldon-core-analytics
提供给您的实例。未准备好生产。
最佳答案
seldon-core-analytics
中的 Prometheus 配置是很标准的。它基于内置的 Kubernetes 服务发现,并使用注释来查找抓取目标:
annotations:
prometheus.io/scrape: true
prometheus.io/path: /metrics
prometheus.io/scheme: http
prometheus.io/port: 9100
在 their example configuration prometheus 将使用 prometheus.io/scrape: true
定位 Pod、服务和端点对它们的注释。其他三个标签用于覆盖每个目标的默认抓取参数。因此,如果您有示例中的配置,则只需将其中一些注释放在 pod 上。方式
kube-prometheus-stack
作品不一样。它使用 prometheus operator和 CRD 来塑造配置。 This设计文档描述了每个 CRD 的用途。您需要创建一个
ServiceMonitor
资源以便为新服务定义抓取规则。 ServiceMonitor
本身应该具有在 serviceMonitorSelector
下的 prometheus 资源(另一个 CRD)中定义的标签 key 。在这些情况下很难为您提供一个工作示例,但是 this简短的指南应该足以了解要做什么。我建议你描述其中之一
ServiceMonitor
s,然后在 matchLabels
下创建一个新的更改标签.不要更改新对象中的命名空间,prometheus 运算符不会查找 ServiceMonitor
默认情况下在其他命名空间中。使ServiceMonitor
发现所有命名空间中的目标 namespaceSelector
必须为空:spec:
namespaceSelector:
any: true
关于kubernetes - Seldon:如何使用我自己的 Grafana 和 Prometheus 实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65965188/