Amazon.CloudWatch.Model.MetricDatum timestamp is not set correctly #3333
-
Describe the bugHello, I am trying to send multiple metrics to CloudWatch using AWSSDK.CloudWatch NuGet via PutMetricDataAsync. When accessing the AWS Console, the datapoints are set wrong, setting the graph time to "UTC timezone" will show me the datapoint as happening with 3 hours before the TimestampUtc I set in the code!!! Expected BehaviorTo see the datapoints I sent at the correct timestamp in the graph. Current BehaviorWhen accessing the AWS Console, the datapoints are set wrong, setting the graph time to "UTC timezone" will show me the datapoint as happening with 3 hours before the TimestampUtc I set in the code!!! Reproduction StepsTry sending a list of MetricDatum via PutMetricDataAsync function from AWSSDK.CloudWatch NuGet. Possible SolutionNo response Additional Information/ContextNo response AWS .NET SDK and/or Package version usedAWSSDK.CloudWatch 3.7.304.21 Targeted .NET Platform.NET 7 Operating System and versionWindows 10, Windows 11 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @mihneavelinOT, Thank you for reporting this issue. Can you confirm if your code follows the recommendations mentioned in this blog post, for handling UTC timestamp in SDK for .NET? This Blog post mentions about practices to follow to prevent any potential timezone ambiguity in the code. This would ensure that the time value is treated consistently as UTC, regardless of the local execution environment. Kindly share a code sample that I can use to reproduce this scenario, in case above recommendations doesn't work or won't apply to your use-case. Thank you! Regards, |
Beta Was this translation helpful? Give feedback.
-
Hi @bhoradc, Thank you so much!!! I will put my solution here, maybe it will help somebody else. Before:
After:
|
Beta Was this translation helpful? Give feedback.
-
Hello @mihneavelinOT, Glad to know that the blogpost helped. To help others who might be facing similar problems, I will move this Issue to the Regards, |
Beta Was this translation helpful? Give feedback.
Hi @bhoradc,
Thank you so much!!!
I will put my solution here, maybe it will help somebody else.
Before:
When inspecting
TimestampUtc
the date time seemed to be correct, but theDateTimeKind
was wrong!!!point.timestamp
is along
storing the utc timestamp in secondsAfter:
Notice the explicit specification of the
DateTimeKind
.