This topic describes how to create a Prometheus data source in OCP and the subsequent operations required.
Prerequisites
- Ensure that the SLS data source is not enabled in the current OCP.
- The Prometheus service of version V2.28 or later has been deployed.
- Ensure that the user currently logged in to OCP has the ADMIN role.
Procedure
Log in to OCP.
In the left navigation bar, click System Management > External Integration.
Click the Prometheus tab.
On the Prometheus Data Sources page, click Create Prometheus Data Source.
In the dialog box that appears, enter the relevant information for the Prometheus Data Source.
ParameterDescriptionData Source Name The name of the Prometheus data source. It must be 2 to 32 characters long, can contain Chinese characters, English letters, numbers, and underscores (_), and must be unique. Access Address The access IP address of the Prometheus service, starting with http/https. Only one IP address is allowed.Port The access port of the Prometheus service. The default is 9090, but it can be customized. Username The username of the authorized account for the Prometheus service. This field is required if available. Password The password of the authorized account for the Prometheus service. This field is required if available. Remarks Add any special notes about the Prometheus data source. Click Verify to verify the connectivity of the data source.
After verification succeeds, click Create.
What to do next
After the data source is created, follow these steps to configure and enable Prometheus for it to take effect.
Add the following configuration information to the Prometheus configuration file
prometheus.yaml(note that the password is shown only once).scrape_configs: - job_name: 'ocp_sd' scheme: 'http' fallback_scrape_protocol: "PrometheusText1.0.0" # This parameter is required only for Prometheus 3.x; Prometheus 2.x does not require it. http_sd_configs: - url: 'http://xx.xx.xx.xx:8080/api/v2/monitor/prometheus_sd' basic_auth: # Access OCP to retrieve all targets in prometheus_sd. username: "******" password: "******" basic_auth: # Control access to all targets. username: "******" password: "******"Restart the Prometheus service to ensure the configuration takes effect.
Enable the Prometheus configuration in the current OCP platform.
By default, monitoring data is written only to Prometheus. To write monitoring data to MonitorDB as well, change the value of the system parameter
ocp.monitor(metric.collect.service.typetoLOCAL.
