能从Logs Explorer中的Google Cloud Logging条目中提取特定信息吗?

huangapple go评论52阅读模式
英文:

Is it possible to extract particular information from Google Cloud Logging entries in the Logs Explorer?

问题

在GCP的Cloud Logging日志资源浏览器中,我从NGINX等地方获取到了这样的textPayload。现在我想要提取或至少突出显示特定部分,例如错误代码或响应时间。

23.23.23.23 - - [24/May/2023:13:41:49 +0000] "POST /api/my-endpoint HTTP/1.1" 502 186 "-" "Google-ActionsOnGoogle/1.0" 3309 1.905 [app-somewild-service-80] [] 10.2.124.159:8081 186 1.904 502 218057012395790

在日志资源浏览器中能够直接实现这个吗?

当然,我可以导出日志并在其他地方处理。

英文:

In the Logs Explorer of Cloud Loggging on the GCP I'm getting such textPayload here from NGINX for example. Now I would like to extract or at least highlight specific parts, e.g. error code or response time.

23.23.23.23 - - [24/May/2023:13:41:49 +0000] "POST /api/my-endpoint HTTP/1.1" 502 186 "-" "Google-ActionsOnGoogle/1.0" 3309 1.905 [app-somewild-service-80] [] 10.2.124.159:8081 186 1.904 502 218057012395790

Is this possible directly in the Logs Explorer?

Sure, I can export the logs and do it somewhere else.

答案1

得分: 1

你可以使用云日志中的基于日志的指标从日志条目的内容中提取指标数据。要搜索查询结果的内容,请在查询结果窗格中单击在结果中查找,然后输入您的搜索词。这个过滤器允许您在日志条目中查找信息,而无需构建新的查询。

例如,如果您想提取应用程序引擎指标的错误和时间戳,请在日志资源资源浏览器查询编辑器字段中编写一个表达式,然后单击运行查询。与您的查询匹配的日志会列在查询结果下。

您可以参考按Google云服务分组的查询

例如,以下是一天内的应用程序引擎日志表达式。

resource.type="gae_app" AND
severity>=ERROR AND
timestamp>="2023-05-24T00:00:00Z" AND timestamp<="2023-05-25T00:00:00Z"

在查询编辑器中输入此表达式,然后运行查询。您将在查询结果选项卡中找到所需的结果。

欲了解更多信息,您可以参考此文档

英文:

You can extract metric data from the content of log entries using Log-based metrics in cloud Logging. To search the contents of the Query results, click Find in results in the Query results pane, and then enter your search term. This filter lets you find information in your log entries without building a new query.

For example, if you want to extract error and timestamp of app engine metrics write an expression into the Logs Explorer query-editor field and click Run query. Logs that match your query are listed under Query results.

You can refer to the queries grouped by Google cloud services.

For example, below is the expression for App engine logs for one day.

resource.type=&quot;gae_app&quot; AND
severity&gt;=ERROR AND
timestamp&gt;=&quot;2023-05-24T00:00:00Z&quot; AND timestamp&lt;=&quot;2023-05-25T00:00:00Z&quot;

Type this expression in query-editor and run the query. You will find the desired results in the Query results tab.

For more information, you can refer to this document.

huangapple
  • 本文由 发表于 2023年5月25日 16:07:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76330142.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定