etichy / grafana-swis-datasource

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

Parsing 'include all' from variable not working for timeseries graph #14

Closed svestenik closed 1 year ago

svestenik commented 3 years ago

Hello,

I have tried to create repeating panels for several interfaces of same device and ran into the issue with parsing grafana variable with value 'include all'.

Defined variable in Dashboard variables like this:

Source: swis-datasource

Variable name: RouterInterface Query: SELECT Caption AS text, InterfaceID AS value FROM Orion.NPM.Interfaces WHERE [NodeID] LIKE '537' AND (InterfaceType=6 OR InterfaceType=135);

Panel query:

SELECT downsample(ObservationTimeStamp) as time, a.Interface.Alias, MAX((OutMaxbps)/1000000) AS [Max Transmit Mbps], MAX((InMaxbps)/1000000) AS [Max Receive Mbps] FROM Orion.NPM.InterfaceTraffic a WHERE ObservationTimeStamp BETWEEN $from AND $to AND InterfaceID='$RouterInterface' GROUP BY downsample(ObservationTimeStamp), a.Interface.Alias ORDER BY time DESC

If I use this variable without 'include all' or 'multi-value' selections, everything works for single interface choosen from dropdown variable menu.

But repeat panel option on that variable does not work and if I select 'include all' or 'multi-value' selection in the variable, then that panel does not work at all (throws red exclamation mark instead of graph).

etichy commented 1 year ago

Because SWQL language is very close to SQL, for 'include all' and 'multi-value' variable, you have to use syntax IN

SELECT downsample(ObservationTimeStamp) as time, a.Interface.Alias, MAX((OutMaxbps)/1000000) AS [Max Transmit Mbps], MAX((InMaxbps)/1000000) AS [Max Receive Mbps] FROM Orion.NPM.InterfaceTraffic a WHERE ObservationTimeStamp BETWEEN $from AND $to AND InterfaceID IN ($RouterInterface) GROUP BY downsample(ObservationTimeStamp), a.Interface.Alias ORDER BY time DESC