OpenTSDB / opentsdb

A scalable, distributed Time Series Database.
http://opentsdb.net
GNU Lesser General Public License v2.1
5k stars 1.25k forks source link

be able to sum two series #546

Open gaos1 opened 9 years ago

gaos1 commented 9 years ago

for the following query, i want the result to be sum of two matched series. can opentsdb support this?

/api/query?start=1h-ago&m=sum:system.healthy{job=etcd_z1|etcd_z2}

opentsdb response:

[
    {
        "metric": "system.healthy",
        "tags": {
            "index": "0",
            "job": "etcd_z2",
            "role": "unknown"
        },
        "aggregateTags": [],
        "dps": {
            "1439790128": 1,
            "1439790188": 1,
         }
    },
    {
        "metric": "system.healthy",
        "tags": {
            "index": "0",
            "job": "etcd_z1",
            "role": "unknown"
        },
        "aggregateTags": [],
        "dps": {
            "1439790083": 1,
            "1439790143": 1,
        }
    }
]

I want to see a response like this:

[
    {
        "metric": "system.healthy",
        "tags": {
            "index": "0",
            "job": "etcd_z1|etcd_z2",
            "role": "unknown"
        },
        "aggregateTags": [],
        "dps": {
            "1439790128": 2,
            "1439790188": 2,
         }
    }
]
aleyandre commented 9 years ago

Hi Gaos,

I was watching this thread hoping somebody more able than I would respond. I haven't found a way to do that with the stable version, however with 2.2 it is quite easy using filters, e.g. : [CODE]

"start": 1389953499,
"end": 1418811099,
"queries": [
    {
        "aggregator": "avg",
        "metric": "env.indoor.temperature",
        "downsample": "1d-avg",
        "rate": "false",
        "filters": [
         {
            "type": "literal_or",
            "tagk": "srcid",
            "filter":"38|39",
            "groupBy": false
         }
        ]
    }
]

}

[/CODE]

If you change groupBy to true, you will get two separate series instead of one.

Regards,

Alex

manolama commented 9 years ago

@gaos1, @aleyandre is right, if that's all you're looking to do then use the new Filters method and you'll get the aggregate. We just can't do cross-metric aggregations yet.

gaos1 commented 9 years ago

Thank you. It seems groupBy can meet our requirements. We are using 2.1. and we will upgrade it to 2.2 for testing.

On Thu, Aug 27, 2015 at 12:41 PM, Chris Larsen notifications@github.com wrote:

@gaos1 https://github.com/gaos1, @aleyandre https://github.com/aleyandre is right, if that's all you're looking to do then use the new Filters method and you'll get the aggregate. We just can't do cross-metric aggregations yet.

— Reply to this email directly or view it on GitHub https://github.com/OpenTSDB/opentsdb/issues/546#issuecomment-135288846.

gaos1 commented 9 years ago

per your estimation, when will 2.2 be released?

On Thu, Aug 27, 2015 at 2:11 PM, Simon Gao sgao@pivotal.io wrote:

Thank you. It seems groupBy can meet our requirements. We are using 2.1. and we will upgrade it to 2.2 for testing.

On Thu, Aug 27, 2015 at 12:41 PM, Chris Larsen notifications@github.com wrote:

@gaos1 https://github.com/gaos1, @aleyandre https://github.com/aleyandre is right, if that's all you're looking to do then use the new Filters method and you'll get the aggregate. We just can't do cross-metric aggregations yet.

— Reply to this email directly or view it on GitHub https://github.com/OpenTSDB/opentsdb/issues/546#issuecomment-135288846.

manolama commented 9 years ago

I'm spending all weekend on it so as soon as I fix the last query bug I'll cut an RC.

johann8384 commented 8 years ago

2.2 is out, as most people know obviously. 2.3 has expressions like sum() and will be an RC soonish.

http://opentsdb.net/docs/build/html/api_http/query/exp.html

We can probably close this @manolama

IDerr commented 7 years ago

@manolama You can close this as said @johann8384