/_rollup/${rollup_task_name},${rollup_task_name}为 Rollup 任务的名称。
方法:PUT参数名称 | 必选 | 类型 | 描述 |
base_metric | 是 | string | Rollup 依赖的 metric 名称(父表) |
rollup_metric | 是 | string | Rollup 产生的 metric 名称(子表) |
base_rollup | 否 | string | 依赖的 Rollup 任务,任务执行前会检查相应时间段的依赖任务是否完成执行 |
query | 否 | string | 过滤数据的查询条件,由很多个元素和操作对组成,例如: name:host AND type:max OR region:gz |
group_by | 是 | Array | 进行聚合的维度列,可以包含多列 |
function | 是 | Map | 指定聚合的名称、方法和字段,其字段只能选自 base_metric 里的 fields 字段,如果 base_metric 的 fields 为空,则无法设置 rollup,function 有 sum、avg、min、max、set、any、first、last、percentiles 等。例如: {"cost_total":{"sum": {"field":"cost"}},"cpu_usage_avg":{ "avg": { "field":"cpu_usage"}}} |
interval | 是 | string | 聚合粒度(rollup 产生数据的时间精度),例如1s、5m(5分钟)、1h、1d等 |
frequency | 否 | string | 调度频率,例如5m、1h、1d等,默认等于 interval |
delay | 否 | string | 延迟执行时间,写入数据通常有一定的延时,避免丢失数据,例如5m、1h等 |
start_time | 否 | string | 开始时间,从该时间开始周期性执行 Rollup,默认为当前时间 |
end_time | 否 | string | 结束时间,到达该时间后不再调度 ,默认为时间戳最大值 |
options | 否 | map | rollup_metric 选项,跟新建 metric 选项一致 |
curl -u root:le201909 -H 'Content-Type:application/json' -X PUT 172.16.345.14:9201/_rollup/ctsdb_rollup_task_test -d'{"base_metric": %{base_metric_name},"rollup_metric": %{rollup_metric_name},"base_rollup": %{base_rollup_name},"query" : "name:host AND type:max","group_by": ["host"],"function": {"cost_total": {"sum": {"field": "cost"}},"cpu_usage_avg": {"avg": {"field": "cpu_usage"}},"value": {"percentiles": {"field": "value","percents": [95]}},"metricName": {"set": {"value": "cpu_usage"}},"appid": {"any": {"field": "appid"}},"first_value": {"first": {"field": "value"}},"last_value": {"last": {"field": "value"}}},"interval": "1m","frequency": "5m","delay": "1m","start_time": "1502892000","end_time": "2147483647","options": {"expire_day": 365}}'
{"acknowledged": true,"message": "create rollup success"}
/_rollups
方法:GETcurl -u root:le201909 -H 'Content-Type:application/json' -X GET 172.16.345.14:9201/_rollups{"result":{"rollups":["rollup_jgq_6","rollup_jgq_60"]},"status": 200}
/_rollup/${rollup_task_name},${rollup_task_name}为 Rollup 任务的名称。
方法:GETcurl -u root:le201909 -H 'Content-Type:application/json' -X GET 172.16.345.14:9201/_rollup/rollup_jgq_6?v{"result": {"rollup_jgq_6": {"base_metric": "cvm_device-300","rollup_metric": "cvm_device-86400","query": "metricName:cpu_usage AND statType:max","group_by": ["vm_uuid"],"function": {"value": {"percentiles": {"field": "value","percents": [95]}},"metricName": {"set": {"value": "cpu_usage"}},"appid": {"any": {"field": "appid"}}},"interval": "1d","delay": "5m","options": {"expire_day": 186},"frequency": "1d","start_time": 1534003200,"end_time": 2147483647,"@state": "running", // 运行状态"@timestamp": 1550766085000, // rollup 任务信息更新的时间点"@last_end_time": 1550764800 // rollup 任务正确执行到的时间点}},"status": 200}
/_rollup/${rollup_task_name},${rollup_task_name},为 Rollup 任务的名称。
方法:DELETEcurl -u root:le201909 -H 'Content-Type:application/json' -X DELETE 172.16.345.14:9201/_rollup/ctsdb_rollup_task_test{"acknowledged": true,"message": "delete rollup success"}
/_rollup/${rollup_task_name}/update,${rollup_task_name}为 Rollup 任务的名称。
方法:POST参数名称 | 必选 | 类型 | 描述 |
state | 是 | string | running/pause |
start_time | 否 | string | 开始时间,从该时间开始周期性执行 Rollup,默认为当前时间 |
end_time | 否 | string | 结束时间,到达改时间后不再调度,默认为时间戳最大值 |
options | 否 | map | 聚合选项,跟新建 metric 选项一致 |
curl -u root:le201909 -H 'Content-Type:application/json' -X POST 172.16.345.14:9201/_rollup/ctsdb_rollup_task_test/update -d'{"state":"running","start_time": "1511918989","end_time": "1512019765","options":{"expire_day": 365}}'
{"acknowledged": true,"message": "update rollup success"}
文档反馈