此内容没有您所选择的语言版本。
Chapter 14. Monitoring Data Grid services
Data Grid exposes metrics that can be used by Prometheus and Grafana for monitoring and visualizing the cluster state.
This documentation explains how to set up monitoring on OpenShift Container Platform. If you’re working with community Prometheus deployments, you might find these instructions useful as a general guide. However you should refer to the Prometheus documentation for installation and usage instructions.
See the Prometheus Operator documentation.
14.1. Creating a Prometheus service monitor 复制链接链接已复制到粘贴板!
Data Grid Operator automatically creates a Prometheus ServiceMonitor that scrapes metrics from your Data Grid cluster.
Procedure
Enable monitoring for user-defined projects on OpenShift Container Platform.
When the Operator detects an Infinispan CR with the monitoring annotation set to true, which is the default, Data Grid Operator does the following:
-
Creates a
ServiceMonitornamed<cluster_name>-monitor. Adds the
infinispan.org/monitoring: 'true'annotation to yourInfinispanCR metadata, if the value is not already explicitly set:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
To authenticate with Data Grid, Prometheus uses the operator credentials.
Verification
You can check that Prometheus is scraping Data Grid metrics as follows:
- In the OpenShift Web Console, select the </> Developer perspective and then select Monitoring.
- Open the Dashboard tab for the namespace where your Data Grid cluster runs.
Open the Metrics tab and confirm that you can query Data Grid metrics such as:
vendor_cache_manager_default_cluster_size
vendor_cache_manager_default_cluster_sizeCopy to Clipboard Copied! Toggle word wrap Toggle overflow
14.1.1. Disabling the Prometheus service monitor 复制链接链接已复制到粘贴板!
You can disable the ServiceMonitor if you do not want Prometheus to scrape metrics for your Data Grid cluster.
Procedure
Set
'false'as the value for theinfinispan.org/monitoringannotation in yourInfinispanCR.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Apply the changes.
14.1.2. Configuring Service Monitor Target Labels 复制链接链接已复制到粘贴板!
You can configure the generated ServiceMonitor to propagate Service labels to the underlying metrics using the ServiceMonitor spec.targetLabels field. Use the Service labels to filter and aggregate the metrics collected from the monitored endpoints.
Procedure
-
Define labels to apply to your service by setting the
infinispan.org/targetLabelsannotation in yourInfinispanCR. Specify a comma-separated list of the labels required in your metrics using the
infinispan.org/serviceMonitorTargetLabelsannotation on yourInfinispanCR.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Apply the changes.
14.2. Installing the Grafana Operator 复制链接链接已复制到粘贴板!
To support various needs, Data Grid Operator integrates with the community version of the Grafana Operator to create dashboards for Data Grid services.
Until Grafana is integrated with OpenShift user workload monitoring, the only option is to rely on the community version. You can install the Grafana Operator on OpenShift from the OperatorHub and should create a subscription for the alpha channel.
However, as is the policy for all Community Operators, Red Hat does not certify the Grafana Operator and does not provide support for it in combination with Data Grid. When you install the Grafana Operator you are prompted to acknowledge a warning about the community version before you can continue.
14.3. Creating Grafana data sources 复制链接链接已复制到粘贴板!
Create a GrafanaDatasource CR so you can visualize Data Grid metrics in Grafana dashboards.
Prerequisites
-
Have an
occlient. -
Have
cluster-adminaccess to OpenShift Container Platform. - Enable monitoring for user-defined projects on OpenShift Container Platform.
-
Install the Grafana Operator from the alpha channel and create a
GrafanaCR.
Procedure
Create a
ServiceAccountthat lets Grafana read Data Grid metrics from Prometheus.apiVersion: v1 kind: ServiceAccount metadata: name: infinispan-monitoring
apiVersion: v1 kind: ServiceAccount metadata: name: infinispan-monitoringCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the
ServiceAccount.oc apply -f service-account.yaml
oc apply -f service-account.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Grant
cluster-monitoring-viewpermissions to theServiceAccount.oc adm policy add-cluster-role-to-user cluster-monitoring-view -z infinispan-monitoring
oc adm policy add-cluster-role-to-user cluster-monitoring-view -z infinispan-monitoringCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create a Grafana data source.
Retrieve the token for the
ServiceAccount.oc serviceaccounts get-token infinispan-monitoring
oc serviceaccounts get-token infinispan-monitoringCopy to Clipboard Copied! Toggle word wrap Toggle overflow Define a
GrafanaDataSourcethat includes the token in thespec.datasources.secureJsonData.httpHeaderValue1field, as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Apply the
GrafanaDataSource.oc apply -f grafana-datasource.yaml
oc apply -f grafana-datasource.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
Enable Grafana dashboards with the Data Grid Operator configuration properties.
14.4. Configuring Data Grid dashboards 复制链接链接已复制到粘贴板!
Data Grid Operator provides global configuration properties that let you configure Grafana dashboards for Data Grid clusters.
You can modify global configuration properties while Data Grid Operator is running.
Prerequisites
- Data Grid Operator must watch the namespace where the Grafana Operator is running.
Procedure
Create a
ConfigMapnamedinfinispan-operator-configin the Data Grid Operator namespace.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the namespace of your Data Grid cluster with the
data.grafana.dashboard.namespaceproperty.NoteDeleting the value for this property removes the dashboard. Changing the value moves the dashboard to that namespace.
-
Specify a name for the dashboard with the
data.grafana.dashboard.nameproperty. -
If necessary, specify a monitoring key with the
data.grafana.dashboard.monitoring.keyproperty. Create
infinispan-operator-configor update the configuration.oc apply -f infinispan-operator-config.yaml
oc apply -f infinispan-operator-config.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open the Grafana UI, which is available at:
oc get routes grafana-route -o jsonpath=https://"{.spec.host}"oc get routes grafana-route -o jsonpath=https://"{.spec.host}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
14.5. Enabling JMX remote ports for Data Grid clusters 复制链接链接已复制到粘贴板!
Enable JMX remote ports to expose Data Grid MBeans and to integrate Data Grid with external monitoring systems such as Cryostat.
When you enable JMX for Data Grid cluster, the following occurs:
-
Each Data Grid server pod exposes an authenticated JMX endpoint on port
9999utilizing the "admin" security-realm, which includes the Operator user credentials. -
The
<cluster-name>-adminService exposes port9999.
You can enable or disable JMX only during the creation of the Infinispan CR. Once the CR instance is created, you cannot modify the JMX settings.
Procedure
Enable JMX in your
InfinispanCR.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the Operator user credentials to authenticate client JMX connections.
oc get secret infinispan-generated-operator-secret -o jsonpath="{.data.identities\.yaml}" | base64 --decodeoc get secret infinispan-generated-operator-secret -o jsonpath="{.data.identities\.yaml}" | base64 --decodeCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
14.6. Setting up JFR recordings with Cryostat 复制链接链接已复制到粘贴板!
Enable JDK Flight Recorder (JFR) monitoring for your Data Grid clusters that run on OpenShift.
JFR recordings with Cryostat
JFR provides insights into various aspects of JVM performance to ease cluster inspection and debugging. Depending on your requirements, you can store and analyze your recordings using the integrated tools provided by Cryostat or export the recordings to an external monitoring application.
Prerequisites
- Install the Cryostat Operator. You can install the Cryostat Operator in your OpenShift project by using Operator Lifecycle Manager (OLM).
- Have JMX enabled on your Data Grid cluster. You must enable JMX before deploying the cluster, as JMX settings cannot be modified after deployment.
Procedure
Create a Cryostat CR in the same namespace as your
InfinispanCR.Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe Cryostat Operator requires cert-manager for traffic encryption. If the cert-manager is enabled but not installed, the deployment fails. For details, see the Installing Cryostat guide.
Wait for the
CryostatCR to be ready.oc wait -n <namespace> --for=condition=MainDeploymentAvailable cryostat/cryostat-sample
oc wait -n <namespace> --for=condition=MainDeploymentAvailable cryostat/cryostat-sampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open the Cryostat
status.applicationUrl.oc -n <namespace> get cryostat cryostat-sample
oc -n <namespace> get cryostat cryostat-sampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the Operator user credentials to authenticate client JMX connections in the Cryostat UI.
oc get secret infinispan-generated-operator-secret -o jsonpath="{.data.identities\.yaml}" | base64 --decodeoc get secret infinispan-generated-operator-secret -o jsonpath="{.data.identities\.yaml}" | base64 --decodeCopy to Clipboard Copied! Toggle word wrap Toggle overflow - In the Cryostat UI, navigate to the Security menu.
- In the Store Credentials window, click the Add button. The Store Credentials window opens.
In the Match Expression filed, enter match expression details in the following format:
target.labels['infinispan_cr'] == '<cluster_name>'
target.labels['infinispan_cr'] == '<cluster_name>'Copy to Clipboard Copied! Toggle word wrap Toggle overflow