THWACK logo
THWACK
  • Sign In
  • Search
  • Community
    Community

    Find all you need to begin your THWACK journey, including documentation, missions, blogs, community groups, events, and media.

    Command Central
    • Getting Started
    MVP Program
    • MVP Program
    Monthly Mission
    • AI Foundations
    Blogs
    • Community Announcements
    • Product Blog
    Groups
    • DevOps Discourse
    • Data Driven
    • See All Groups
    Events
    • Global Events
    • SolarWinds User Group
    • THWACKcamp
      • ↪ 2024: On Demand
    • Bracket Battle
    Media Vault
    • Movies & Mainframes
    • TechPod
    • THWACK Tech Tips
    • THWACK Livecast
    • SolarWinds Lab Archive
    • THWACKcamp Archive
    • See All Media
  • Products
    Products

    Find the best place to learn and ask questions about your SolarWinds products.

    Observability
    • Observability Solutions
    • SolarWinds Observability SaaS
    • SolarWinds Observability Self-Hosted
    • SolarWinds Platform
    Network Management
    • Network Performance Monitoring
    • NetFlow Traffic Analyzer
    • Network Configuration Manager
    • IP Address Manager
    • User Device Tracker
    • VoIP & Network Quality Manager
    • Log Analyzer
    • Engineer's Toolset
    • Network Topology Mapper
    • Kiwi CatTools
    • Kiwi Syslog Server
    • ipMonitor
    Application Management
    • AppOptics
    • Loggly
    • Papertrail
    • Pingdom
    • DevOps
    IT Security
    • Access Rights Manager
    • Identity Monitor
    • Security Event Manager
    • Patch Manager
    • Serv-U FTP & MFT
    IT Service Management
    • SolarWinds Service Desk
    • Web Help Desk
    • DameWare Remote Support
    • DameWare Remote Everywhere
    • DameWare Mini Remote Control
    System Management
    • Server & Application Monitor
    • Virtualization Manager
    • Storage Resource Monitor
    • Server Configuration Monitor
    • SolarWinds Backup
    • Web Performance Monitor
    Database Management
    • Database Performance Analyzer
    • SQL Sentry
    • Database Performance Monitor
    • Database Mapper
    • Task Factory
  • Content Exchange
    Content Exchange

    Find downloadable files and templates other users have built and found useful to share with others.

    SolarWinds Platform
    • Alerts
    • Custom HTML
    • Custom Queries
    • Modern Dashboards
    • Reports
    • Scripts
    Server & Application Monitor
    • API Pollers
    • Application Monitor Templates
    Database Performance Analyzer
    • Custom Alerts
    • Custom Metrics
    • Custom Queries
    Server Configuration Monitor
    • Policies
    • Profiles
    Network Performance Monitor
    • Device Pollers
    • Universal Device Pollers
    Network Configuration Manager
    • Config Change Scripts
    • Device Templates
    • Firmware Upgrade Templates
    • Policy Documents
    SQL Sentry
    • Advisory Conditions
    Web Help Desk
    • Style Sheets
  • Resources
    SolarWinds Customer Portal Customer Portal

    Create individual user accounts for your team, manage your licenses, download your SolarWinds software, create and track support tickets, and more.

    SolarWinds Academy Academy

    A one-stop-shop for world-class training for SolarWinds products through on-demand videos, and instructor-led classes. All SolarWinds Academy content is included with every software purchase.

    SolarWinds Customer Success Support

    Get help when you need it from a world-class support team, available to assist with technical product issues 24 hours a day, seven days a week, 365 days a year.

    SolarWinds Partner Portal Partner Portal

    Accelerate SolarWinds Partners’ ability to drive digital and IT transformation for customers with powerful tools, resources, and increased profit potential.

  • Free Tools & Trials
  • Store
The SolarWinds Platform
  • Products
The SolarWinds Platform
SolarWinds Platform API What is the SolarWinds Query Language?
  • Newsroom
  • Forums
  • SolarWinds Platform API
  • Content Exchange
  • What We're Working On
  • Feature Requests
  • More
  • Cancel
  • New
  • -SolarWinds Platform API
    • About the SolarWinds Information Service (SWIS)
    • +Setting up a Python Development Environment
    • +Using PowerShell 7+ and Visual Studio Code
    • -SolarWinds Query Language (SWQL) Basics
      • -What is the SolarWinds Query Language?
        • +Basic SWQL Syntax
        • Standard Functions
        • Aggregate Functions
        • Boolean Operators
        • Working with Date/Time Fields
      • SWQL Studio
      • Query Basics in SWQL Studio
      • Query Construction in SWQL Studio
      • Navigation Properties
      • Architect
    • +Data Presentation Examples
    • Additional Resources
    • Glossary

What is the SolarWinds Query Language?

The SolarWinds Query Language (SWQL) is a data retrieval mechanism for querying a SolarWinds Platform product and retrieving data.  Built to mimic the Structured Query Language (SQL) used in most database management systems, it is an easy language to understand if you already possess a working grasp of SQL.

SWQL interfaces directly with the SolarWinds Information Service (SWIS) running on SolarWinds Platform products as opposed to making direct queries to the underlying database.

Direct Database Call (SQL) vs. API-based Call (SWQL)

Structurally speaking the SolarWinds Information Service acts as an abstraction and interpretation layer between the requestor and the underlying databases. Existing outside of direct database requests, this interaction has distinctions between itself and traditional database queries.

This document cannot be a complete reference for the entire SolarWinds Query Language and questions should be asked in the SolarWinds SDK Forum.

Key differentiators between SQL and SWQL

Although the data available via SQL and SWQL is identical, there are several reasons to use SWQL as opposed to SQL.  The most notable have to do with permissions and database schema upgrade protection.

Account Limitations & Credential Management

It’s a best practice to limit the number of accounts which have access to any database – even for read-only access.  The best practice to maintain a zero-trust model with regards to your monitoring data would be to have only a single account with a complex password which can access your databases directly.

Since the SolarWinds Query Language operates at a higher level of abstraction, it also inherits the account permissions and limitations native to the SolarWinds Platform.  Accounts which are not permitted to see certain types of data (Network Configuration Backups, Application Statistics, Community Strings, etc.) will honor those restrictions.  A simplified example would be an account for network engineers is only authorized to see network devices within your infrastructure.  Any queries written in SWQL and executed as a network engineer will not be able to see systems, virtualization, storage, etc. information.  However, if a user had access directly to the database, they would have unfettered access to all monitoring data.  This is inherently dangerous and goes against zero-trust security standards.

Using the accounts that you’ve already defined in your SolarWinds Platform to be used to query for monitoring data allows you to keep the number of accounts with direct database access to minimum while segregating the data to which those Orion accounts have access.

Insulation from Database Schema Changes

As the products on the SolarWinds Platform mature, there may be needs to update or remove tables, views, stored procedures, or other database-specific elements.  The SolarWinds Query Language is not affected by these lower-level changes as it speaks with the data at a higher abstraction level.  If you were to write a Web-based Report that makes direct calls to the database there is a chance that after an upgrade, the underlying database schema has been changed and the report will fail to execute.  A Web-based Report that retrieves the same data, but uses SWQL, would be insulated from these changes and would continue to operate.

This is not to say that operations within the SWQL entities are without change, but those are documented within the API and are noted as being deprecated far in advance of being removed.

Syntax

Although the SWQL language syntax is similar to that of SQL, there are notable differences – specifically with the number and type of functions allowed within each language.

Similarities include:

  • Standard query syntax is identical
  • SELECT TOP XX (PERCENT) is valid
  • The percent sign (%) is used for multi-character string matching
  • The underscore (_) is used for single-character string matching
  • Single quotes (') are used to denote characters or strings
  • JOINs are supported, but Navigation Properties  alleviates some of the need
  • Sub queries are supported, and the syntax is identical
  • WHERE clauses follow the same syntax and Boolean logic
  • Aggregate functions behave the same between SWQL and SQL
  • GROUP BY and ORDER BY operations behave the same
  • HAVING is used for filtering on returned values from aggregate functions
  • CASE statements are supported, and the syntax is the same

Differences include:

  • SWQL supports only SELECT queries. UPDATE, MERGE, DELETE, and any other action that is not read-only is not supported.  This read/write functionality is supported by using Verbs (see SWQL Verbs [link to another chapter]) and specific REST calls (see Updating SWIS Data [link to another chapter]).
  • The asterisk (*) for returning all fields is not supported in SWQL (SELECT * FROM…)
  • SWQL does not support cursors or looping within a statement.
  • Common Table Expressions (CTEs) are not supported
  • Temporary Tables are not supported
  • CAST and CONVERT operations are not supported
  • SWQL has several functions, specialized for working with monitoring data, outside those for SQL.

Under the surface, it’s plain that SWQL queries at some point must be converted to SQL calls.  This is functionally correct and can be useful when troubleshooting.  This will be covered in Troubleshooting SWQL Queries [link to another chapter].

Semantic Differences

When making a database call via SQL you are querying a table.  Although the syntax is identical with SWQL, the terminology is changed.  Being an API, data structured in tabular form are called “entities.”  You may see either term (table or entity) in this wiki but be aware that entities are the way in which data is grouped and organized to match up with your monitoring infrastructure.

Testing SWQL Queries

Later in this chapter, we’ll be discussing how to use SWQL Studio to build an run queries, but in the meantime if you want to test queries you can use your SolarWinds Platform web interface.  Accounts with admin access can navigate to http(s)://serverNameHere/Orion/admin/swis.aspx and execute SWQL queries for testing purposes.

For the purposes of the rest of this section, we’ll concentrate on the fundamental construction of SWQL queries.  All queries listed in this chapter will be published in a public GitHub repository where you can download and tailor them to your environment.

  • SolarWinds Query Language (SWQL)
  • Share
  • History
  • More
  • Cancel
Related
Recommended

SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 200,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.

SolarWinds Customer Success Center Certification SolarWinds Lab Link Customer Portal
About THWACK SolarWinds Blog Federal & Government Edit Settings Free Tools & Trials
Legal Documents Terms of Use Privacy California Privacy Rights Security Information
©2021 SolarWinds Worldwide, LLC. All Rights Reserved.