This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Dashboard for Top 10 Interfaces

Hey All!  Now, you’re probably looking at the title of this and thinking “yeah, that’s easy enough, just create a custom chart and get the top 10 already”.  Well, this one is going to be a bit different.  What if, instead, you want to see the top 10 interfaces, but the interfaces are in separate charts?  Perfstack seems the obvious choice, but perfstack only gives you a static list, not a top 10 list.  That’s where things get a bit tricky.

But fear not!  With the power of SQL, this can be accomplished:

pastedImage_0.png

Here I’ve gone and created a view in Orion that contains the top 10 interfaces across the entire environment.  Each one of these resources is a custom chart that is based on a custom SQL query. Each query is exactly the same, except there is an offset number that is changed for the first, second, etc. interface. Below are the steps in creating:

Step 1 - Create a new view (Optional, but recommended):

Go to Settings --> All Settings, and click on Manage Views. Click on Add, then create a Summary View called “Top 10 Interfaces”

pastedImage_2.png

pastedImage_4.png

Step 2 – Add the new view to a menu bar (Optional, but recommended):

Go to Settings --> All Settings, and click on “Customize Menu Bars”.  Click on the menu bar you want to add the view to (I used Network_TabMenu), and select Edit.

pastedImage_6.png

From the list of available views on the left, find the “Top 10 Interfaces” you created, and drag that to the right.

pastedImage_7.png

Now you have the new view under My Dashboards --> Network --> Top 10 Interfaces

pastedImage_9.png

Step 3 – Create the widgets:

Click on the view we just created in steps 1 and 2, and on the left side of our blank canvas, click on Customize Page:

pastedImage_10.png

Then go to “Add Widgets” in the upper right:

pastedImage_11.png

Search for the “Custom Chart” Widget, then drag and drop that widget 10 times to the main part of the screen (5 in each column):

pastedImage_12.png

Click “Done Adding Widgets when finished”

Step 4 – Make the charts:

This is the meaty part. On the first chart, click on “Configure this resource” or “edit” (both will take you to the same page):

pastedImage_13.png

For “Title”, call this “Interface #1”
Subtitle we can leave blank
Then for datasource, click "Select Datasource", and change the selection method to “Advanced Database Query (SQL, SWQL)”, then change the query type to SQL:

pastedImage_14.png

Now for the query, copy and paste the following:

SELECT

     (no.caption + ' - ' + interf.interfacename) as [Node Name],

     interf.interfacename as [Interface Name],

     it.datetime,

     it.in_averagebps as [Average BPS In],

     it.out_averagebps as [Average BPS Out]

FROM [dbo].[InterfaceTraffic] it

inner join Interfaces interf

     on it.interfaceid=interf.interfaceid

inner join nodes no

     on it.nodeid=no.nodeid

where it.interfaceID=(

SELECT

     it.interfaceid

FROM [dbo].[InterfaceTraffic] it

where it.datetime >= DATEADD(day, -1, GETDATE()) and it.in_averagebps IS NOT NULL and it.out_averagebps IS NOT NULL

group by it.interfaceid

order by(avg(it.in_averagebps)+avg (it.out_averagebps)) desc

OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY)

So, quick explanation as to what this query does.  The first part, up to the “where” statement, pulls the interface traffic information. The magic happens in the where clause. The where clause takes the last 24 hours of performance information, per interface, and averages it out and sorts the top interfaces.

The important piece to this is the LAST line;

OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY)

What this line does is return just one line, but offset the rows X number of lines.  So, for this chart, we take the top result.  For the next chart, we will take an offset of 1, so our query is now:

OFFSET 1 ROWS FETCH NEXT 1 ROWS ONLY)

This query will give us the chart for the 2nd interface in the top ten, and so on.

Step 4 – The rest of the chart setup:

Now that our data source is set for the first chart, you can now set the rest of the options.

  1. Set your time period (I set mine to last 24 hours)
  2. On the left y-Axis, click Add data series, select “Average BPS In”
  3. Once added, click ‘More’, and a button will appear for “Time Column”.  Click that and select ‘datetime’
  4. Again on the left y-Axis, click Add data series, select “Average BPS Out”.
  5. And again, once added, click ‘More’, and select ‘datetime’ for the “Time Column”
  6. For “Units Displayed”, set this to “Bit/s”
  7. Under “Data Grouping”, “Group chart data” by “Interface Name”
  8. And for “Legend Shows”, select “Node Name”

pastedImage_15.png

And that’s it!  Hit submit.

Step 5 – Rinse and Repeat:

Repeat steps 3 and 4 for the other ten charts, and make sure you:

Change the offset number for each chart (Interface #2 has an offset of 1, Interface #3 has an offset of 2, etc.)

Change the name of the Charts for Interface 2, 3, etc.

That should do it! From this point, if you want to change the query to include a custom property, or maybe do volumes or cpu performance, you can.  The real part of this is the where clause where you look up your information ahead of time, then offset/fetch.  Let me know in the comments if you have any questions!

Parents Reply
  • I assume you have a custom property set for the interfaces you wish to filter on?  If so, just add that to the where clause:

    ...

    where it.datetime >= DATEADD(day, -1, GETDATE()) and it.in_averagebps IS NOT NULL and it.out_averagebps IS NOT NULL and it.<custom_property_name>=<custom_property_value>

    group by it.interfaceid

    ...

Children
  • Like the same way i applied the filter for custom property but its not working showing invalid query. Kindly help me to apply this query with custom property filter.

  • Sorry for the delay, can you paste the query that you are using?  Using the Solarwinds SWQL studio in the SDK you can see where the error occurs in a SQL-like error message.

    GitHub - solarwinds/OrionSDK: SDK for the SolarWinds Orion platform, including tools, documentation, and samples in Powe…

  • Can you share one script with applying the filter for custom property in the above one.

  • It is a combination of the above examples, but:

    SELECT

         (no.caption + ' - ' + interf.interfacename) as [Node Name],

         interf.interfacename as [Interface Name],

         it.datetime,

         it.in_averagebps as [Average BPS In],

         it.out_averagebps as [Average BPS Out]

    FROM [dbo].[InterfaceTraffic] it

    inner join Interfaces interf

         on it.interfaceid=interf.interfaceid

    inner join nodes no

         on it.nodeid=no.nodeid

    where it.interfaceID=(

    SELECT

         it.interfaceid

    FROM [dbo].[InterfaceTraffic] it

    where it.datetime >= DATEADD(day, -1, GETDATE()) and it.in_averagebps IS NOT NULL and it.out_averagebps IS NOT NULL and it.<custom_property_name>=<custom_property_value>

    group by it.interfaceid

    order by(avg(it.in_averagebps)+avg (it.out_averagebps)) desc

    OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY)

  • Am getting the error not able to apply the filter

    pastedImage_0.png

  • Can you copy/paste the query you are using?

  • Would it be possible to copy/paste the full query.  From what I can see ti looks fine, but that isn't the whole thing.

  • Please refer the below mention query which am using

    SELECT

         (no.caption + ' - ' + interf.interfacename) as [Node Name],

         interf.interfacename as [Interface Name],

         it.datetime,

         it.in_averagebps as [Average BPS In],

         it.out_averagebps as [Average BPS Out]

    FROM [dbo].[InterfaceTraffic] it

    inner join Interfaces interf

         on it.interfaceid=interf.interfaceid

    inner join nodes no

         on it.nodeid=no.nodeid

    where it.interfaceID=(

    SELECT

         it.interfaceid

    FROM [dbo].[InterfaceTraffic] it

    where it.datetime >= DATEADD(day, -1, GETDATE()) and it.in_averagebps IS NOT NULL and it.out_averagebps IS NOT NULL and it.IsWanInterface = Yes

    group by it.interfaceid

    order by(avg(it.in_averagebps)+avg (it.out_averagebps)) desc

    OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY)

  • AHA!  Found it.  I referenced the wrong table in the where clause.  Also note that yes/no was changed to 1 and 0.  I highlighted the change below:

    SELECT

    (no.caption + ' - ' + interf.interfacename) as [Node Name],

         interf.interfacename as [Interface Name],

        it.datetime,

         it.in_averagebps as [Average BPS In],

         it.out_averagebps as [Average BPS Out]

    FROM [dbo].[InterfaceTraffic] it

    inner join Interfaces interf

         on it.interfaceid=interf.interfaceid

    inner join nodes no

         on it.nodeid=no.nodeid

    where it.interfaceID=(

    SELECT

         it.interfaceid

    FROM [dbo].[InterfaceTraffic] it

    where it.datetime >= DATEADD(day, -1, GETDATE()) and it.in_averagebps IS NOT NULL and it.out_averagebps IS NOT NULL and interf.IsWanInterface=1

    group by it.interfaceid

    order by (avg(it.in_averagebps) + avg(it.out_averagebps)) desc

    OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY)