1 插入数据
POST http://localhost:4242/api/put?summary
[{
“metric”: “cpu”,
“timestamp”: 1552605661,
“value”: 1,
“tags”: {
“type”: “Server”,
“objectName”: “objectName”,
“id”: “123456”,
“unit”: “percentage”
}
}]
说明:
多次保存相同时间戳的数据是覆盖的,新数据覆盖旧数据。
特殊符号保存不了,例如%
想要自己创建metric需要事先在opentsdb.conf配置文件中配置tsd.core.auto_create_metrics = true并重启服务
2.查询数据
POST http://localhost:4242/api/query?detail
{
“start”: 1552605661,
“end”: 1558837144,
“queries”: [
{
“aggregator”: “sum”,
“metric”: “cpu”,
“rate”: “false”,
“tags”: {
“type”: “Server”,
“objectName”: “iliteral_or(objectname)”,
“id”: “*”
}
}
]
}
说明