0

I'm using TSI rest API to get aggregation data, when I request data for multiple months with interval of one month ("P1M"), it returns data with inconsistent plotting. Below is my request and response,

Request

{
    "aggregateSeries": {
        "interval": "P1M",
        "searchSpan": {
            "from": "2020-11-01T00:00:00Z",
            "to": "2020-12-31T23:59:59.999Z"
        },
        "timeSeriesId": [
            "MyTSIId"
        ],
        "projectedVariables": [
            "ResultSet"
        ],
        "inlineVariables": {
            "ResultSet": {
                "kind": "numeric",
                "value": {
                    "tsx": "$event.MyData.Double"
                },
                "filter": null,
                "interpolation": null,
                "aggregation": {
                    "tsx": "avg($value)"
                },
                "categories": null,
                "defaultCategory": null
            }
        }
    }
}

Response

{
    "timestamps": [
        "2020-10-03T00:00:00Z",
        "2020-11-02T00:00:00Z",
        "2020-12-02T00:00:00Z"
    ],
    "properties": [
        {
            "values": [
                null,
                2.8,
                null
            ],
            "name": "ResultSet",
            "type": "Double"
        }
    ],
    "progress": 100.0
}

If you look at TSI response it returns 3 records where as I requested data for only 2 months, also plotting of months starts from random date, it's not plotting either starts of month and also not based on from date in searchSpan.

+-----------------------------------------------------+
| TSI Response Plotting  | Expected Response Plotting |
+-----------------------------------------------------+
| "2020-10-03T00:00:00Z" |   "2020-11-01T00:00:00Z"   |
| "2020-11-02T00:00:00Z" |   "2020-12-01T00:00:00Z"   |
| "2020-12-02T00:00:00Z" |                            |
+-----------------------------------------------------+

Is it possible to get expected response from TSI, or is there any workaround, any help is appreciated.

Shri
  • 351
  • 3
  • 16
  • can you please validate if using Gen1 or Gen2 ? Thanks – asergaz Nov 18 '20 at 12:22
  • want also to make sure that you have same results when querying data for example from May to July? You have data for December 2020 already :) ? Also fyi: Interval size is specified in ISO-8601 duration format. All intervals are the same size. One month is always converted to 30 days! So it is expected that months with 31 days will not show accordingly... – asergaz Nov 18 '20 at 12:28

1 Answers1

4

This is by design in TSI. The behavior is explained here.

"For a specified search span and interval, this API returns an aggregated response per interval per variable for a Time Series ID. The number of intervals in the response dataset is calculated by counting epoch ticks (the number of milliseconds that have elapsed since Unix epoch - Jan 1st, 1970) and dividing the ticks by the interval span size specified in the query. The timestamps returned in the response set are of the left interval boundaries, not of the sampled events from the interval."

This is a known issue and something that TSI has in it's backlog to fix! You can vote on the Feedback item here.

Shreya Sharma
  • 306
  • 1
  • 3