Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with sampling during querying with aggregates and descending order #687

Open
ramazanyich opened this issue Feb 16, 2024 · 0 comments

Comments

@ramazanyich
Copy link

ramazanyich commented Feb 16, 2024

Discovered an issue with result of querying from kairosdb. I need to get last x items from the timeseries DB for a defined timerange and perform aggregation of returned datapoints with sampling of 1 second on this aggregates.
Then I do query using default ascending order response is correctly constructed with correctly sampled datapoints per second.
But it I set order to descending, when sampling is broken: aggregation performed on all data and set to last sampled period.
Below are the example datapoints and queries.
Created 4 datapoints using following REST API call:

curl -v -X POST -d '[ {                                                                                                                                                                               base 10:15:39
  "name" : "my.new.metric2x",     
  "tags" : {     
    "a" : "b"                      
  },                   
  "type" : "long",   
  "value" : 1,      
  "timestamp" : 238433400000
}, {                      
  "name" : "my.new.metric2x",
  "tags" : {                    
    "a" : "b"                 
  },    
  "type" : "long",
  "value" : 3,                 
  "timestamp" : 238433400999                                   
}, {
  "name" : "my.new.metric2x",
  "tags" : {
    "a" : "b"
  },
  "type" : "long",
  "value" : 5,
  "timestamp" : 238433401000
}, {
  "name" : "my.new.metric2x",
  "tags" : {
    "a" : "b"
  },
  "type" : "long",
  "value" : 7,
  "timestamp" : 238433401999
} ]'  http://127.0.0.1:8080/api/v1/datapoints

then perform query using default order:

curl -v -X POST -d '{                                                                                                                                                                         ✘ INT   base 10:17:37
  "start_absolute" : 238433400000,
  "metrics" : [ {
    "name" : "my.new.metric2x",    
    "aggregators" : [ {
      "name" : "sum",
      "sampling" : {
        "value" : "1",
        "unit" : "seconds"
      },
      "align_start_time" : true,
      "align_sampling" : false
    } ] 
  } ],
  "end_absolute" : 238433402000
}'  http://127.0.0.1:8080/api/v1/datapoints/query

and got expected result with correctly sampled aggregation:

{"queries":[{"sample_size":4,"results":[{"name":"my.new.metric2x","group_by":[{"name":"type","type":"number"}],"tags":{"a":["b"]},"values":[[238433400000,4],[238433401000,12]]}]}]}

but if I set order to desc:

curl -v -X POST -d '{                                                                                                                                                                                 base 10:17:43
  "start_absolute" : 238433400000,
  "metrics" : [ {
    "name" : "my.new.metric2x",
    "aggregators" : [ {
      "name" : "sum",
      "sampling" : {
        "value" : "1",
        "unit" : "seconds"
      },
      "align_start_time" : true,
      "align_sampling" : false
    } ],
    "order" : "desc"
  } ],                         
  "end_absolute" : 238433402000                                
}'  http://127.0.0.1:8080/api/v1/datapoints/query

then I got following response:

{"queries":[{"sample_size":4,"results":[{"name":"my.new.metric2x","group_by":[{"name":"type","type":"number"}],"tags":{"a":["b"]},"values":[[238433401000,16]]}]}]}

as you can see the aggregation does not have samping per second and all aggregation happened on all data and put on the last samping period.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant