grafana / grafana-iot-twinmaker-app

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

Custom component showing duplicate records when streaming is enabled for the panel #263

Closed babakc closed 8 months ago

babakc commented 8 months ago

What happened: When i enable streaming for the panel for a query with a custom component (fetching from DynamoDB), it duplicates already fetched records with every poll which can be seen when switching the panel visualisation to a table view.

What you expected to happen: No duplicate records, which is the case with Sitewise components.

How to reproduce it (as minimally and precisely as possible):

  1. Create a custom component fetching data from DynamoDB. I followed the steps in this blog: https://aws.amazon.com/blogs/iot/own-data-source-aws-iot-twinmaker/
  2. Create a query for the data in Grafana, enable stream and set the interval to 5s. The data will duplicate with every 5s poll as per the screenshot.

image

Anything else we need to know?:

Environment:

idastambuk commented 8 months ago

Hi @babakc just submitted a PR that will help with this. Keep in mind you will also need to adjust your data reader Lambda to query

 ':startTime': new Date(startTime).getTime() + 1

or something similar, since in KeyConditionExpression: thingName = :hashKey AND #tmsp BETWEEN :startTime AND :endTime, the "between" includes the startTime