The custom collection feature lets you scrape metrics from specific endpoints in your containers or ECS instances to make Prometheus more flexible, automated, and manageable. This document uses a container environment as an example.
Limitations
Only container and ECS environments are supported.
Billing
Custom collection incurs fees. For more information, see Prometheus instance billing.
Prerequisites
-
You have a container or an ECS instance. For instructions, see Create an ACK managed cluster and Create an instance.
-
A target endpoint on your container cluster or ECS instance must be exposing metrics.
Access
-
Log on to the Cloud Monitor console.
-
In the navigation pane on the left, click Integration Management.
-
On the Integrated Environments tab, in the Container Service list, click Metric Scraping in the Actions column of the target container environment to open the Metric Scraping page.
-
On the Metric Scraping tab, click Customize Collection.
Custom collection list
The Customize Collection page lists all custom collection configurations for the current container or ECS environment.
The list includes the following columns: Name, Job Name, Component, Service Discovery Method, Scrape Path, Scrape Interval, and Actions. In the Actions column, you can Disable, Edit Configuration, and Delete tasks. In the upper-right corner of the page, click the Create button to add a collection task and search for tasks by Task Name.
Create custom collection
On the Customize Collection page, click Create. In the Add Custom Collection Task panel, enter a Job Name, paste your custom collection YAML configuration into the code editor and click Precheck and Create.
The YAML configuration uses the Prometheus scrape_configs format. You can define multiple jobs, such as job1 and job2. Each job can include fields like honor_timestamps, honor_labels, scrape_interval (for example, 30s), scheme (for example, http), metrics_path (for example, /metric), and targets under static_configs (for example, 127.0.0.1:9090).
Scrape interval and Grafana query step
The scrape_interval in your YAML configuration (or interval in a ServiceMonitor/PodMonitor) controls how often Prometheus scrapes the target endpoint. For example, interval: 5s means Prometheus scrapes metrics every 5 seconds.
The query step determines the data granularity displayed in a Grafana panel, which is independent of the scrape interval. Grafana calculates the actual query step using the formula: max(Min interval, Time range / Max data points). Even if the scrape interval is 5s, Grafana might display data at a 15s or 30s granularity when you view a long time range.
To match the Grafana data granularity to your scrape interval, expand Query options in the panel editor. Set the Min interval to the same value as your scrape interval (for example, 5s) and view a shorter time range. The Min interval only sets a lower limit for the query step; this setting has no effect if the calculated step is already greater.
Related operations
Edit custom collection
To edit a custom collection task, find it in the list and click Edit Configuration in the Operation column. Modify the YAML content in the Edit Custom Collection Task panel.
Delete custom collection
To delete a custom collection task, find it in the list and click Delete in the Operation column.
Disable custom collection
To disable a custom collection task, find it in the list and click Disable in the Operation column. A disabled task stops scraping metrics.