Telegraf数据收集 - 如何为输入选择特定字段

发布于 2025-02-09 18:25:52 字数 424 浏览 2 评论 0原文

标题几乎是我的问题 - 我是Telegraf的新手,慢慢地掌握了如何运行并指定日志文件,归档过程等

。收集的指标。例如,仅收集每个CPU ID的CPU-BUSY。但是,当我运行基本config( telegraf -config telegraf.conf -once )时,它会根据所请求的输入从字面上收集每个字段。

有没有办法告诉Telegraf每个输入只收集特定字段?我的telegraf.conf CPU设置如下:

[[inputs.cpu]]
  percpu = false
  totalcpu = true
  collect_cpu_time = false
  report_active = false
  core_tags = false

提前欢呼,Vinny

The title is pretty much my question - I'm new to Telegraf and slowly getting to grips with how to run it and specify log files, archiving processes, etc etc.

One of the, IMO very simple, tasks I have is to specify the metrics collected. For example, only to collect CPU-busy per CPU ID. But when I run my basic config (telegraf --config telegraf.conf --once), it collects literally every field per the input requested.

Is there a way to tell Telegraf to only collect specific fields per the input? My Telegraf.conf CPU setup is as below:

[[inputs.cpu]]
  percpu = false
  totalcpu = true
  collect_cpu_time = false
  report_active = false
  core_tags = false

Cheers very much in advance, Vinny

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁〃客ぐ 2025-02-16 18:25:53

Telegraf配置提供了 metric-filtering
对于用例,您可以尝试 fieldPass fieldDrop 以有用的为准。

关于: fieldpass 的简短描述

:全球模式字符串的数组。仅发出其字段键匹配此列表中图案的字段。

fieldDrop :fieldPass的倒数。具有匹配其中一种模式的字段键的字段将从该点丢弃。

我认为,在CPU忙碌的情况下,您的意思是用户级别流程的消耗百分比。在这种情况下,您的配置变为:

[[inputs.cpu]]
  percpu = false
  totalcpu = true
  collect_cpu_time = false
  report_active = false
  core_tags = false
  fieldpass = ["usage_user"]

上面的配置仅通过用户级别进程输出使用。

注意:CPU忙碌,如果您还要收集系统使用量,请在fieldPass数组中添加usage_system,

如果您想报告所有非IDLE CPU状态的总和,则需要设置report> report> report_active = true在上面的配置中。要仅报告主动用法(所有非IDLE CPU状态的总和),请在 fieldpass array中传递usage_active arnay array as field> fieldpass = [“ usage_active”] < /代码>

如果您希望分别收集每个CPU的统计信息,请设置percpu = true

Telegraf configuration provides support for metric-filtering.
For your use case, you may try fieldpass or fielddrop whichever is useful.

Short description about:

fieldpass: An array of glob pattern strings. Only fields whose field key matches a pattern in this list are emitted.

fielddrop: The inverse of fieldpass. Fields with a field key matching one of the patterns will be discarded from the point.

I assume that by cpu busy, you mean the percentage consumption by user level processes. In that case, your configuration becomes:

[[inputs.cpu]]
  percpu = false
  totalcpu = true
  collect_cpu_time = false
  report_active = false
  core_tags = false
  fieldpass = ["usage_user"]

The above configuration will output only the usage by user level processes.

NOTE: By CPU busy, if you mean to collect system usage as well, add usage_system as well to the fieldpass array

If you would like to report the sum of all non-idle CPU states, you need to set report_active = true in the above configuration. To report only the active usage (sum of all non-idle CPU states), pass the usage_active in the fieldpass array as fieldpass = ["usage_active"]

If you wish to collect statistics of each cpu separately, set percpu = true

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文