To export data from a Prometheus instance for custom processing, use the data delivery feature to send the data to MaxCompute. With MaxCompute, you can perform big data computations on data from various sources and use the results for tasks like report analysis.
Prerequisites
-
Ensure that a Prometheus instance is connected. For more information, see the following topics:
Deploy an ApsaraMQ for Kafka instance and create the necessary resources, such as a topic. For more information, see Overview.
Function Compute (FC) has been activated. For more information, see Activate Function Compute.
EventBridge has been activated. For more information, see Activate EventBridge and grant permissions.
Limits
-
If the Prometheus instance and the destination reside in different VPCs, add the destination vSwitch CIDR block to the Prometheus instance allowlist to avoid network connection failures.
-
Supported data sources:
Instance type
Description
Prometheus for Cloud Services
Excludes free instances whose names start with cloud-product-prometheus.
Prometheus for Container Service
None
Prometheus for Flink Serverless
None
Prometheus for Kubernetes
None
General-purpose
Excludes data reported through OpenTelemetry endpoints.
-
Only real-time data generated after task creation is shipped; historical data is not supported.
Billing
When you deliver data to MaxCompute, a Function Compute (FC) service is created. The service name is prefixed with {task_name}_SINK_FC_TO_MAXCOMPUTE. Function Compute (FC) writes the data to MaxCompute, which incurs FC service fees. Data is batched before being sent to Function Compute (FC). Therefore, the fewer the invocations of Function Compute (FC), the lower the related costs. You can log on to the Function Compute console to view the status of your FC resources.
Step 1: Prepare MaxCompute resources
Connect to your MaxCompute project by using one of the methods described in the MaxCompute documentation. For more information, see Select a connection tool.
Define the table schema. The column names in the table schema must match the Prometheus data label names. If a column name does not have a corresponding label, a NULL value is written to that column. If you have multiple types of metrics, the column names must be the union of all metric label names.
For example, assume that you want to export the following two metrics:
Create a SQL table in MaxCompute based on the following example. For more information, see Analyze data by using SQL.
CREATE TABLE metric (
__name__ VARCHAR(50) NOT NULL,
cluster_id VARCHAR(50),
host VARCHAR(50),
node_id VARCHAR(50),
job VARCHAR(50),
instance VARCHAR(50),
cpu VARCHAR(50),
__value__ DOUBLE,
timestamp BIGINT
);The table must include at least the following fields: __name__, __value__, and timestamp. These fields are the basic tags of Prometheus data. We recommend that you design the table schema based on your business requirements and define a sufficient number of fields for tag mapping. If key tags are missing, the table receives a large amount of duplicate data.
Step 2: Create a data delivery task
-
Log on to the Cloud Monitor console.
In the left-side navigation pane, click .
On the Data Shipping page, select a destination region in the top menu bar and click Create Task.
In the dialog box that appears, enter a Task Name and Task description, and click OK.
On the Edit Task page, configure the data source and destination.
Click + Add Data Source, configure the following parameters, and then click OK.
Parameter
Description
Example
Prometheus Instance
The source Prometheus instance.
c78cb8273c02*****
Data Filtering
Filter data by metric labels. Supports regular expressions. Separate multiple conditions with line breaks (AND logic).
__name__=AliyunEcs_CPUUtilization|AliyunEcs_memory_usedutilization regionId=cn-hangzhou id=i-2ze0mxp.*Data Labeling
Additional labels for shipped metric data. Separate with line breaks.
deliver_test_key1=ssss deliver_test_key2=yyyyClick Add Target, set Target Type to MaxCompute, configure the remaining fields as required, and then click OK.
On the Edit Task page, click OK, and then click Save to create the data shipping task.
Step 3: Verify data delivery
In the SQL editor, enter the following SQL statement to query data in the metric table. Click Run and view the execution result on the Result tab.
select * from metric limit 20;