10.2. 向 Prometheus 公开 Data Grid Metrics
添加从 Data Grid 向 Prometheus 公开 JMX 指标的服务。
创建一个
service-metrics.yaml
文件来定义指标服务。apiVersion: v1 kind: Service metadata: annotations: description: Expose Data Grid metrics to Prometheus. labels: app: datagrid-service application: datagrid-service template: datagrid-service metrics: datagrid name: datagrid-app-metrics spec: ClusterIP: None ports: # Set the port name where Data Grid publishes metrics. # You add the port name to service-monitor.yaml. - name: web port: 8080 protocol: TCP targetPort: 9779 selector: deploymentConfig: datagrid-service sessionAffinity: None
应用
service-metrics.yaml
。$ oc apply -f service-metrics.yaml