-
Notifications
You must be signed in to change notification settings - Fork 142
SWQL Functions
Michal Ludik edited this page Sep 16, 2024
·
15 revisions
SolarWinds Query Language supports a number of built-in functions that can be used in queries.
-
IsNull(a, b)
- Returnsa
unless it isNULL
, else returnsb
. -
Case when c then a else b end
- Returnsa
ifc
is true else returnsb
. -
UNION(q)
- Adds the results of an additional queryq
directly below the former, the number of columns must match between unioned queries
-
Abs(n)
- Returns the absolute value ofn
. -
Ceiling(n)
- Returns the smallest integer that is not less thann
. -
Floor(n)
- Returns the largest integer that is not greater thann
. -
Round(n, p)
- Returnsn
rounded to thep
decimal places.
-
AddDate(u, n, d)
- Returns a daten
units afterd
, where the unit is specified by the first parameteru
, which must be one of:'millisecond'
,'second'
,'minute'
,'hour'
,'day'
,'week'
,'month'
, or'year'
. Theu
argument must be a string literal. It can't be a query parameter or value derived from the data. -
AddDay(n, d)
- Returns a daten
days afterd
. -
AddHour(n, d)
- Returns a daten
hours afterd
. -
AddMillisecond(n, d)
- Returns a daten
milliseconds afterd
. -
AddMinute(n, d)
- Returns a daten
minutes afterd
. -
AddMonth(n, d)
- Returns a daten
months afterd
. -
AddSecond(n, d)
- Returns a daten
seconds afterd
. -
AddWeek(n, d)
- Returns a daten
weeks afterd
. -
AddYear(n, d)
- Returns a daten
years afterd
. -
DateTime
- Converts a string to a date. In most scenarios this conversion will happen automatically when needed by usage. -
DateTrunc('datepart', 'd')
- Where'datepart'
is one of the following strings:'minute'
,'hour'
,'day'
,'week'
,'month'
,'quarter'
,'year'
. Returns a date liked
, but with all components more granular than'datepart'
set to zero. -
Day(d)
- Returns the day of the month ofd
. -
DayDiff(a, b)
- Returns the number of days (rounded to the nearest integer) thatb
is later thana
. -
DayOfYear(d)
- Returns the day of year ofd
. January 1 is 1, February 1 is 32, etc. -
Downsample(d, p)
- Rounds the supplied timestampd
to the defined time periodp
. For example, a period of'00:15:00'
would round to the nearest 15 minute time increment. Requires Orion 2018.3 or later. -
GetDate()
- Returns the current date in local time at the Orion server. -
GetUtcDate()
- Returns the current date and time in UTC. Please note possible issues. -
Hour(d)
- Returns the hour part ofd
(in 24 hour format). -
HourDiff(a, b)
- Returns the number of hours (rounded to the nearest integer) thatb
is later thana
. -
Millisecond(d)
- Returns the millisecond part ofd
. -
MillisecondDiff(a, b)
- Returns the number of milliseconds (rounded to the nearest integer) thatb
is later thana
. -
Minute
- Returns the minute part ofd
. -
MinuteDiff(a, b)
- Returns the number of minutes (rounded to the nearest integer) thatb
is later thana
. -
Month
- Returns the month part ofd
. January is 1. -
MonthDiff(a, b)
- Returns the number of months (rounded to the nearest integer) thatb
is later thana
. -
QuarterOfYear(d)
- Returns the quarter of the year that containsd
. January, February, and March are 1; April, May, and June are 2; etc. -
Second(d)
- Returns the second part ofd
. -
SecondDiff(a, b)
- Returns the number of seconds (rounded to the nearest integer) thatb
is later thana
. -
ToLocal(d)
- Convertsd
to local time on the Orion server. -
ToUtc
- Convertsd
to UTC time. -
Week(d)
- Returns the week number ofd
. -
WeekDay(d)
- Returns the day of the week ofd
as a number, with Sunday = 0, Monday = 1, ..., Saturday = 6. Available in Orion Platform 2016.1 and later. -
WeekDiff(a, b)
- Returns the number of weeks (rounded to the nearest integer) thatb
is later thana
. -
Year(d)
- Returns the year ofd
. -
YearDiff(a, b)
- Returns the number of years (rounded to the nearest integer) thatb
is later thana
.
Aggregate functions operate on a whole group of values at once. If a GROUP BY
clause is present in the query, the aggregate function will operate on all values for each set of GROUP BY
keys. If no GROUP BY
clause is present, the aggregate function will operate on all values returned by the query.
-
Avg(n)
- Returns the average (arithmetic mean) of the values in the group. -
Count(n)
- Returns the number of non-NULL
values in the group. -
Max(n)
- Returns the largest value in the group. -
Min(n)
- Returns the smallest value in the group. -
Sum(n)
- Returns the arithmetic sum of the values in the group.
-
ArrayContains(a, v)
- Returns true if arraya
contains valuev
. -
ArrayLength(a)
- Returns the number of elements in arraya
. -
ArrayValueAt(a, i)
- Returns the array element at positioni
in arraya
, counting from zero.
-
Concat(a, b, c, ...)
- Takes one or more arguments and returns a single string that is the concatenation of the values of the arguments. -
EscapeSWISUriValue(a)
- Returnsa
with certain characters escaped. Intended for internal use only. -
Length(s)
- Returns the length of strings
. -
CharIndex(toFind, toSearch [, start])
- Returns the position at whichtoFind
occurs withintoSearch
(starting at positionstart
, if provided) or zero iftoFind
is not found. Supported since Orion Platform 2018.2 (NPM 12.3) and later. -
SubString(s, start, length)
- Returns a substring oflength
characters starting at positionstart
(the first character is position 1). -
Replace(expression, pattern, replacement)
- Replaces all occurrences of a specified string (pattern
) value inexpression
with another string value (replacement
). Supported since Orion Platform 2017.3 (NPM 12.2) and later. -
ToLower(a)
- Convertsa
to all lowercase. -
ToUpper(a)
- Convertsa
to all uppercase. -
ToString(a)
- Convertsa
to a string. In most scenarios this conversion will happen automatically when needed by usage. -
UriEquals(a, b)
- Returns true if SWIS Uria
refers to the same entity instance as SWIS Urib
.
- About SWIS
- Connecting to SWIS
- SWQL Functions
- REST
- PowerShell
- Alerts
- Creating custom properties
- Poller Types
- Network Performance Monitor
- NetFlow Traffic Analyzer
- Network Configuration Manager
- IP Address Manager
- Server & Application Monitor
- Log Analyzer
- Schema reference