1

so playing around with OpenTSDB and after inserting data using put I was wondering what the easiest way to query this new data would be. I'm currently telnetting to the database that is on zookeeper and running the commands there. I've looked at the telnet and HTTP versions and haven't really gotten anywhere significantly. Any help would be awesome!

4

2 回答 2

1

最简单的方法是使用 OpenTSDB 提供的标准 UI 以图形的形式查看数据点。它通常在http://<virtual machine ip>:4242

或者

您可以制作一个客户端应用程序并使用 HTTP api 来查询数据点。

于 2014-06-05T05:33:25.567 回答
1
  • 步骤 1. 创建文件 sample.json

    [
        {
            "metric": "johan.test1",
            "timestamp": 1346846401,
            "value": 42.5,
            "tags": {
                "article_id": "00010012",
                "bucket_id": "AAAA2",
                "parent_bucket_id": "AAAA"
            }
        },
        {
            "metric": "johan.test1",
            "timestamp": 1346846401,
            "value": 42.5,
            "tags": {
                "article_id": "00010013",
                "bucket_id": "AAAA2",
                "parent_bucket_id": "AAAA"
            }
        },
        {
            "metric": "johan.test1",
            "timestamp": 1346846402,
            "value": 2.5,
            "tags": {
                "article_id": "00010012",
                "bucket_id": "AAAA2",
                "parent_bucket_id": "AAAA"
            }
        },
        {
            "metric": "johan.test1",
            "timestamp": 1346846402,
            "value": 3.5,
            "tags": {
                "article_id": "00010013",
                "bucket_id": "AAAA2",
                "parent_bucket_id": "AAAA"
            }
        },
        {
            "metric": "johan.test1",
            "timestamp": 1346846400,
            "value": 15.2,
            "tags": {
                "article_id": "00010011",
                "bucket_id": "AAAA1",
                "parent_bucket_id": "AAAA"
            }
        }
    ]
    
  • 第2步:发布并添加到opentsdb

    curl -X POST -d @sample.json -H "Accept: Application/json" -H "Content-Type: application/json" http://localhost:4242/api/put
    
  • 第 3 步:评估结果:运行查询

    http://localhost:4242/api/query?start=0&m=sum:rsl.test3.pv{bucket_id=*}
    

    结果:

    [
    {
        "metric":"johan.test1",
        "tags":
        {   
            "bucket_id":"AAAA1",
            "parent_bucket_id":"AAAA",
            "article_id":"00010011"
        },
        "aggregateTags":[],
        "dps":{"1346846400":15.199999809265137}
    },
    {
        "metric":"johan.test1",
        "tags":
        {
            "bucket_id":"AAAA2",
            "parent_bucket_id":"AAAA"
        },
        "aggregateTags":["article_id"],
        "dps":{"1346846401":85.0,"1346846402":6.0}
    }
    ]
    

而已。希望这也对你有用。

干杯,

约翰

于 2015-11-03T06:26:32.147 回答