etichy / grafana-swis-datasource

DataSource plugin for grafana to access SolarWinds data via SWIS REST API
MIT License
52 stars 11 forks source link

Not able to create a Graph #6

Closed tim-99 closed 3 years ago

tim-99 commented 4 years ago

Hi, could you share your Graph Query from https://thwack.solarwinds.com/t5/NPM-Discussions/Grafana-NPM-datasource/m-p/164923 - would be rly nice.

etichy commented 3 years ago

Do you want to see graph definition for Interface Utilization?

etichy commented 3 years ago

For chart I use following query:

SELECT downsample(d.DateTime) as dt, d.Caption, AVG(d.PercentUtil) as PercentUtil FROM ( SELECT i.Caption ,i.Traffic.DateTime ,CASE WHEN ISNULL(i.InBandwidth,0) = 0 THEN 0 ELSE (ISNULL(i.Traffic.InAveragebps,0) / i.InBandwidth 100) END AS InPercentUtil ,CASE WHEN ISNULL(i.OutBandwidth,0) = 0 THEN 0 ELSE (ISNULL(i.Traffic.OutAveragebps,0) / i.OutBandwidth 100) END AS OutPercentUtil ,CASE WHEN i.[InBandwidth] + i.[OutBandwidth] = 0 THEN 0 WHEN i.[InBandwidth] = 0 THEN ((i.Traffic.[OutAveragebps] / [i].[OutBandwidth]) 100) WHEN i.[OutBandwidth] = 0 THEN ((i.Traffic.[InAveragebps] / [i].[InBandwidth]) 100) ELSE ((i.Traffic.[OutAveragebps] / i.[OutBandwidth] + i.Traffic.[InAveragebps] / i.[InBandwidth]) * 50) END AS PercentUtil FROM Orion.NPM.Interfaces as i WHERE InterfaceID IN ($Interfaces) ) as d WHERE d.DateTime BETWEEN $from AND $to GROUP BY downsample(d.DateTime), d.Caption

image

tim-99 commented 3 years ago

Many thanks! That really helps get started. Could you also share the two variables 'Nodes' and 'Interfaces'?