Telegraf: Input Plugins: Unterschied zwischen den Versionen

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „= exec = timeout = "1m" <br> data_format = "influx" <br> PowerShell Parameter = -NoProfile <br> == PowerShell Module "PSInfluxLineConverter" == ''PowerShell…“)
 
Zeile 26: Zeile 26:
 
  $VHDs = (Get-VM).Id | ForEach {Get-VHD -Id $_} | select Path, DiskIdentifier, VhdFormat, VhdType, Size, MinimumSize, FileSize, LogicalSectorSize, PhysicalSectorSize, BlockSize, FragmentationPercentage
 
  $VHDs = (Get-VM).Id | ForEach {Get-VHD -Id $_} | select Path, DiskIdentifier, VhdFormat, VhdType, Size, MinimumSize, FileSize, LogicalSectorSize, PhysicalSectorSize, BlockSize, FragmentationPercentage
 
  $VHDs | ConvertTo-Metric -Measure hyperv_vhd -MetricProperty Size, MinimumSize, FileSize, LogicalSectorSize, PhysicalSectorSize, BlockSize, FragmentationPercentage -TagProperty Path, DiskIdentifier, VhdFormat, VhdType | ConvertTo-InfluxLineString
 
  $VHDs | ConvertTo-Metric -Measure hyperv_vhd -MetricProperty Size, MinimumSize, FileSize, LogicalSectorSize, PhysicalSectorSize, BlockSize, FragmentationPercentage -TagProperty Path, DiskIdentifier, VhdFormat, VhdType | ConvertTo-InfluxLineString
 
 
 
 
 
== Troubleshooting ==
 
=== Error: [telegraf] Error running agent: Error parsing <C:\your_config_file_path>, line x: invalid TOML syntax ===
 
Example: Configuration with the error:
 
<pre>
 
[[processors.regex]]
 
  namepass = ["hyperv_processor"]
 
 
 
  [[processors.regex.tags]]
 
    key = "instance"
 
    pattern = "^(?P<VMName>.+)\:.+$"
 
    replacement = "${VMName}"
 
    result_key = "VMName" </pre>
 
 
 
==== Solution: Write the "pattern" between singleqoutes instead between doublequotes ====
 
Example: Configuration without the error:
 
<pre>
 
[[processors.regex]]
 
  namepass = ["hyperv_processor"]
 
 
 
  [[processors.regex.tags]]
 
    key = "instance"
 
    pattern = '^(?P<VMName>.+)\:.+$'
 
    replacement = "${VMName}"
 
    result_key = "VMName" </pre>
 
 
 
  
  

Version vom 6. Mai 2020, 09:45 Uhr

exec

timeout = "1m"
data_format = "influx"
PowerShell Parameter = -NoProfile


PowerShell Module "PSInfluxLineConverter"

PowerShell module to convert PowerShell outputs for Telegraf agent to the InfluxLine-Protocol. The Telegraf agents reads the converted outputs and send this to an InfluxDB.
More informations on my [Github Project-Page]https://github.com/R-Studio/PSInfluxLineConverter.


Examples

PowerShell-Skript Get-VHD (with PowerShell Module)

Telegraf Configuration

 [[inputs.exec]]
 commands = ['powershell -NoProfile -File "C:\Program Files\Telegraf\scripts\input.vhd.ps1"']
 data_format = "influx"
 timeout = "1m" 

PowerShell-Skript "input.vhd.ps1"

  • Install the PowerShell-Module "PSInfluxLineConverter" first, or copy the module to a destination (in this example: "C:\Program Files\Telegraf\scripts\psmodules\PSInfluxLineConverter")
Import-Module 'C:\Program Files\Telegraf\scripts\psmodules\PSInfluxLineConverter' -Force

$VHDs = (Get-VM).Id | ForEach {Get-VHD -Id $_} | select Path, DiskIdentifier, VhdFormat, VhdType, Size, MinimumSize, FileSize, LogicalSectorSize, PhysicalSectorSize, BlockSize, FragmentationPercentage
$VHDs | ConvertTo-Metric -Measure hyperv_vhd -MetricProperty Size, MinimumSize, FileSize, LogicalSectorSize, PhysicalSectorSize, BlockSize, FragmentationPercentage -TagProperty Path, DiskIdentifier, VhdFormat, VhdType | ConvertTo-InfluxLineString