Telegraf: Processor Plugins: Unterschied zwischen den Versionen
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) |
||
(7 dazwischenliegende Versionen des gleichen Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
− | |||
− | |||
== Regex Processor Plugin == | == Regex Processor Plugin == | ||
''The regex plugin transforms tag and field values with regex pattern. If '''result_key''' parameter is present, it can produce new tags and fields from existing ones.'' <br> | ''The regex plugin transforms tag and field values with regex pattern. If '''result_key''' parameter is present, it can produce new tags and fields from existing ones.'' <br> | ||
− | ''For tags transforms, if '''append''' is set to '''true''', it will append the transformation to the existing tag value, instead of overwriting it.'' | + | ''For tags transforms, if '''append''' is set to '''true''', it will append the transformation to the existing tag value, instead of overwriting it.'' <br> |
+ | '''The regex pattern must match always the whole field, not only a part of it!''' | ||
''More information about the Telegraf processor plugin: https://github.com/influxdata/telegraf/tree/master/plugins/processors/regex'' | ''More information about the Telegraf processor plugin: https://github.com/influxdata/telegraf/tree/master/plugins/processors/regex'' | ||
Zeile 12: | Zeile 11: | ||
I have the following Windows Perfmon input/configuration to monitoring the load of the VMs for each virtual Core (vCore): | I have the following Windows Perfmon input/configuration to monitoring the load of the VMs for each virtual Core (vCore): | ||
<pre> | <pre> | ||
− | + | [[inputs.win_perf_counters.object]] | |
− | + | ObjectName = "Hyper-V Hypervisor Virtual Processor" | |
− | + | Instances = ["*"] | |
− | + | Measurement = "hyperv_virtual_processor" | |
− | + | Counters = [ | |
− | + | "% Total Run Time", | |
− | + | ] | |
+ | </pre> | ||
'''Assumption/Example:''' | '''Assumption/Example:''' | ||
Zeile 30: | Zeile 30: | ||
That means we have following metrics: | That means we have following metrics: | ||
− | + | hyperv_virtual_processor,instance="TestRHE01:Hv VP 01" Percent_Total_Run_Time=10% | |
− | + | hyperv_virtual_processor,instance="TestRHE01:Hv VP 02" Percent_Total_Run_Time=30% | |
− | + | hyperv_virtual_processor,instance="TestRHE01:Hv VP 03" Percent_Total_Run_Time=20% | |
− | + | hyperv_virtual_processor,instance="TestRHE01:Hv VP 04" Percent_Total_Run_Time=20% | |
− | + | hyperv_virtual_processor,instance="TestRHE02:Hv VP 01" Percent_Total_Run_Time=10% | |
− | + | hyperv_virtual_processor,instance="TestRHE02:Hv VP 02" Percent_Total_Run_Time=70% | |
Zeile 45: | Zeile 45: | ||
<pre> | <pre> | ||
[[processors.regex]] | [[processors.regex]] | ||
− | namepass = [" | + | namepass = ["hyperv_virtual_processor"] |
[[processors.regex.tags]] | [[processors.regex.tags]] | ||
Zeile 64: | Zeile 64: | ||
[[Datei:02-telegraf-regex-grafana.png]] <br> | [[Datei:02-telegraf-regex-grafana.png]] <br> | ||
+ | |||
+ | ==== Further use - Aggregate the mean ==== | ||
+ | More details: http://wiki.webperfect.ch/index.php?title=Telegraf:_Aggregator_Plugins | ||
Zeile 73: | Zeile 76: | ||
<pre> | <pre> | ||
[[processors.regex]] | [[processors.regex]] | ||
− | namepass = [" | + | namepass = ["hyperv_virtual_processor"] |
[[processors.regex.tags]] | [[processors.regex.tags]] | ||
Zeile 86: | Zeile 89: | ||
<pre> | <pre> | ||
[[processors.regex]] | [[processors.regex]] | ||
− | namepass = [" | + | namepass = ["hyperv_virtual_processor"] |
[[processors.regex.tags]] | [[processors.regex.tags]] | ||
Zeile 93: | Zeile 96: | ||
replacement = "${VMName}" | replacement = "${VMName}" | ||
result_key = "VMName" </pre> | result_key = "VMName" </pre> | ||
+ | |||
+ | |||
+ | |||
+ | ''More information's: https://github.com/influxdata/telegraf/issues/7432'' | ||
+ | |||
+ | |||
Aktuelle Version vom 14. Juni 2021, 16:29 Uhr
Inhaltsverzeichnis
[Verbergen]Regex Processor Plugin
The regex plugin transforms tag and field values with regex pattern. If result_key parameter is present, it can produce new tags and fields from existing ones.
For tags transforms, if append is set to true, it will append the transformation to the existing tag value, instead of overwriting it.
The regex pattern must match always the whole field, not only a part of it!
More information about the Telegraf processor plugin: https://github.com/influxdata/telegraf/tree/master/plugins/processors/regex
Example: Extract the VMNames from tag "instance" and create a new tag "VMName"
Input "win_perf_counters configuration (Telegraf input config file "inputs.win_perf.hyper-v.conf")
I have the following Windows Perfmon input/configuration to monitoring the load of the VMs for each virtual Core (vCore):
[[inputs.win_perf_counters.object]] ObjectName = "Hyper-V Hypervisor Virtual Processor" Instances = ["*"] Measurement = "hyperv_virtual_processor" Counters = [ "% Total Run Time", ]
Assumption/Example:
- I have two VMs ("TestRHE01" and "TestRHE02")
- The VM "TestRHE01" has four vCores
- The VM "TestRHE01" has two vCores
With the win_perf configuration, showing above, the tag instance has the following value:
"<VMName>:Hv VP <CoreNumber>"
That means we have following metrics:
hyperv_virtual_processor,instance="TestRHE01:Hv VP 01" Percent_Total_Run_Time=10% hyperv_virtual_processor,instance="TestRHE01:Hv VP 02" Percent_Total_Run_Time=30% hyperv_virtual_processor,instance="TestRHE01:Hv VP 03" Percent_Total_Run_Time=20% hyperv_virtual_processor,instance="TestRHE01:Hv VP 04" Percent_Total_Run_Time=20% hyperv_virtual_processor,instance="TestRHE02:Hv VP 01" Percent_Total_Run_Time=10% hyperv_virtual_processor,instance="TestRHE02:Hv VP 02" Percent_Total_Run_Time=70%
What we want
Extract the VMName in the tag instance as a new tag VMName, and now the Telegraf regex processor plugin comes into the game.
Processor to extract the VMName as a new tag (Telegraf processor config file "processors.regex.global.conf")
[[processors.regex]] namepass = ["hyperv_virtual_processor"] [[processors.regex.tags]] key = "instance" pattern = '^(?P<VMName>.+)\:.+$' replacement = "${VMName}" result_key = "VMName"
Regex explanation (thanks to regex101.com):
The ?P<> is a named group in the Golang-regex
Further use - Grafana
Because you have the VMName extracted from the tag instance, you are able to group by the VNName.
In our example we want the vCPU load in percentage for each VM and not foreach virtual core of a VM.
Further use - Aggregate the mean
More details: http://wiki.webperfect.ch/index.php?title=Telegraf:_Aggregator_Plugins
Troubleshooting
Error: [telegraf] Error running agent: Error parsing <C:\your_config_file_path>, line x: invalid TOML syntax
Example: Configuration with the error:
[[processors.regex]] namepass = ["hyperv_virtual_processor"] [[processors.regex.tags]] key = "instance" pattern = "^(?P<VMName>.+)\:.+$" replacement = "${VMName}" result_key = "VMName"
Solution: Write the "pattern" between singleqoutes instead between doublequotes
Example: Configuration without the error:
[[processors.regex]] namepass = ["hyperv_virtual_processor"] [[processors.regex.tags]] key = "instance" pattern = '^(?P<VMName>.+)\:.+$' replacement = "${VMName}" result_key = "VMName"
More information's: https://github.com/influxdata/telegraf/issues/7432