how to use query/expr to diff 2 timeseries groupBy id

43 views
Skip to first unread message

Dieter Cailliau

unread,
Sep 14, 2017, 6:41:46 AM9/14/17
to OpenTSDB
I have n x 2 timeseries: per id, i have 2 series: v=one and v=two.
There is 1 point per minute in each of these series (timestamp aligned).

I need a query that shows for each id, the difference (per timestamp) between the v=one and v=two series. It should output n timeseries (1 per id).

Is this the kind of problem that is to be solved with http://opentsdb.net/docs/build/html/api_http/query/exp.html ?

Below is my attempt to code this. Unfortunately this does not give me the right answer.

{
   "time": {
       "start": 1493596800,
       "end": 1493683200,
       "aggregator":"none"
   },
   "filters": [
       {
           "tags": [
               {
                   "type": "literal_or",
                   "tagk": "v",
                   "filter": "one",
                   "groupBy": false
               },
               {
                   "type": "wildcard",
                   "tagk": "id",
                   "filter": "*",
                   "groupBy": true
               }
           ],
           "id": "v1"
       },
       {
           "tags": [
               {
                   "type": "literal_or",
                   "tagk": "v",
                   "filter": "two",
                   "groupBy": false
               },
               {
                   "type": "wildcard",
                   "tagk": "id",
                   "filter": "*",
                   "groupBy": true
               }
           ],
           "id": "v2"
       }
   ],
   "metrics": [
       {
           "id": "v1",
           "metric": "x",
           "filter": "v1"
       },
       {
           "id": "v2",
           "metric": "x",
           "filter": "v2"
       }
   ],
   "expressions": [
       {
           "id": "delta",
           "expr": "v1-v2"
       }
      
    ],
    "outputs":[
      {"id":"delta", "alias":"delta"}
    ]
 }


ManOLamancha

unread,
Jan 29, 2018, 8:37:52 PM1/29/18
to OpenTSDB
On Thursday, September 14, 2017 at 3:41:46 AM UTC-7, Dieter Cailliau wrote:
I have n x 2 timeseries: per id, i have 2 series: v=one and v=two.
There is 1 point per minute in each of these series (timestamp aligned).

I need a query that shows for each id, the difference (per timestamp) between the v=one and v=two series. It should output n timeseries (1 per id).

Is this the kind of problem that is to be solved with http://opentsdb.net/docs/build/html/api_http/query/exp.html ?

Below is my attempt to code this. Unfortunately this does not give me the right answer.

Ah it almost works. The problem is that right now it joins across tags and since you're querying the same metric but with one tag being different, it won't join properly. I've addressed this in version 3 but I need to back-port a fix to 2.5 that will allow for explicit joins to solve your issue. 

ga...@ridezum.com

unread,
Jan 9, 2019, 3:24:45 PM1/9/19
to OpenTSDB
Is there any update to this? Did you mean 2.5? We're just on 2.4 now, any chance there's a back-port for 2.4? If not, I'm willing to do it, with some knowledge transfer.
Reply all
Reply to author
Forward
0 new messages