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.

SWQL script not working

Hello everybody,

I am new to SWQL studio. I have built what I want to see from the SWQL studio which is a very helpful tool. I am able to get it to work, however when I want to put it to use within the Reports of Orion, I get * Query is not valid. My expectation was that I would be able to copy and paste directly from studio and magic would happen. Question to the THWACK community, What am I doing wrong?

pastedImage_5.png

  • I would expect that you should be able to copy your query without issues.  Can you supply the full text of the query that you're trying to execute?  The screenshot is useful, but it only gives so much detail.

  • SELECT 1 as aa, [N].NodeCaption as [Device Name],

    COUNT(CASE WHEN [P].InterfaceName like 'mgmt%'

    THEN 1 ELSE NULL END)

    AS [MGT],

    COUNT(CASE WHEN [P].InterfaceName like 'Fa%'

    THEN 1 ELSE NULL END)

    AS [FastEthernet],

    COUNT(CASE WHEN [P].InterfaceName like 'Gi%'

    THEN 1 ELSE NULL END)

    AS [1 Gig],

    COUNT(CASE WHEN [P].InterfaceName like 'Te%'

    THEN 1 ELSE NULL END)

    AS [10 Gig],

    COUNT(CASE WHEN [P].InterfaceName like 'Eth%' and [N].Vendor = 'Cisco'

    THEN 1 ELSE NULL END)

    AS [E10 Gig],

    COUNT(CASE WHEN [P].InterfaceHighSpeed = '40000' and [N].Vendor = 'Cisco'

    THEN 1 ELSE NULL END)

    AS [Fo Gig],

    COUNT(CASE WHEN [P].InterfaceHighSpeed = '25000'

    THEN 1 ELSE NULL END)

    AS [25g],

    COUNT(CASE WHEN [P].InterfaceHighSpeed = '100000'

    THEN 1 ELSE NULL END)

    AS [100g]

    FROM NCM.Interfaces AS [P]

    INNER JOIN NCM.Nodes AS [N]

       ON [P].NodeID = [N].NodeID

    WHERE InterfaceDescription Not LIKE '%-Controlled'

    and InterfaceDescription not like '%-Uncontrolled'

    and InterfaceDescription not like '%Vlan%'

    and InterfaceDescription not like '%Stack%'

    and InterfaceDescription not like '%Loop%'

    and InterfaceDescription not like '%port-channel%'

    and InterfaceDescription not like '%Tunnel%'

    and InterfaceDescription not like '%Adaptive%'

    and InterfaceDescription not like '%SPAN%'

    and InterfaceDescription not like '%Null%'

    and InterfaceDescription not like '%EOB%'

    GROUP BY [N].NodeCaption

    UNION

    (SELECT 2 as aa, 'GRAND TOTAL' AS [Device Name],

    SUM(CASE WHEN [P].InterfaceName like 'mgmt%'

    THEN 1 ELSE NULL END)

    AS [MGT],

    SUM(CASE WHEN [P].InterfaceName like 'Fa%'

    THEN 1 ELSE NULL END)

    AS [FastEthernet],

    SUM(CASE WHEN [P].InterfaceName like 'Gi%'

    THEN 1 ELSE NULL END)

    AS [1 Gig],

    SUM(CASE WHEN [P].InterfaceName like 'Te%'

    THEN 1 ELSE NULL END)

    AS [10 Gig],

    SUM(CASE WHEN [P].InterfaceName like 'Eth%' and [N].Vendor = 'Cisco'

    THEN 1 ELSE NULL END)

    AS [E10 Gig],

    SUM(CASE WHEN [P].InterfaceHighSpeed = '40000' and [N].Vendor = 'Cisco'

    THEN 1 ELSE NULL END)

    AS [Fo Gig],

    SUM(CASE WHEN [P].InterfaceHighSpeed = '25000'

    THEN 1 ELSE NULL END)

    AS [25g],

    SUM(CASE WHEN [P].InterfaceHighSpeed = '100000'

    THEN 1 ELSE NULL END)

    AS [100g]

    FROM NCM.Interfaces AS [P]

    INNER JOIN NCM.Nodes AS [N]

       ON [P].NodeID = [N].NodeID

    WHERE InterfaceDescription Not LIKE '%-Controlled'

    and InterfaceDescription not like '%-Uncontrolled'

    and InterfaceDescription not like '%Vlan%'

    and InterfaceDescription not like '%Stack%'

    and InterfaceDescription not like '%Loop%'

    and InterfaceDescription not like '%port-channel%'

    and InterfaceDescription not like '%Tunnel%'

    and InterfaceDescription not like '%Adaptive%'

    and InterfaceDescription not like '%SPAN%'

    and InterfaceDescription not like '%Null%'

    and InterfaceDescription not like '%EOB%')

    ORDER BY aa

  • it appears it does not like the Union. I pasted just the top half of the script and it works fine. My goal is to get a 'sum' of each column at the top or bottom. 

  • It works if you remove the ORDER BY aa from the script

  • The actual error is reported in C:\ProgramData\Solarwinds\InformationService\v3.0\Orion.InformationService.log