Telegraf: Input Plugins

Aus Wiki-WebPerfect
Version vom 6. Mai 2020, 09:44 Uhr von Admin (Diskussion | Beiträge)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

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



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_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_processor"]
  
   [[processors.regex.tags]]
     key = "instance"
     pattern = '^(?P<VMName>.+)\:.+$'
     replacement = "${VMName}"
     result_key = "VMName"