Documentation forSolarWinds Platform

Custom Query

This topic applies to all SolarWinds Platform products.

You can create a custom widget based on a SWQL query. The query provided in this widget runs against your SolarWinds database, and the results are displayed in an appropriate grid.

If you have upgraded to SolarWinds Platform version 2015.1.x or later, your custom SQL or SWQL query or filter may no longer work correctly.

When using queries, be aware that users will only see the information they have privileges to see. For example, non-administrators will not see audit events or details on other user accounts; users with account limitations will only see query results they are allowed to see.

Configure the widget

  1. Click Edit.
  2. Enter a Title and Subtitle.
  3. Enter your custom SWQL query.
    • For more information about creating valid custom SWQL queries, see Using SWQL (Semantic Web Query Language).
    • Do not end your custom SWQL query with a comment. Closing your query with a comment may exclude the required query clauses that are automatically appended to your custom query. Those clauses ensure full resource functionality in the web console. 
  4. Designate the Number of Rows Per Page in the widget.

    If your query returns a large number of objects, you can decrease the load on your SolarWinds Platform server by breaking your results into pages. This setting indicates the number of objects the web console should display in the widget at a time.

  5. Click Submit.

Configuration examples (SWQL)

The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.

Display the time and date of your last three successful logins

  1. Into the Custom SWQL Query box, enter the following code:

    SELECT TOP 3 ToLocal(TimeLoggedUtc) AS Time, DisplayName AS Info

    FROM Orion.AuditingEvents

    WHERE ActionTypeID=1 and AccountID = '${UserID}' ORDER BY TimeLoggedUtc DESC

  2. Select Enable search and enter the following code into the box.

    SELECT TOP 3 ToLocal(TimeLoggedUtc) AS Time, DisplayName AS Info

    FROM Orion.AuditingEvents

    WHERE ActionTypeID=1 and AccountID = '${UserID}' ORDER BY TimeLoggedUtc DESC

  3. Click Submit.

Convert datetime columns to UTC or local time (SWQL)

Datetime values are usually stored in the UTC format. To convert datetime values use the following functions:

  • ToLocal(d) - converts d to the local time of the SolarWinds Platform server
  • ToUtc(d) - converts d to UTC time

For a comprehensive list of SWQL functions, see SWQL Functions in GitHub.

To display the top nodes that are up with the last boot time in UTC, use the following code:

  1. Into the Custom SWQL Query box, enter the following code:

    SELECT TOP 10

    NodeID As NodeID,

    ToUtc(LastBoot) AS LastBoot_UTC,

    SystemUptime

    FROM Orion.NodesStats

    WHERE NodeId BETWEEN 1 AND 10 ORDER BY SystemUpTime ASC

  2. To enable searching the widget, select Enable search and enter the same code into the box.

  3. Click Submit.