如何将自定义属性添加到opentelemetry hostmetricsReceiver
我正在使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论