Updated on 2024-07-24 GMT+08:00

Querying Time Series Data

Scenario

This section describes how to query the time series data about a node's CPU usage.

Obtaining Basic Information

Before querying time series data, obtain the value of the node ID from dimensions on the ECS console, and the value of the cluster ID from dimensions on the cluster management page of the CCE console.

Some metrics may be renamed due to format standardization. For the input parameter metric_name for CPU usage used in this scenario, see the metric_name (not renamed) returned when you call the API for querying time series objects (to call this API, set the input parameter metric_name to the name queried in Host Metrics. In this example, the name is aom_node_cpu_usage (renamed)). For the name corresponding to the cluster ID or node ID, see Host Metrics - Dimension. For the namespace, see Table 4.

Querying Time Series Data

  • URI format

    POST /v2/{project_id}/samples

  • Example request

    POST https://{aom_endpoint}/v2/{project_id}/samples

    To obtain the value of {aom_endpoint}, see Regions and Endpoints.

    Body:

    {  
        "samples": [  
            {  
                "namespace": "PAAS.NODE",  
                "metric_name": "cpuUsage",
                   "dimensions": [ {  
                        "name": "clusterId",  
                        "value": "4fae3587-0202-11eb-9ba9-0255ac100b02"  
                    },
                    {  
                        "name": "hostID",  
                        "value": "4100f512-c4e9-4b65-b0dd-2b94ea5e1a84"  
                    }
                ]  
            }  
        ],  
        "period": 60,  
        "time_range": "-1.-1.2", 
        "statistics": [  
            "maximum",  
            "minimum",  
            "sum"  
        ]  
    }
  • Example response
    {
    	"samples": [{
    		"sample": {
    			"namespace": "PAAS.NODE",
    			"metric_name": "cpuUsage",
    			"dimensions": [{
    				"name": "clusterId",
    				"value": "4fae3587-0202-11eb-9ba9-0255ac100b02"
    			},
    			{
    				"name": "hostID",
    				"value": "4100f512-c4e9-4b65-b0dd-2b94ea5e1a84"
    			}]
    		},
    		"data_points": [{
    			"timestamp": 1608191880000,
    			"unit": "Percent",
    			"statistics": [{
    				"statistic": "maximum",
    				"value": 14.5
    			},
    			{
    				"statistic": "minimum",
    				"value": 14.5
    			},
    			{
    				"statistic": "sum",
    				"value": 14.5
    			}]
    		},
    		{
    			"timestamp": 1608191940000,
    			"unit": "Percent",
    			"statistics": [{
    				"statistic": "maximum",
    				"value": 12.0
    			},
    			{
    				"statistic": "minimum",
    				"value": 12.0
    			},
    			{
    				"statistic": "sum",
    				"value": 12.0
    			}]
    		}]
    	}]
    }