-
Notifications
You must be signed in to change notification settings - Fork 849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AmazonCloudWatchLogsClient.ListAnomaliesAsync throws Amazon.Runtime.AmazonClientException: We expected a VALUE token but got: ObjectStart #3205
Comments
Do you see the same error when using the AWS CLI? For example: |
Hi @dscpinheiro. Thanks for your reply. My assumption is that this method has been hidden entirely? |
No, the API is public but it was released recently, during last year's re:Invent: https://github.com/aws/aws-sdk-net/blob/main/changelogs/SDK.CHANGELOG.2023.md#376930-2023-11-27-0424-utc. It's available in the last version of the CLI, so you may have to update your version:
|
@danispir Can you enable response logging by adding the following code at the startup of your test application and share the response JSON from the call. Be sure to redact anything sensitive in the response.
|
Hello @normj. Below is the output I get. Since it seems that I do get the response, could be a deserialization issue when trying to deserialize LogSamples array of objects?
|
@danispir Thanks for the log. Unfortunately it cut off the response payload at 1K and I think we are missing the part that the unmarshaller is having a problem. Can you add the following line increase the size of the response payload logging?
|
I increased it to 20_000_000.
|
@danispir Thanks for the bigger snippet. The |
P120800175 |
@danispir Could you test with the new version of the CloudWatch package that was just released? https://www.nuget.org/packages/AWSSDK.CloudWatchLogs/3.7.305 It includes an update to the |
Hi @dscpinheiro. I can confirm that with the latest version it is working. Thanks everyone for your support! I would like to point another thing, but is not related in this case to AWS SDK, because it's behaving the same when running through aws cli command line. Maybe somebody can pass this information to CloudWatch logs team. When executing list anomalies, there is LogSamples array which contains messages and templates. If the message is above a specific length, it is truncated. This is a bit frustrating for us developers. However, in the browser on AWS Console, when navigating the anomalies page in CloudWatch, log samples tab displays entire message. One work around is to take the timestamp and execute some requests over CloudWatch logs in order to fetch entire message. But of course, this implies other API calls on our side, which increases execution time when we have large amount of log data. |
Glad that resolved your issue, I'll pass the feedback to the CloudWatch team. |
Comments on closed issues are hard for our team to see. |
Describe the bug
Hello,
On our AWS business account we have Log Groups created to group various logs coming from our services. One of the log group has Anomaly Detector set to ON.
In our code repository, we want to implement a .NET 8 Micro-Service that pulls Log Anomalies from a specified Anomaly Detector ARN.
We have the following setup:
TargetFramework: net8.0
We are using latest nuget packages:
AWSSDK.CloudWatch Version="3.7.302.5"
AWSSDK.CloudWatchLogs Version="3.7.304.7"
We have created properly a IAM user with correct rights and we are executing the following code:
var cloudWatchClient = new AmazonCloudWatchClient(credentials, Amazon.RegionEndpoint.MY_REGION_HERE);
var result = await client.ListAnomaliesAsync(new ListAnomaliesRequest { AnomalyDetectorArn = serverArn, Limit = 10, });
serverArn is valid ARN from our subscription.
The above code throws the following exception: Amazon.Runtime.AmazonUnmarshallingException
With the following message:
Error unmarshalling response back from AWS. Request ID: 9*****-ffd8ed4093b7, Last Parsed Path: /anomalies//logSamples//, HTTP Status Code: 200 OK**
And this stacktrace
$>d__0.MoveNext() in D:\ZCode\AwsAnomaliesDetector\Program.cs:line 71at Amazon.Runtime.Internal.Transform.JsonResponseUnmarshaller.Unmarshall(UnmarshallerContext input)
at Amazon.Runtime.Internal.Transform.ResponseUnmarshaller.UnmarshallResponse(UnmarshallerContext context)
at Amazon.Runtime.Internal.Unmarshaller.UnmarshallResponse(UnmarshallerContext context, IRequestContext requestContext)
at Amazon.Runtime.Internal.Unmarshaller.d__5.MoveNext()
at Amazon.Runtime.Internal.Unmarshaller.d__3
1.MoveNext() at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__5
1.MoveNext()at Amazon.Runtime.Internal.ErrorHandler.d__5
1.MoveNext() at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9
1.MoveNext()at Amazon.Runtime.Internal.Signer.d__1
1.MoveNext() at Amazon.Runtime.Internal.EndpointDiscoveryHandler.<InvokeAsync>d__2
1.MoveNext()at Amazon.Runtime.Internal.EndpointDiscoveryHandler.d__2
1.MoveNext() at Amazon.Runtime.Internal.CredentialsRetriever.<InvokeAsync>d__7
1.MoveNext()at Amazon.Runtime.Internal.RetryHandler.d__10
1.MoveNext() at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10
1.MoveNext()at Amazon.Runtime.Internal.CallbackHandler.d__9
1.MoveNext() at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9
1.MoveNext()at Amazon.Runtime.Internal.ErrorCallbackHandler.d__5
1.MoveNext() at Amazon.Runtime.Internal.MetricsHandler.<InvokeAsync>d__1
1.MoveNext()at Program.<
And this inner exception:
We expected a VALUE token but got: ObjectStart
If a call method ListAnomaliesAsync without any ARN specified, I get the same exception and stacktrace as above.
If I call other methods such as ListLogAnomalyDetectorsAsync or GetLogAnomalyDetectorAsync I do get successful results.
I tried also AWS Support Central, however they don't provide code assistance.
Any help will be much appreciated.
Expected Behavior
I should receive a successful response as described in this document
https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_ListAnomalies.html
Current Behavior
AmazonCloudWatchLogsClient.ListAnomaliesAsync throws Amazon.Runtime.AmazonClientException: We expected a VALUE token but got: ObjectStart
Reproduction Steps
Specified in bug description.
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.CloudWatchLogs 3.7.304.7
Targeted .NET Platform
.NET 8
Operating System and version
Windows 10/11, Linux
The text was updated successfully, but these errors were encountered: