如何将Windows性能计数器发送到Logstash + Kibana?

我想设置我的Windows服务器上的系统资源的监视。 我注意到Linux中的一个常见configuration是使用collectd守护进程获取系统度量信息。 从collectd数据可以通过logstash读取并最终放入弹性search中以便与Kibana一起查看。

这很好,在Linux世界中运行良好。 然而,我坚持与Windows服务器,我需要一些build议,以实现类似的工作stream程的最佳工具。 作为一个侧面节点,我已经使用Nxlog将IIS日志发送到logstash。

“与石墨工作的工具”页面http://graphite.readthedocs.org/en/latest/tools.html列出了几个。 我已经尝试了PowerShell脚本“Graphite PowerShell函数” https://github.com/MattHodge/Graphite-PowerShell-Functions ,它运行良好。

编辑我错读了你的问题,你只是谈论Logstash和Kibana,而不是关于Graphite。 我不使用Logstash + Kibana作为系统度量标准,但使用Statsd + Graphite。 所以不知道我的答案是否对您有效,但是如果您使用Graphite Logstashinputhttp://logstash.net/docs/1.4.2/ ,则可以使用这些工具。

Elastic现在提供了一个叫做topbeat的工具,它可以完成你正在寻找的任务。 它将CPU,内存和磁盘统计信息直接发送到Elasticsearch或Logstash。

示例度量值在弹性/顶点上的github上。

我使用Powershell 5Filebeat来解决这个问题。 请注意,这还没有经过多个小时的testing,并且是一个概念certificate。

 #Version 0.2 #Todo: #* Notify on fail #Function to get Sql Server Counters function Get-SqlServerData() { $Data = get-counter ($SqlServerCounterPrefix + ":Buffer Manager\Buffer cache hit ratio"), ($SqlServerCounterPrefix + ":Buffer Manager\Page life expectancy"), ($SqlServerCounterPrefix + ":Access Methods\Page splits/sec") #$Data $TransformedData = $Data.CounterSamples | Select-Object -Property Path, CookedValue $object = New-Object psobject $object | Add-Member -NotePropertyName 'Timestamp' -NotePropertyValue $Data.Timestamp foreach ($row in $TransformedData) { $path = $row.Path $name = $path.Substring($path.LastIndexOf("\") + 1) $object | Add-Member -NotePropertyName $name -NotePropertyValue $row.CookedValue } $object } #Parameters $SqlServerCounterPrefix = '\MSSQL$MSSQL_2008' $Type = "SQLServerStatistics" $Data = Get-SqlServerData $Path = "Z:\Temp\PowershellTest\" $AddTimeStamp = $false $NumberOfDaysToKeepFiles = 7 $FileExtension = "csv" #Variables (do not change) $Date = Get-Date -format yyyy-MM-dd $Timestamp = Get-Date $FilenameRegex = "^" + $Type + "_(?<Date>\d{4}-\d{2}-\d{2})(?:\(\d\))?\." + $FileExtension + "$" $Suffix = '' $Counter = 0 $Done = $false if ($AddTimeStamp -eq $true) { $Data | ForEach-Object { $_ | Add-Member -NotePropertyName 'Timestamp' -NotePropertyValue $Timestamp } } #Try to export file if it fails (the headers have changed) add a (number) while($Done -eq $false -and $Counter -le 9) { Try { $Filename = $Type + "_" + $Date + $Suffix + "." + $FileExtension Write-Host "Trying to write $Filename" $FilePath = $Path + $Filename $Data | Export-Csv -Path $FilePath -Delimiter ";" -NoTypeInformation -Append $Done = $true } Catch [Exception] { Write-Host "Failed to create file " + $_.Exception.GetType().FullName, $_.Exception.Message $Counter++ $Suffix = '(' + $Counter + ')' } } #Notify if we failed if ($Done -eq $false) { #Todo: Notify that we failed } #Cleanup $Files = Get-ChildItem $Path -Filter ("*." + $FileExtension) $Files | Foreach-Object { $FilePath = $_.FullName $Filename = [System.IO.Path]::GetFileName($FilePath) $Match = [regex]::Match($Filename, $FilenameRegex) Write-Host $FilePath Write-Host $Filename if ($Match.Success -eq $true) { Write-Host $Match.Groups["Date"].Value $FileDate = [datetime]::ParseExact($Match.Groups["Date"].Value, "yyyy-MM-dd", $null) $TimeSince = New-TimeSpan -Start $FileDate -End (Get-Date).Date if ($TimeSince.TotalDays -ge $NumberOfDaysToKeepFiles) { Remove-Item $FilePath } } } 

这将在$ Path目录中创build一个csv文件,如果您更改了计数器,那么它将在名称中创build一个带有(1-9)的新文件。

更新版本可在以下urlfind: https : //gist.github.com/AnderssonPeter/8261e255630d6f672ba5bc80f51b017f

现在有一个Windows性能监视器的logstashinput插件 。