Time Series Insights Gen 2 - how to call Get Events with tsiClient,,server.GetEvents

307 views Asked by At

I am trying to use my own tsi environment Gen2 to simply return data from my own environment.

In Postman I can use this query to return data

{
  "getEvents": {
    "searchSpan": {
      "from": "2020-09-26T00:00:00Z",
      "to": "2020-09-29T20:00:00Z"
    },
    "timeSeriesId": [
      "10"
    ]
  }
}

whats the equivalent using tsiClient.server.getEvents? I've tried

authContext.getTsiToken().then(function(token){
                    
   tsiClient.server.getEvents(token, 'xxxxx.env.timeseries.azure.com', ???what goes here???,  {}, startDate, endDate).then(function (events) {
                        
   console.log(events)
  });
}); 

I am sure I am missing the timeSeriesId somewhere in the call to getEvent!!!

1

There are 1 answers

3
Matt Darsney On

It will be an array that looks just like what you give to Postman (the SDK will batch the calls for you internally, so you can do requests for multiple timeSeriesIds or time ranges)

So this is the appropriate thing to place in ???what goes here???

[{
  "getEvents": {
    "searchSpan": {
      "from": "2020-09-26T00:00:00Z",
      "to": "2020-09-29T20:00:00Z"
    },
    "timeSeriesId": [
      "10"
    ]
  }
}]

Give that a shot and lemme know how it works. Thanks!