简体   繁体   English

如何在Stackdriver Logging上禁用来自k8s_cluster的日志?

[英]How to disable logs from k8s_cluster on Stackdriver Logging?

We have a Google Coud Platform project where we use a cluster to deploy our apps, we have noticed on our billing this month that Stackdriver Logging increased too much so we started to create exclusions. 我们有一个Google Coud Platform项目,在该项目中我们使用群集来部署应用程序,我们在本月的账单中注意到Stackdriver Logging增加太多,因此我们开始创建排除项。

We excluded logs from resource.type="container" without any problem, but we are not able to do it from resource.type="k8s_cluster" 我们没有任何问题地将日志从resource.type="container"排除, 但是我们无法从 resource.type="k8s_cluster"

filter to create our desired exclusion: 过滤以创建所需的排除项:

resource.type="k8s_cluster"
protoPayload.serviceName="k8s.io"
protoPayload.resourceName="app.k8s.io/v1beta1/namespaces/default/applications/prometheus-1"

A curious thing is that Stackdriver Monitoring doesn't detect any data (0B ingested) from there, neither from our gcp-project ( https://console.cloud.google.com/logs/usage?project=xxxx ) unless we filter it using the logs viewer, then we can see the logs. 奇怪的是,除非我们过滤,否则Stackdriver Monitoring不会从那里检测到任何数据(提取的0B) ,也不会从我们的gcp-project( https://console.cloud.google.com/logs/usage?project=xxxx )中检测到任何数据使用日志查看器,那么我们可以看到日志。

Grafana is able to detect the data with Stackdriver Datasource, you can see it here Grafana能够使用Stackdriver Datasource检测数据,您可以在此处查看

The filter for resource.type="k8s_cluster" contains Audit Logs for System Events that are always enabled, hence, they won't be excluded from Stackdriver Logging unlike resource.type="container" that only has container stdout and stderr logging. resource.type="k8s_cluster"的筛选器包含始终启用的系统事件的审核日志,因此,与只有容器stdout和stderr日志记录的resource.type="container"不同,它们不会从Stackdriver Logging中排除。

Furthermore, you can determine which logs belong to the Audit Logs stream by adding the '@type' condition to your Stackdriver filter: 此外,您可以通过在Stackdriver过滤器中添加'@type'条件来确定哪些日志属于Audit Logs流:

resource.type="k8s_cluster"
protoPayload.serviceName="k8s.io"
protoPayload.resourceName="app.k8s.io/v1beta1/namespaces/default/applications/prometheus-1"
protoPayload."@type"="type.googleapis.com/google.cloud.audit.AuditLog"

Finally, Grafana is able to display these log-based metrics since they're exported into it via Datasource instead of going into Stackdriver. 最后,Grafana能够显示这些基于日志的指标,因为它们是通过数据源而不是通过Stackdriver导出到其中的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM