安装在 VM 上的 GCP stackdriver-agent 每分钟发送一次奇怪的日志

Posted

技术标签:

【中文标题】安装在 VM 上的 GCP stackdriver-agent 每分钟发送一次奇怪的日志【英文标题】:GCP stackdriver-agent installed on VM send strange logs every minute 【发布时间】:2020-09-01 21:21:36 【问题描述】:

请您帮我解决以下问题。

我在 node.js 上有一个后端服务 我将它部署在 GCE VM 上。 它工作正常,但在安装日志记录和监控代理后,我在日志查看器中看到非常奇怪的日志。我查看了生成该日志的付费。它是 stackdriver-agent。

这是他们:

A 2020-05-15T22:45:26Z write_gcm: can not take infinite value
A 2020-05-15T22:45:26Z write_gcm: wg_typed_value_create_from_value_t_inline failed for swap/percent/value! Continuing. 
A 2020-05-15T22:45:26Z write_gcm: can not take infinite value 
A 2020-05-15T22:45:26Z write_gcm: wg_typed_value_create_from_value_t_inline failed for swap/percent/value! Continuing. 
A 2020-05-15T22:45:26Z write_gcm: can not take infinite value 
A 2020-05-15T22:45:26Z write_gcm: wg_typed_value_create_from_value_t_inline failed for swap/percent/value! Continuing. 
A 2020-05-15T22:45:28Z write_gcm: Server response (CollectdTimeseriesRequest) contains errors:#012#012  "payloadErrors": [#012    #012      "error": #012        "code": 3,#012        "message": "Unsupported collectd plugin/type combination: plugin: \"processes\" type: \"io_octets\""#012      #012    ,#012    #012      "index": 5,#012      "error": #012        "code": 3,#012        "message": "Unsupported collectd plugin/type combination: plugin: \"processes\" type: \"io_octets\""#012      #012    ,#012    #012      "index": 10,#012      "error": #012        "code": 3,#012        "message": "Unsupported collectd plugin/type combination: plugin: \"processes\" type: \"io_octets\""#012      #012    ,#012    #012      "index": 15,#012      "error": #012        "code": 3,#012        "message": "Unsupported collectd plugin/type combination: plugin: \"processes\" type: \"io_octets\""#012      #012    ,#012    #012      "index": 20,#012      "error": #012        "code": 3,#012        "message": "Unsupported collectd plugin/type combination: plugin: \"processes\" type: \"io_octets\""#012      #012    ,#012    #012      "index": 25 
A 2020-05-15T22:45:29Z write_gcm: Server response (CollectdTimeseriesRequest) contains errors:#012#012  "payloadErrors": [#012    #012      "error": #012        "code": 3,#012        "message": "Unsupported collectd plugin/type combination: plugin: \"processes\" type: \"io_octets\""#012      #012    #012  ]#012 
A 2020-05-15T22:45:29Z write_gcm: Unsuccessful HTTP request 400: #012  "error": #012    "code": 400,#012    "message": "Field timeSeries[3].points[0].interval.start_time had an invalid value of \"2020-05-15T15:45:27.348251-07:00\": The start time must be before the end time (2020-05-15T15:45:27.348251-07:00) for the non-gauge metric 'agent.googleapis.com/agent/api_request_count'.",#012    "status": "INVALID_ARGUMENT"#012  #012 
A 2020-05-15T22:45:29Z write_gcm: Error talking to the endpoint. 
A 2020-05-15T22:45:29Z write_gcm: wg_transmit_unique_segment failed. 
A 2020-05-15T22:45:29Z write_gcm: wg_transmit_unique_segments failed. Flushing. 

所以,每分钟我都会看到这样的日志出现。 当我停止 stackdriver-agent 服务时,它们消失了。 我的项目中有 4 个虚拟机。只有其中两个出现这样的问题 在 Cent OS7 虚拟机和 Ubuntu 18 虚拟机上

【问题讨论】:

但是,错误并不意味着代理有问题。 错误有“不成功HTTP request 400"和here” 我在基于 CentOS7 的镜像和最新的 v6.0.2 监控代理中出现了相同的日志 我建议您可以创建一个PIT,这样支持工程师可以适当地解决问题 在 Debian 9 上看到这个 【参考方案1】:

目前有 2 个 PIT:

https://issuetracker.google.com/issues/160340568 https://issuetracker.google.com/issues/161054680

最后一个有谷歌工程师对错误400的解释:

这些消息令人讨厌但无害。您不会丢失任何指标。您可以放心地忽略这些日志。

根本原因是服务器端配置更改并影响所有代理。该更改仅影响响应的详细程度,而不影响请求的处理。一些传入的指标在该更改之前被静默删除,现在被嘈杂地删除。

这些指标默认由上游 collectd 插件发送,我们没有任何控制措施可以完全阻止这些指标被发送。日志垃圾邮件消息来自 collectd 对这些指标的内部处理。

如果您想过滤掉您看到的所有嘈杂的日志,您可以创建一个 Log Exclusion[1][2] 或 Log Sink[3][4]。日志排除会将日志与指定的过滤器匹配,并在它们进入之前将它们从日志查看器中删除,而日志接收器将获取日志并将它们定向到存储桶、大查询表或 PubSub 主题。

[1]https://cloud.google.com/logging/docs/exclusions#overview [2]https://cloud.google.com/logging/docs/exclusions#create-filter [3]https://cloud.google.com/logging/docs/export [4]https://cloud.google.com/logging/docs/export/configure_export_v2

关于swap有一篇博文:

https://myshittycode.com/2020/06/13/gcp-stackdriver-agent-write_gcm-can-not-take-infinite-value-error/

出现此错误是因为 VM 实例没有交换内存,因此此指标插件尝试除以 0。

要解决此问题,请删除此配置并重新启动 stackdriver-agent

【讨论】:

以上是关于安装在 VM 上的 GCP stackdriver-agent 每分钟发送一次奇怪的日志的主要内容,如果未能解决你的问题,请参考以下文章

在stackdriver上监视VM进程

如何使用 API 或 Terraform 模板在 GCP 中创建 StackDriver 工作区

Stackdriver GCP 中的日志保留

使用 Python 查询 GCP Stackdriver 日志

.NetCore 日志在 GCP Stackdriver 中输出错误的严重性

GCP 中 Stackdriver 中的 DialogFlow 日志没有 json_payload