如何编写堆栈驱动程序日志查询,对返回的所有日志中的 5% 进行采样?

How do I write a stack driver log query that samples 5% of all logs returned?

我一直读到我可以编写一个日志查询来对一定百分比的日志进行采样,但我发现了零个示例。

https://cloud.google.com/blog/products/gcp/preventing-log-waste-with-stackdriver-logging\ You can also choose to sample certain messages so that only a percentage of the messages appear in Stackdriver Logs Viewer

如何通过日志查询获取所有 GCE 负载均衡器日志的 10%?我知道我可以在后端配置它,但我不想那样。我想在 stackdriver 中获取 100% 的日志并创建一个 pub/sub 带有日志查询的日志接收器,该日志查询仅捕获其中的 10% 并将这些采样日志发送到其他地方。

我怀疑您想要为日志路由器创建一个 Pub/Sub 接收器。参见 Configure and manage sinks

使用Google的日志查询,可以使用sample过滤(包含)日志。