10.3. 启用 Prometheus 以监控 Data Grid

服务监控器可让 Prometheus 连接到 Data Grid 指标服务。

  1. 创建一个 service-monitor.yaml 文件,其中包含 ServiceMonitor 对象的定义。

    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      name: datagrid-service-monitor
      labels:
        team: frontend
    spec:
      selector:
        matchLabels:
          metrics: datagrid
      endpoints:
          # Set the name of the port where Data Grid publishes metrics.
          # You create this port in service-metrics.yaml.
        - port: web
  2. 应用 service-monitor.yaml

    $ oc apply -f service-monitor.yaml