OpenTSDB使用总结-(4)

使用限制

  • 系统中metric、tagk和tagv都有数量限制,每种最多可创建16777215个。

  • 查询时延受查询条件和时间范围影响,如果存在聚合且数据量很多,则耗时也越长。

  • 谨慎使用返回数据量非常大的查询,会造成查询时较长影响服务使用,从发起查询操作以直至返回结果期间,无法手工终止请求。
  • http请求的参数内容最大值为32M。
  • 写入数据和查询数据时的时间戳建议使用4334400秒到4291718400秒之间的时间,即从1970/02/20 12:00:00到2106/01/01 00:00:00,否则可能导致查询结果不正确。
  • 写入数据时,如果数据点的值为浮点数,目前只支持单精度的浮点数(Float);查询数据时,如果数据点的值为浮点数,以双精度浮点数(Double)的方式显示,可根据需要转换为单精度或双精度浮点数。

API测试样例

请求样例

  • case 1
echo ; curl 'URL:4242/api/query' -d '
{
    "start": xxxx,
    "end": xxxx,
    "queries": [
        {
            "aggregator": "sum",
            "metric": "cpu.sys",
            "filters": [
                {
                   "type":"iteral_or",
                   "tagk":"device",
                   "filter":"device1",
                   "groupBy":false
                }
            ]
        }
    ]
}
';echo

样例解释:

URL:4242 - 默认使用的就是4242端口,URL是OpenTSDB的URL

这里采用了求和的方式,筛选device键值为device1的项目,以每个时间点cpu.sys值的方式进行返回。

  • case 2
echo ; curl 'URL:4242/api/query' -d '
{
    "start": xxxx,
    "end": xxxx,
    "queries": [
        {
            "aggregator": "sum",
            "metric": "cpu.sys",
            "filters": [
                {
                   "type":"iteral_or",
                   "tagk":"device",
                   "filter":"device1|device2|device3",
                   "groupBy":false
                }
            ]
        }
    ]
}
';echo

样例解释:

这里采用了avg取平均的方法,计算device1-3在每个时间点的平均cpu.sys

  • case 3
echo ; curl 'URL:4242/api/query' -d '
{
    "start": xxxx,
    "end": xxxx,
    "queries": [
        {
            "aggregator": "sum",
            "downsample":"1h-sum",
            "metric": "cpu.sys",
            "filters": [
                {
                   "type":"iteral_or",
                   "tagk":"device",
                   "filter":"device1",
                   "groupBy":false
                }
            ]
        }
    ]
}
';echo

样例解释:

这里采用了downsample的查询参数,通过设置1h-sum,对数据采用1h重采样,逻辑是加权形式。注意最后的返回值是从end向前,以3600为间隔进行采样,这里不会严格按照从start开始,而是start时间点后第一个符合条件的采样间隔。比如start是0,end是7300,则输出的点是”dps”:{“3700”:xxx.00,”7300”,xxx.00}

猜你喜欢

转载自blog.csdn.net/u013576018/article/details/80682689