opentsdb操作草稿

插入数据api/put

192.168.1.68:4242/api/put?details

http://localhost:4242/api/put?details
method:POST
[ {
"metric": "gas_patrol", "timestamp": 1571028638, "value": 58, "tags": { "host": "web01", "dc": "lga" } }, { "metric": "gas_patrol", "timestamp": 1571028638, "value": 18, "tags": { "host": "web02", "dc": "lga2" } } ]

return

{
"success": 2,
"failed": 0,
"errors": []
}

查询api/query

http://localhost:4242/api/query
method:POST
{
    "start": 1571028630,
    "end": 1571028639,
    "showTSUIDs":"true",  
    "queries": [
        {
            "aggregator": "avg",
            "metric": "gas_patrol",
            "tags": {
                 "host": "web*",
                 "dc": "lga"
             }
        }
    ]
}
return

[
    {
        "metric": "gas_patrol",
        "tags": {
            "host": "web01",
            "dc": "lga"
        },
        "aggregateTags": [],
        "tsuids": [
            "000001000001000001000002000002"
        ],
        "dps": {
            "1571028635": 18,
            "1571028636": 28,
            "1571028637": 38,
            "1571028638": 58
        }
    },
    {
        "metric": "gas_patrol",
        "tags": {
            "host": "web02",
            "dc": "lga"
        },
        "aggregateTags": [],
        "tsuids": [
            "000001000001000003000002000002"
        ],
        "dps": {
            "1571028637": 38,
            "1571028638": 18
        }
    },
    {
        "metric": "gas_patrol",
        "tags": {
            "host": "web02",
            "dc": "lga2"
        },
        "aggregateTags": [],
        "tsuids": [
            "000001000001000003000002000004"
        ],
        "dps": {
            "1571028638": 18
        }
    }
]

平均值:"downsample":"0all-avg"

{
    "start": 1271028034,
    "end": 1571028939,
    "showTSUIDs":"true",  
    "queries": [
        {
            "aggregator": "avg",
            "metric": "gas_patrol",
            "downsample":"0all-avg",
            "tags": {
                 "host": "web*",
                 "dc": "lga"
             }
        }
    ]
}

求和:"downsample":"0all-sum"

 

下采样(按1分钟/1小时/1天聚合)

"downsample":"1m-avg"

"downsample":"1h-avg"

"downsample":"1d-avg"

"downsample":"0y-avg"

可以查询相应的 5分钟  10小时  22天 等等

下采样补值:

1m-avg-null
1m-avg-zero
。。。


可用的政策包括:

None(none) - 默认行为,在序列化期间不输出缺失值,在聚合序列时执行线性插值(或以其他方式指定插值)的。
NaN(nan) - 当序列中缺少所有值时,在序列化输出中输出NaN 。缺少值时跳过聚合中的NaN,而不是将整个分组计算转换为NaN(参见下表)。
Null(null) - 与NaN的行为相同,只是在序列化期间它会发出一个null,而不是一个NaN。
零(zero) - 缺少时间戳时替换为零。零值将合并到汇总结果中。

 

posted @ 2019-10-14 15:59  静静别跑  阅读(993)  评论(0编辑  收藏  举报