如何将自定义属性添加到opentelemetry hostmetricsReceiver

发布于 2025-02-12 17:43:29 字数 2459 浏览 4 评论 0原文

我正在使用opentelemetry collector contermetmetricsReceiver https://github.com/open-telemetry/opentelemetry-collector-collector-contrib/tree/main/main/receiver/hostmetricsreceiver

我对这一过程特别感兴趣,所以我的Otel-Config看起来像这样:

receivers:
  hostmetrics:
    collection_interval: 1m
    scrapers:
      process:

processors:
  batch:

exporters:
  logging:
    loglevel: debug

service:
  pipelines:
    metrics:
      receivers: [ hostmetrics ]
      exporters: [ logging ]

现在,当前的配置为我提供了每个过程的以下资源级别属性:

        "attributes": [
          {
            "key": "process.pid",
            "value": {
              "intValue": "1"
            }
          },
          {
            "key": "process.executable.name",
            "value": {
              "stringValue": "api-server"
            }
          },
          {
            "key": "process.executable.path",
            "value": {
              "stringValue": "/bin/bash"
            }
          },
          {
            "key": "process.command",
            "value": {
              "stringValue": "/bin/bash"
            }
          },
          {
            "key": "process.command_line",
            "value": {
              "stringValue": "/bin/bash /usr/bin/api-server start"
            }
          },
          {
            "key": "process.owner",
            "value": {
              "stringValue": "root"
            }
          }
        ]

现在,我们要说,我想要要在此处添加过程启动时间作为新属性。我该怎么做?

我读过 https://github.com/open-telemetry/opentelemetry-collector-collector-contrib/tree/main/main/processor/attributesprocessor https://github.com/open-telemetry/opentelemetry-collector-collector-contrib/tree/main/main/main/receiver/hostmetreicsreceiver

但是,我想这些处理器只能帮助我添加具有固定的静态值。

我可以将这些处理器用于我的用户酶吗? 如何在现有接收器中添加此类属性?

I am using Opentelemetry Collector Contrib's hostmetricsreceiver
https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/hostmetricsreceiver

I am specifically interested in the process scraper, so my otel-config looks like this :

receivers:
  hostmetrics:
    collection_interval: 1m
    scrapers:
      process:

processors:
  batch:

exporters:
  logging:
    loglevel: debug

service:
  pipelines:
    metrics:
      receivers: [ hostmetrics ]
      exporters: [ logging ]

Now, current configuration gives me following Resource level attributes for each process :

        "attributes": [
          {
            "key": "process.pid",
            "value": {
              "intValue": "1"
            }
          },
          {
            "key": "process.executable.name",
            "value": {
              "stringValue": "api-server"
            }
          },
          {
            "key": "process.executable.path",
            "value": {
              "stringValue": "/bin/bash"
            }
          },
          {
            "key": "process.command",
            "value": {
              "stringValue": "/bin/bash"
            }
          },
          {
            "key": "process.command_line",
            "value": {
              "stringValue": "/bin/bash /usr/bin/api-server start"
            }
          },
          {
            "key": "process.owner",
            "value": {
              "stringValue": "root"
            }
          }
        ]

Now, let us say, I want to add process start time as a new attribute here. How can I do that ?

I read about https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/attributesprocessor and
https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/hostmetricsreceiver

But, I guess these processors can only help me for adding attributes having fixed or static values.

Can I use these processors for my usecase ?
How do I approach adding such attributes in existing receivers ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文