This is a lightweight PowerShell module to convert PowerShell outputs for Telegraf agent to the InfluxLine-Protocol. Then the Telegraf agents reads the converted outputs and send this to an InfluxDB.
Import the module by running:
Import-Module PSInfluxLineConverter -Scope CurrentUser
Example: Converts the output of "Get-Process" to the InfluxLine-Protocol
# Content of PowerShell script "input.process.ps1"
Import-Module PSInfluxLineConverter
Get-Process | ConvertTo-Metric -Measure win_process -MetricProperty CPU,PagedmemorySize,Handles -TagProperty Id,ProcessName | ConvertTo-InfluxLineString
# Content of Telegraf configuration "inputs.exec.process.conf"
[[inputs.exec]]
commands = ['powershell -NoProfile -File "C:\Program Files\Telegraf\scripts\input.process.ps1"']
data_format = "influx"
timeout = "1m"
Informations about the example
- Measurement = win_process
- Tags = Id, ProcessName
- Metric/Fields = CPU, PagedmemorySize, Handles
A full list of implemented cmdlets is provided below for your reference. Use Get-Help <cmdlet name>
with these to learn more about their usage.
Cmdlet | Description |
---|---|
ConvertTo-Metric | Converts the specified properties of any object to a metric object, which can then be easily transmitted to Influx. |
ConvertTo-InfluxLineString | Convert metrics to the InfluxLine protocol format, output as strings. |
PSInfluxLineConverter Copyright (C) 2020 Robin Hermann This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.
This repository is originally from @markwragg (https://github.com/markwragg/PowerShell-Influx). -> Thanks for that!! First I forked the repo and made it more lightweight. (All unused code are removed to minimize the overhead and optimize the performance.) Later I noticed I will worked on the originally repo, so I migrate this repo to a new GitHub repository to take advantages of forking features.