aws-samples / aws-serverless-connect-wallboard

Sample code for building a serverless wallboard for Amazon Connect.
MIT No Attribution
28 stars 18 forks source link

Specify Different Service Level #16

Closed Aikleong7 closed 1 year ago

Aikleong7 commented 1 year ago

Hello, I tried specifying different service level by using another lambda function with Eventbridge to run the lambda every min to update the service level data in the DynamoDB, however, data in the DynamoDB are refreshed every min?(I guess) is there a way to change the refresh timing of the data so that as the Lambda run to override the service level data will work.

Brettles commented 1 year ago

Any data that is in DynamoDB is returned to the "front end" (so, the browser the is rendering the wallboard table) - there's no caching there. If you look at the GetData() function at line 166 of render-wallboard.py just about the first thing it does is a scan of the DynamoDB table looking for data that is relevant to the wallboard.

If you're refreshing data in the table at a higher frequency then it should be returned during the render process.

On line 190 the data from the table is stored in memory - that'd be a good place to do a debug (print or something) to see whether it has been retrieved from the table.

Aikleong7 commented 1 year ago

I'm refreshing the data at the interval of 1 minute but there is like a 5-10second gap where the data is refreshed to 0. I override the default value of 0 for different service level where I think the data will refresh every 60 seconds which i cannot change that number and it will cause a 5-10 second gap where data is 0 instead of the data I override.

Brettles commented 1 year ago

Oh, I think I understand now. The service level is put into the database in the get-historical-metrics.py Lambda function. If you have a different function trying to set the same data then it could well get overwritten.

If you're setting the service level and you don't want it to come from the Connect historical metrics, then remove line 71 from get-historical-metrics.py - the code won't try and retrieve the data.

Do you want to also keep the Connect historical service level? Or are you completely replacing it with your own?

Aikleong7 commented 1 year ago

I'm completely replacing on my own using lambda function.

Brettles commented 1 year ago

Ok, no problems. If you remove line 71 then the function won't try and retrieve the historical metrics for service level and therefore won't overwrite the data from your Lambda function in the table.