0

Prometheus-operator 和 Prometheus 是使用帮助图分别安装的。

为方便起见,在部署 Prometheus 的命名空间中指定了 serviceMonitorNamespaceSelector 和 PodMonitorNamespaceSelecotr。

我想创建一个 servicemonitor 并连接端点以收集特定的指标,例如单独的解决方案(Gitalb、Rook-ceph)。

Gitlab 和 Rook-ceph 安装在不同的操作系统中,命名空间不同。

但是,ServiceMonitor 不会出现在 Prometheus Target 中。

有什么我错过的吗?

# rook-ceph service && servicemonitor
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: "2021-12-02T12:11:58Z"
  labels:
    app: rook-ceph-mgr
    ceph_daemon_id: a
    rook_cluster: rook-ceph
  name: rook-ceph-mgr
  namespace: rook-ceph
  ownerReferences:
  - apiVersion: ceph.rook.io/v1
    blockOwnerDeletion: true
    controller: true
    kind: CephCluster
    name: rook-ceph
    uid: 39e4d63d-af59-4698-9d38-513bed86d7ab
  resourceVersion: "335184"
  uid: 3c3ccfe9-9c3c-482b-85a9-fc694d5c3da8
spec:
  clusterIP: 10.43.165.239
  clusterIPs:
  - 10.43.165.239
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: http-metrics
    port: 9283
    protocol: TCP
    targetPort: 9283
  selector:
    app: rook-ceph-mgr
    ceph_daemon_id: a
    rook_cluster: rook-ceph
  sessionAffinity: None
  type: ClusterIP
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name:  rook-ceph-mgr
  namespace: rook-ceph
  labels:
    app: rook-ceph-mgr
    ceph_daemon_id: a
    rook_cluster: rook-ceph
    release: prometheus
spec:
  endpoints:
  - path: /metrics
    port: http-metrics
    scheme: http
    interval: 5s
  selector:
    matchLabels:
      app: rook-ceph-mgr
      rook_cluster: rook-ceph
      ceph_daemon_id: a
  namespaceSelector:
    matchNames:
    - rook-ceph
# prometheus install yaml
    serviceMonitorNamespaceSelector:
      matchLabels:
        name: prometheus
    serviceMonitorSelectorNilUsesHelmValues: false
    podMonitorNamespaceSelector:
      matchLabels:
        name: prometheus
root@server1:~# kubectl get servicemonitor -A
NAMESPACE    NAME                                                 AGE
prometheus   prometheus-kube-prometheus-alertmanager              39d
prometheus   prometheus-kube-prometheus-apiserver                 39d
prometheus   prometheus-kube-prometheus-coredns                   39d
prometheus   prometheus-kube-prometheus-grafana                   39d
prometheus   prometheus-kube-prometheus-kube-controller-manager   39d
prometheus   prometheus-kube-prometheus-kube-etcd                 39d
prometheus   prometheus-kube-prometheus-kube-proxy                39d
prometheus   prometheus-kube-prometheus-kube-scheduler            39d
prometheus   prometheus-kube-prometheus-kube-state-metrics        39d
prometheus   prometheus-kube-prometheus-kubelet                   39d
prometheus   prometheus-kube-prometheus-node-exporter             39d
prometheus   prometheus-kube-prometheus-prometheus                39d
prometheus   rke2-ingress-nginx-controller                        39d
rook-ceph    rook-ceph-mgr                                        23m

在此处输入图像描述

4

0 回答 0