更新时间:2024-11-26 GMT+08:00

查询时序数据

场景描述

本章以查询一个节点的CPU使用率时序数据为例。

涉及的基本信息

查询时序数据前,需要确定节点的ID和集群ID的值,节点ID值可以在ECS的dimensions中查看,集群ID值可以在CCE的“集群管理”页面,基本信息的dimensions中查看。

因指标格式统一,部分指标被重命名。本场景的CPU使用率metric_name入参值来自于调用查询时间序列接口(该接口metric_name入参需传入主机指标中查询到的重命名后的主机指标aom_node_cpu_usage),返回的metric_name参数值(重命名前的主机指标);集群ID和节点ID各自对应的name可以在主机指标-维度中查看,namespace可以在表4 QuerySample中查看。

查询时序数据

  • 接口相关信息

    URI格式:POST /v2/{project_id}/samples

  • 请求示例

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

    {aom_endpoint}信息请从地区和终端节点获取。

    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"  
        ]  
    }
  • 响应示例
    {
    	"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
    			}]
    		}]
    	}]
    }