Management of Metrics
The platform's monitoring system is based on the metrics collected by Prometheus / VictoriaMetrics. This document will guide you on how to manage these metrics.
TOC
Viewing Metrics Exposed by Platform Components
The monitoring method for the cluster components within the platform is to extract metrics exposed via ServiceMonitor. Metrics in the platform are publicly available through the /metrics endpoint. You can view the exposed metrics of a specific component in the platform using the following example command:
Sample Output:
Viewing All Metrics Stored by Prometheus / VictoriaMetrics
You can view the list of available metrics in the cluster to help you write the PromQL you need based on these metrics.
Prerequisites
-
You have obtained your user Token
-
You have obtained the platform address
Procedures
Run the following command to get the list of metrics using the curl command:
Sample Output:
Viewing All Built-in Metrics Defined by the Platform
To simplify user usage, the platform has built in a large number of commonly used metrics. You can directly use these metrics when configuring alerts or monitoring dashboards without needing to define them yourself. The following will introduce you to how to view these metrics.
Prerequisites
-
You have obtained your user Token
-
You have obtained the platform address
Procedures
Run the following command to get the list of metrics using the curl command:
Sample Output:
- Whether this metric supports being used for configuring alerts
- Whether this metric supports being used in monitoring dashboards
- Whether this metric supports being used when configuring alerts for multiple resources
- The PromQL statement defined for the metric
- The variables that can be used in the PromQL statement of the metric
Integrating External Metrics
In addition to the built-in metrics of the platform, you can also integrate metrics exposed by your applications or third-party applications via ServiceMonitor or PodMonitor. This section uses the Elasticsearch Exporter installed in pod form in the same cluster as an example for explanation.
Prerequisites
You have installed your application and exposed metrics through specified interfaces. In this document, we assume your application is installed in the cpaas-system namespace and has exposed the http://<elasticsearch-exporter-ip>:9200/_prometheus/metrics endpoint.
Procedures
-
Create a Service/Endpoint for the Exporter to expose metrics
-
Create a
ServiceMonitorobject to describe the metrics exposed by your application:- To which Prometheus should the ServiceMonitor be synchronized; the operator will listen to the corresponding ServiceMonitor resource based on the serviceMonitorSelector configuration of the Prometheus CR. If the ServiceMonitor's labels do not match the serviceMonitorSelector configuration of the Prometheus CR, this ServiceMonitor will not be monitored by the operator.
- The operator will listen to which namespaces of ServiceMonitor based on the serviceMonitorNamespaceSelector configuration of the Prometheus CR; if the ServiceMonitor is not in the serviceMonitorNamespaceSelector of the Prometheus CR, this ServiceMonitor will not be monitored by the operator.
- Metrics collected by Prometheus will add a job label, with the value being the service label value corresponding to jobLabel.
- The ServiceMonitor matches the corresponding Service based on the namespaceSelector configuration.
- The ServiceMonitor matches the Service based on the selector configuration.
- The ServiceMonitor matches the Service's port based on port configuration.
- The access path to the Exporter, default is /metrics.
- The interval at which Prometheus scrapes the Exporter metrics.
- If authentication is required to access the Exporter path, authentication information needs to be added; it also supports bearer token, tls authentication, and other methods.
-
Check if the ServiceMonitor is being monitored by Prometheus
Access the UI of the monitoring component to check if the job
cpaas-elasticsearch-exporterexists.- Prometheus UI address:
https://<Your platform access address>/clusters/<Cluster name>/prometheus-0/targets - VictoriaMetrics UI address:
https://<Your platform access address>/clusters/<Cluster name>/vmselect/vmui/?#/metrics
- Prometheus UI address: