cloudwatch sdk cannot get request-id #2027
Unanswered
jinleileiking
asked this question in
Q&A
Replies: 2 comments
-
c.GetQueryResults |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @jinleileiking , Since you haven't shared any information I'm not able to tell why retrieving requestID is failing for you. Maybe you are hitting a different error and not error handling it? I am able to successfully get the request ID from Cloudwatch: package main
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
"log"
)
func main() {
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-east-1"))
if err != nil {
log.Fatalf("unable to load SDK config, %v", err)
}
client := cloudwatchlogs.NewFromConfig(cfg)
startQueryOutput, err := client.StartQuery(context.TODO(), &cloudwatchlogs.StartQueryInput{
EndTime: aws.Int64(1655054117),
QueryString: aws.String("fields @timestamp"),
StartTime: aws.Int64(1654708517),
LogGroupName: aws.String("/aws/rds/cluster/foo/bar"),
})
if err != nil {
panic(err)
}
resultsOutput, err := client.GetQueryResults(context.TODO(), &cloudwatchlogs.GetQueryResultsInput{QueryId: startQueryOutput.QueryId})
if err != nil {
panic(err)
}
requestID, ok := middleware.GetRequestIDMetadata(resultsOutput.ResultMetadata)
if !ok {
fmt.Println("RequestID not included with request")
}
fmt.Printf("RequestID: %s\n", requestID)
}
// Output:
// RequestID: 310c****-****-****-****-************ Let me know if this helps. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I check https://aws.github.io/aws-sdk-go-v2/docs/making-requests/#response-metadata , s3 is ok, but cloudwatch failed.
Beta Was this translation helpful? Give feedback.
All reactions