阅读CloudWatch日志查询状态在GO SDK V2中

发布于 2025-01-25 18:54:46 字数 722 浏览 4 评论 0原文

我正在通过V2 SDK运行CloudWatch日志查询。我已经成功地使用Startquery方法提交了查询,但是我似乎无法处理结果。

我在变量(queryID)中有查询ID,并且正在使用GetQueryResults方法如下:

    results, err := svc.GetQueryResults(context.TODO(), &cloudwatchlogs.GetQueryResultsInput{QueryId: queryId,})

我如何实际阅读内容?具体来说,我正在查看状态字段。如果我在命令行中运行查询,则将其作为字符串描述返回。根据SDK文档的说法,这是一种定制类型的“ querystatus”,该类型定义为枚举常数

我尝试过与常量名称进行比较,例如

if results.Status == cloudwatchlogs.GetQueryResultsOutput.QueryStatus.QueryStatusComplete

编译器不接受。如何引用常数或到达字符串值本身?

I'm running a CloudWatch log query through the v2 SDK for Go. I've successfully submitted the query using the StartQuery method, however I can't seem to process the results.

I've got my query ID in a variable (queryID) and am using the GetQueryResults method as follows:

    results, err := svc.GetQueryResults(context.TODO(), &cloudwatchlogs.GetQueryResultsInput{QueryId: queryId,})

How do I actually read the contents? Specifically, I'm looking at the Status field. If I run the query at the command line, this comes back as a string description. According to the SDK docs, this is a bespoke type "QueryStatus", which is defined as a string with enumerated constants.

I've tried comparing to the constant names, e.g.

if results.Status == cloudwatchlogs.GetQueryResultsOutput.QueryStatus.QueryStatusComplete

but the compiler doesn't accept this. How do I either reference the constants or get to the string value itself?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以歌曲疗慰 2025-02-01 18:54:46

querystatus类型是定义的在单独的类型软件包中。 GO SDK服务都是这样组织的。

import "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types"

if res.Status == types.QueryStatusComplete {
        fmt.Println("complete!")
}

The QueryStatus type is defined in the separate types package. The Go SDK services are all organised this way.

import "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types"

if res.Status == types.QueryStatusComplete {
        fmt.Println("complete!")
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文