Grafana 仪表板 - 更改 Server,Server,Server?
Posted
技术标签:
【中文标题】Grafana 仪表板 - 更改 Server,Server,Server?【英文标题】:Grafana Dashboard - Change Server,Server,Server?Grafana 仪表板 - 更改 Server,Server,Server? 【发布时间】:2020-12-12 13:04:37 【问题描述】:我正在尝试在我的实验室环境中了解有关 Grafana(Influx 和 Telegraf)的更多信息,但我未能将 Server,Server,Server 更改为 Server,Server,Server(请参阅屏幕截图和代码)
我做错了什么?我想同时查看多台服务器,但不想将它们的值混为一谈...
我想要...
Server1 - 错误 服务器 2 - 错误 Server1 - 成功 Server2 - 成功
不是……
Server1,Server2 - 错误 Server1,Server2 - 成功
Grafana Dashboard 1
Grafana Dashboard 2
Powershell Result
PowerShell 脚本
# Parameters
$Server = 'localhost'
$Database = 'CM_ORG'
# Query
$sqlCmd = "
SELECT [$($Database)].[dbo].[DistributionPoints].ServerName AS DistributionPoint,
[$($Database)].[dbo].[ContentDistributionByDP].NumberErrors AS Errors,
[$($Database)].[dbo].[ContentDistributionByDP].NumberInProgress AS InProgress,
[$($Database)].[dbo].[ContentDistributionByDP].NumberInstalled AS Installed,
[$($Database)].[dbo].[ContentDistributionByDP].NumberUnknown AS Unknown
FROM [$($Database)].[dbo].[ContentDistributionByDP]
LEFT JOIN [$($Database)].[dbo].[DistributionPoints] ON [$($Database)].[dbo].[ContentDistributionByDP].DPID = [$($Database)].[dbo].[DistributionPoints].DPID
"
# Run
Try $Result = Invoke-Sqlcmd $sqlCmd -Server $Server -Database $Database -OutputSqlErrors $False
Catch Return $False
# Variables
#$Server = @Label="Server";Expression=$env:COMPUTERNAME # There is already a "host" built-in
$Process = @Label="Process";Expression='Distribution Status'
$Measurement = "DistributionPoints"
$TagList = "DistributionPoint","Process"
$MetricList = "Installed","InProgress","Errors","Unknown"
# Output
$Result | Select-Object $Process,@N='DistributionPoint';E=$_.DistributionPoint.Split(".")[0],Installed,InProgress,Errors,Unknown | ConvertTo-Metric -Measure $Measurement -MetricProperty $MetricList -TagProperty $TagList | ConvertTo-InfluxLineString -WarningAction SilentlyContinue
【问题讨论】:
【参考方案1】:我碰巧让它工作了。我相信这与在 GROUP BY 中添加 DistributionPoint 并通过“$tag_DistributionPoint”在 ALIAS BY 中调用它有关,这之前会给我一个空值......但现在它起作用了。
【讨论】:
以上是关于Grafana 仪表板 - 更改 Server,Server,Server?的主要内容,如果未能解决你的问题,请参考以下文章