01 - Telegraf: First Steps and Guide-Lines

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche

Installation

Installing Telegraf Agent as a Windows Service with a configuration directory (recommended)

.\telegraf.exe --service install --config-directory "C:\Program Files\Telegraf\telegraf.d"

Installing Telegraf Agent as a Windows Service with a configuration directory and the default configuration file

.\telegraf.exe --service install --config "C:\Program Files\Telegraf\telegraf.conf" --config-directory "C:\Program Files\Telegraf\telegraf.d"

Installing Telegraf Agent as a Windows Service

The Telegraf Agent searches the configuration: "C:\Program Files\Telegraf\telegraf.conf"

.\telegraf.exe --service install


Deinstallation

Deinstallation of the Telegraf agent (Windows Service)

.\telegraf.exe --service uninstall


Useful Telegraf queries

Show Telegraf version

.\telegraf.exe version

Show all Telegraf input plugins

.\telegraf.exe --input-list


Telegraf Configurations/Plugins

All Telegraf Plugins are Built-In. That means you don't use extra plugin file, you can use the plugin directly you only have to write a configuration file ".conf".
Guide-Line: Save all Telegraf configurations/plugins in .conf files at: C:\Program Files\Telegraf\telegraf.d


Naming (Guide-Line)

<Telegraf-Type>.<Plugin>.<Component>.<Optionals>.conf

Example: An Input-Plugin to collect VHD informations with a PowerShell-Script: inputs.exec.vhd.conf
Example: An Input-Plugin to collect Basic Windows informations with Perfmon: inputs.win_perf_counters.basic.conf
Example: An Input-Plugin to collect Hyper-V informations with Perfmon: inputs.win_perf.hyper-v.conf
Example: Telegraf-Agent configurations: agent.global.conf
Example: Global tagging: tags.global.conf
Example: InfluxDB configurations: outputs.global.influxdb.conf
Example: Internal Monitoring of the Telegraf Agent: inputs.internal.telegraf.conf
Example: Aggregator "BasicStats": aggregators.basicstats.global.conf


Telegraf-Types

  • input
  • output
  • aggregator
  • processor
  • agent (Agent configurations: Global Intervalls,...)
  • tags (Definition of global tags)


Telegraf-Inputs

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