首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Telegraf & InfluxDB:如何将PROCSTAT的pid从字段转换为标记?

Telegraf & InfluxDB:如何将PROCSTAT的pid从字段转换为标记?
EN

Stack Overflow用户
提问于 2020-09-02 01:22:37
回答 1查看 1.4K关注 0票数 0

摘要:--我正在使用telegraf将procstat导入InfluxDB。我想把pid从一个整数字段转换成一个标签,这样我就可以在内流中对它进行分组。

详细信息:经过大量搜索后,我在某个站点上找到了以下内容,但它似乎在做相反的事情(将标记转换为字段)。我不知道如何从它推断相反的转换语法:

代码语言:javascript
复制
[processors]
[[processors.converter]]
namepass = [ "procstat",]

[processors.converter.tags]
string = [ "cmdline",]

我用的是1.7.9

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-19 13:47:25

要将pid转换为标记的正确处理器配置如下。

代码语言:javascript
复制
[processors]
  [[processors.converter]]
     namepass = [ "procstat"]

  [processors.converter.fields]
     tag = [ "pid"]

请参阅转换器处理器插件https://github.com/influxdata/telegraf/tree/master/plugins/processors/converter的文档。

在telegraf的最新版本中,可以通过在输入插件配置中指定pid作为标记存储它。这里不需要转换器处理器。

在配置中提到pid_tag = true。但是,当进程短暂存在时,请注意将pid作为标记对性能的影响。

P.S:你应该把你的telegraf版本升级到1.14.5。在这个版本中,procstat插件有一个性能改进补丁。

插件配置参考https://github.com/influxdata/telegraf/tree/master/plugins/inputs/procstat

样例配置

代码语言:javascript
复制
# Monitor process cpu and memory usage
[[inputs.procstat]]
  ## PID file to monitor process
  pid_file = "/var/run/nginx.pid"
  ## executable name (ie, pgrep <exe>)
  # exe = "nginx"
  ## pattern as argument for pgrep (ie, pgrep -f <pattern>)
  # pattern = "nginx"
  ## user as argument for pgrep (ie, pgrep -u <user>)
  # user = "nginx"
  ## Systemd unit name
  # systemd_unit = "nginx.service"
  ## CGroup name or path
  # cgroup = "systemd/system.slice/nginx.service"

  ## Windows service name
  # win_service = ""

  ## override for process_name
  ## This is optional; default is sourced from /proc/<pid>/status
  # process_name = "bar"

  ## Field name prefix
  # prefix = ""

  ## When true add the full cmdline as a tag.
  # cmdline_tag = false

  ## Add the PID as a tag instead of as a field.  When collecting multiple
  ## processes with otherwise matching tags this setting should be enabled to
  ## ensure each process has a unique identity.
  ##
  ## Enabling this option may result in a large number of series, especially
  ## when processes have a short lifetime.
  # pid_tag = false
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63697421

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档