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

Get latest collected data for an instance based on timestamp? #31

Open
MichalLechowski opened this issue Feb 25, 2021 · 0 comments
Open

Comments

@MichalLechowski
Copy link

MichalLechowski commented Feb 25, 2021

Is it possible to query a single TimeSeriesId with something like filter max($event.timestamp) to get only the latest collected data (measurements from a single sensor)? I don't have any environment, we're just making a proof of concept through Postman to check if we can make the same queries as we do in current CosmosDb environment.

The model is for instance something like that, the sensor is feeding the data every 2 minutes and I need only the last measurement:
image

Is that currently possible?

UPDATE/

I have found one way to do it. The request is for aggregateSeries:

  "aggregateSeries": {
    "timeSeriesId": [
          null, "4B6F6C6F00856F5A"
    ],
    "searchSpan": {
      "from": "2021-02-22T00:00:00Z",
      "to": "2021-02-26T23:59:59Z"
    },
    "interval": "P1M",
    "inlineVariables": {
      "temps": {
        "kind": "numeric",
        "value": {
          "tsx": "$event.object.temp.Double"
        },
        "filter": null,
        "aggregation": {
          "tsx": "last($value)"
        }
      }
    },
    "projectedVariables": [
      "temps"
    ]
  }
} 

As long as I make the interval 'wider' than the searchspan, I can retrieve the last value using aggregate last(value).
Is it the optimal way, tho? Also this method requires to last(value) every measured property I need to collect which is doable but not very convenient.

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