grafana / grafana-iot-twinmaker-app

AWS IoT TwinMaker Application Plugin for Grafana
Apache License 2.0
19 stars 14 forks source link

Support for `interval` #63

Open massi-ang opened 2 years ago

massi-ang commented 2 years ago

Use case: when querying data over long date ranges, it is useful to reduce the data granularity to avoid getting more data than what can be displayed. Grafana calculates an interval property that can be used at that effect, indicating the minimum time range each returned data point should represent. This is for example supported by Timestream plugin ($__interval).

When looking at the request that is sent to my connector by TwinMaker plugin, I cannot find any field being populated with the value of the interval calculated by Grafana based on the time range and graph width. Is it supported?

Since the TwinMaker request object contains the following property I would expect to find the Grafana computed interval populated.

{ "interpolation": { "intervalInSeconds": long, "interpolationType": string}

msshui-amzn commented 2 years ago

The idea is we want to pass the above in the query parameters to the core API.

The core API already has those parameters and is ready to receive them.

msshui-amzn commented 2 years ago

There is a backlog item created for supporting interpolation within sitewise 1p. Currently what customer can do is to implement interpolation in their lambda connector. And Linear interpolation is supported. API doc https://docs.aws.amazon.com/iot-twinmaker/latest/apireference/API_GetPropertyValueHistory.html#tm-GetPropertyValueHistory-request-interpolation https://docs.aws.amazon.com/iot-twinmaker/latest/guide/data-connector-interfaces.html#DataReaderByEntity-connector

massi-ang commented 2 years ago

I am not sure I follow: of course I can implement the interpolation logic in my connector, but currently there is no interpolation structure provided in the event that is sent to my connector lambda.

msshui-amzn commented 2 years ago

Hi @massi-ang ,

You are quite right. We, the Twinmaker Grafana team, need to update the plugin to set the interpolation parameters in the request sent. Will try and get this work prioritised.