标签: google-cloud-ops-agent

如何让 google-cloud-ops-agent 日志记录识别特殊的“严重性”字段

我正在 google 计算实例上运行 ZooKeeper 并尝试设置 google-cloud-ops-agent 以正确解析日志。我已经完成了大部分工作,但很难让它识别该severity区域。

文档指出这severity是一个将从 中提取的特殊字段jsonPayload,但我没有看到这种情况发生。

我的/etc/google-cloud-ops-agent/config.yaml

logging:
  receivers:
    zookeeper:
      type: files
      include_paths:
      - /zookeeper/logs/zookeeper.log
  processors:
    zookeeper:
      type: parse_regex
      field: message
      regex: '^(?<time>.{23}) \[(?<zknode>[^\]]+)] - (?<severity>\S+)\s+ \[(?<class>[^\]]+)] - (?<msg>.*)$'
      time_key: time
      time_format: "%Y-%m-%d %H:%M:%S,%L"
  service:
    pipelines:
      zookeeper:
        receivers: [zookeeper]
        processors: [zookeeper]
Run Code Online (Sandbox Code Playgroud)

证据 parse_regex 正常工作(但注意严重性仍然存在于jsonPayload

示例云日志记录输出

google-cloud-platform google-cloud-logging google-cloud-ops-agent

9
推荐指数
1
解决办法
2263
查看次数

GCP 计算引擎不会显示内存指标

我希望我的计算引擎 VM 在控制台中显示内存使用指标,我转到此页面并安装 Ops-Agents,重新启动服务并转到 VM 可观察性部分,但仍然看到一条消息,表明代理未安装(在内存使用指标): 在此输入图像描述 我想也许默认情况下没有安装内存使用情况(没有在任何地方提到,只是猜测),我需要修改配置。我转到此文档并将此代码添加到/etc/google-cloud-ops-agent/config.yaml

metrics:
  receivers:
    agent.googleapis.com/memory/bytes_used:
      type: hostmetrics
      collection_interval: 1m
Run Code Online (Sandbox Code Playgroud)

根据文档,当代理重新启动时,此配置将与内置配置合并。我重新启动代理服务,返回仪表板,但仍然显示消息“需要 Ops Agent”。我不知道我做错了什么,IMO 的文档对于该主题来说真的很差,我找不到任何有关如何打开内存使用指标的示例。

编辑 运行sudo systemctl status google-cloud-ops-agent"*" 我可以看到此错误消息:

otelopscol[2763]:2022-05-02T14:07:02.780Z#011error#011collector@v0.26.1-0.20220307211504-dc45061a44f9/metrics.go:235#011无法将时间序列导出到GCM#011{“错误”:“rpc错误:代码 = InvalidArgument desc = 名称必须以 '{resource_container_type}/{resource_container_id}' 开头,得到:projects/"}

EDIT2 如果我通过控制台单击“安装”,我会看到以下安装说明:

:> agents_to_install.csv && \
echo '"projects/<project>/zones/europe-west1-b/instances/<instance>","[{""type"":""ops-agent""}]"' >> agents_to_install.csv && \
curl -sSO https://dl.google.com/cloudagents/mass-provision-google-cloud-ops-agents.py && \
python3 mass-provision-google-cloud-ops-agents.py --file agents_to_install.csv
Run Code Online (Sandbox Code Playgroud)

它与这里的不同: https: //cloud.google.com/monitoring/agent/monitoring/installation#joint-install

curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
sudo bash add-monitoring-agent-repo.sh --also-install
Run Code Online (Sandbox Code Playgroud)

不确定安装了什么,两者都尝试了。

google-compute-engine google-cloud-platform google-cloud-ops-agent

5
推荐指数
1
解决办法
1349
查看次数

如何为 Google Cloud Ops Agent 编写自定义多行解析器

我正在尝试配置 google-cloud-ops-agent 以从应用程序收集日志记录。日志是一行或多行。

多行日志示例:

[2023-02-08 10:32:23] production.ERROR: App\Jobs\Message::handle (Symfony\\Component\\Mime\\Exception\\RfcComplianceException(code: 0): Email \"3712\" does not comply with addr-spec of RFC 2822. at /var/www/html/vendor/symfony/mime/Address.php:54)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/Message.php(244): Symfony\\Component\\Mime\\Address->__construct()
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/Message.php(108): Illuminate\\Mail\\Message->addAddresses()
[2023-02-08 20:53:30] production.ERROR: RuntimeException: User not found in /var/www/html/app/Services/UserService.php:82
Stack trace:
#0 /var/www/html/app/Services/UserService.php(63): App\Services\UserService->init()
#1 /var/www/html/app/Helpers/UserHelper.php(128): App\Services\UserHelper->__construct()
Run Code Online (Sandbox Code Playgroud)

我的配置如下:

logging:
  receivers:
    customFile:
      type: files
      include_paths:
      - /var/www/html/storage/logs/error.log
  processors:
    extract_structure:
      type: parse_regex
      field: message
      regex: "^\[(?<time>[\d-]*\s[\d:]*)\]\sproduction.(?<severity>[^ :]*):\s(?<message>[\s\S]*)$"
      time_key: time
      time_format: "%Y-%m-%d %H:%M:%S"
    move_severity:
      type: modify_fields
      fields:
        jsonPayload."logging.googleapis.com/severity":
          move_from: jsonPayload.severity
  service:
    pipelines:
      default_pipeline:
        receivers: …
Run Code Online (Sandbox Code Playgroud)

google-cloud-platform google-cloud-logging google-cloud-ops-agent

5
推荐指数
0
解决办法
395
查看次数