Help Modifying a custom report to give me the ability to enter specific dates (pull historical) and then default to the last "Month"

HI Guys,

I have had NCM installed and monitoring for a few months now but due to issues never got my "Uptime" report working.  I worked with presales before purchasing and they helped get a demo report working off a custom field using SWQL queries.

The problem with these queries is that the WHERE statement is hardcoded to last 30 days and I lost the ability to change the table to use "Last Month" or any of the other prebuilt options in report builder.  

How can I change this SWQL statement to be able to hard code specific dates so I can get my missing historical data?  

Then I want to schedule the report automatically to report on the last month at the first of the new month.  How do I get it to properly do 30/31 days?

I have two custom queries as follows right now that both need modified.

     Orin.CustomProperties.AvailabilityReportingGroups as [Team]
,    OriN.Caption as [Node Name]
,    ToString(Round(AVG(OriN.ResponseTimeHistory.Availability),2))+'%' as Avail
     FROM Orion.Nodes OriN
WHERE OriN.ResponseTimeHistory.DateTime>ADDDAY(-30, GETDATE())
GROUP BY Orin.CustomProperties.AvailabilityReportingGroups, OriN.Caption
ORDER BY Orin.CustomProperties.AvailabilityReportingGroups, OriN.Caption DESC

      OriC.AvailabilityReportingGroups as [Team]
,     ToString(Round(AVG(OriC.Node.ResponseTimeHistory.Availability),2))+'%' as [Availabilty]
FROM Orion.NodesCustomProperties OriC
WHERE OriC.AvailabilityReportingGroups IS NOT NULL and OriC.node.ResponseTimeHistory.DateTime>ADDDAY(-30, GETDATE())
GROUP BY OriC.AvailabilityReportingGroups

Any help is appreciated!

  • If you had a magic pencil, what would you want to result report to look like? (the more detail the better, including if you can put in a table with the fields or the like).

  • Hiya!  Sorry for delay.  Solarwinds support came back and told me they can not help me.  

    Hi Blake,
    Good Day!
    Unfortunately, we do not support SWQL troubleshooting. We can guide you on where to place them but if a script fails, we won't be able to assist.
    It is not that we do not wish to help, it is just that we are not trained for SWQL troubleshooting nor creating them.
    Please see Support Limitation under the article below:
    All SWQL and Orion SDK troubleshooting are usually channeled through the Thwack forums.

    So that does not seem to be an option!

    Ill do my best to describe my wish list.

    1 Monthly Report (with ability to get historical data from when I implemented solarwinds if possible)

    Reporting on Groups (currently a custom field called AvailabilityReportingGroups)

    I also tried using actual groups but that caused issues with historical info.

    Under this custom field I have Dev Servers, Prod Servers, Network Devices, and Telecom.  I need a report monthly that can be easily typed into an excel document.

    The unmanaged time is a wildcard field that I believe i could get them to not track as i am not sure what can be done with this.  I know that Average availability excludes time a node is not managed, so would be good to see a percentage of time that node is in that status, but not sure if this exists.  

    Let me know if this helps.  At this point I don't care if I have to do multiple reports as long as I can get something working soon with the historical data!

    System Uptime (Average of Average availability) Unmanaged Time
    Dev Servers 97.5%
    Prod Servers 99.65%
    Network Devices 86.5%
    Telecom Devices 100%


    Node AvailabilityReportingGroup Uptime (average availability) Unmanaged Time
    Server1Dev DEV Servers 100%
    Server2Dev DEV Servers 95%
    Server1Prod PROD Servers 99.3%
    Server2Prod Prod Servers 100%
    Network Device1 Network Devices 100%
    Network Device2 Network Devices 82%
    Network Device3 Network Devices 79%
    Network Device4 Network Devices 85%
    Telecom1 Telecom 100%
  • Support is wrong.  This isn't a problem with the SWQL.  This is a problem with the reporting engine not picking up the ${FromTime} and ${ToTime} variables in the query.  If you need to, reference them back to this page or ask them to contact me.

    I've got a custom SWQL report that does work correctly Reboots and Downtime Report - Reports - The Orion Platform - THWACK - SolarWinds Community): by showing the "From <Datespan>".

    Under the covers you can see that this is a custom SWQL report:

  • I downloaded the text and saved it as a XML and imported it into my reports and I can confirm that yours does have the selector.

    Can you provide an XML of my report above that I could attempt the same thing for?  That is if you are getting the selector when trying on our side?

  • Actually I really like your report.  I wonder if it can be modified to group like the one I am attempting.  

    If i change yours to last month it no longer pulls back data though and its way more complicated SWQL!

  • Pretty easily actually.  The SWQL behind the scenes is fairly intense (because of all the math it does).  I try to remember to make notes of how to incorporate custom properties (even if it's in comments)

    SELECT area of the query, I even left notes on how to "extend" this to include custom properties (line 9-10).

    SELECT [Nodes].Caption
         , [Nodes].DetailsUrl
         , [Nodes].VendorInfo.Icon
         , [ResponseTime].Day
         , [ResponseTime].Availability
         , [Downtime].MinutesDown
         , [Downtime].CalcAvailability
         , [Events].RebootCount
    -- To add Node Custom Properties use:
    -- , [Nodes].CustomProperties.<Custom Property Name>
    FROM Orion.Nodes AS [Nodes]
    -- truncated for readability --
    --   query continues below   --

    You should be just able to add your specific custom property and keep the same data set.

    SELECT [Nodes].Caption
         , [Nodes].DetailsUrl
         , [Nodes].VendorInfo.Icon
         , [ResponseTime].Day
         , [ResponseTime].Availability
         , [Downtime].MinutesDown
         , [Downtime].CalcAvailability
         , [Events].RebootCount
    -- To add Node Custom Properties use:
         , [Nodes].CustomProperties.AvailabilityReportingGroup
    FROM Orion.Nodes AS [Nodes]
    -- truncated for readability --
    --   query continues below   --

    Then you could edit the table to add the new field (AvailabilityReportingGroup) to the report and at the bottom change the "Day" grouping to that custom property.

  • First: Support responded and said no, you are wrong and they still will not help.  So seems like that is a no go.  


    Some odd results with this.

    SELECT [Nodes].Caption
         , [Nodes].DetailsUrl
         , [Nodes].VendorInfo.Icon
         , [ResponseTime].Day
         , [ResponseTime].Availability
         , [Downtime].MinutesDown
         , [Downtime].CalcAvailability
         , [Events].RebootCount
    -- To add Node Custom Properties use:
    FROM Orion.Nodes AS [Nodes]
         SELECT [RT].NodeID
              , DateTrunc('day', [RT].DateTime) AS [Day]
              , AVG([RT].Availability * 1.0) AS Availability
         FROM Orion.ResponseTime AS [RT]
         GROUP BY DateTrunc('day', [RT].DateTime)
              , [RT].NodeID
         ) AS [ResponseTime]
         ON [Nodes].NodeID = [ResponseTime].NodeID
         SELECT [DT].NodeId
              , DateTrunc('day', [DT].DateTimeUntil) AS [Day]
              , SUM([DT].TotalDurationMin) AS [MinutesDown]
              , ( ( 1.0 - ( SUM([DT].TotalDurationMin) / 1440.0 ) ) * 100.0 ) AS [CalcAvailability]
         FROM Orion.NetObjectDowntime AS [DT]
         INNER JOIN Orion.StatusInfo AS [SI]
              ON [DT].State = [SI].StatusId
                   AND [SI].StatusName = 'Down' -- Where the status is 'Down' (not 'Critical', 'Warning', etc.)
         WHERE [DT].EntityType = 'Orion.Nodes' -- Only show me nodes
              AND [DT].DateTimeUntil IS NOT NULL --Indicates that it's no longer down
         GROUP BY DateTrunc('day', [DT].DateTimeUntil)
              , [DT].NodeId
         ) AS [Downtime]
         ON [ResponseTime].NodeId = [Downtime].NodeID
              AND [ResponseTime].Day = [Downtime].Day
         SELECT [E].Nodes.NodeID
              , COUNT([E].EventID) AS [RebootCount]
              , DATETRUNC('day', [E].EventTime) AS [Day]
         FROM Orion.Events AS [E]
         WHERE [E].EventTypeProperties.Name = 'Node rebooted'
         --   AND [E].Nodes.CustomProperties.<Custom Property Name> = <Custom Property Value>
         GROUP BY DATETRUNC('day', [E].EventTime)
              , [E].Nodes.NodeID
         ) AS [Events]
         ON [ResponseTime].NodeID = [Events].NodeID
              AND [ResponseTime].Day = [Events].Day
    WHERE [Nodes].ObjectSubType <> 'ICMP'
    -- Required for Orion Reports
       AND [ResponseTime].Day BETWEEN ${FromTime} AND ${ToTime}
    -- To filter on Node Custom Properties add
    --  AND [Node].CustomProperties.<Custom Property Name> = <Custom Property Value>

    Preview results gives nothing back in the SWQL view. If i keep the results set to "Last Week" and go the "Edit Table" I have added the AvailabilityReportingGroups field.

    If i run the report I only get 10 results but it will not display the field and I do see it grouping by my custom field.

    Then it gets weirder and it only has sporadic days being displayed for these:

    Now if i change it to "Last Week" it shows even less.  If i change it to last month - it does not load anything at all.

    My only theory is that you are using ResponseTime and my report was using responsetimehistory?  Maybe it clears out values?

  • I mean, this is a downtime report, so if there's no downtime, it shouldn't exist on the report.  That said it does seem like unusual data responses.

    How many nodes do you have in your environment?  Because there's so much behind the scenes in this report, we may be running into a timeout issue.

  • Well true.  I guess its probably simpler to just focus on my report and try to figure out why it wont work with the fields you added.  When I imported your report it does have the field.

    Any chance you can export an xml of my data with it working on your side?

  • Any chance you can export an xml of my data with it working on your side?

    Do you mean, me work with your report?

    If so, you can export it and attach it to this thread. Exporting and Importing Shared Content - THWACK Documentation - THWACK Command Center - THWACK - SolarWinds Community