AQL data calculation and formatting functions
Use Ariel Query Language (AQL) calculation and formatting functions on search results that are retrieved from the Ariel databases.
BASE64
- Purpose
- Returns a Base64 encoded string that represents binary data.
- Example
-
SELECT BASE64(payload) FROM events
CONCAT
- Purpose
- Concatenates all passed strings into one string.
- Example
-
SELECT CONCAT(username, ':', sourceip, ':', destinationip) FROM events LIMIT 5
DATEFORMAT
- Purpose
- Formats time in milliseconds since 00:00:00 Coordinated Universal Time (UTC) on January 1, 1970 to a user-readable form.
- Examples
-
SELECT DATEFORMAT(startTime, 'yyyy-MM-dd hh:mm:ss') AS StartTime FROM events
SELECT DATEFORMAT(starttime,'yyyy-MM-dd hh:mm') AS 'Start Time', DATEFORMAT(endtime, 'yyyy-MM-dd hh:mm') AS Storage_time, QIDDESCRIPTION(qid) AS 'Event Name' FROM events
DOUBLE
- Purpose
- Converts a value that represents a number into a double.
- Example
-
DOUBLE('1234')
LONG
- Purpose
- Converts a value that represents a number into a long integer.
- Examples
-
SELECT destinationip, LONG(SUM(sourcebytes+destinationbytes)) AS TotalBytes FROM flows GROUP BY sourceip
PARSEDATETIME
- Purpose
- Pass a time value to the parser, for example,
PARSEDATETIME('time reference')
. The time reference indicates the parse time for the query.
- Example
-
SELECT * FROM events START PARSEDATETIME('1 hour ago')
PARSETIMESTAMP
- Purpose
- Parse the text representation of date and time and convert it to UNIX epoch time.
For example, parse the following text date format:
Thursday, August 24, 2017 3:30:32 PM GMT +01:00 and convert it to the following epoch timestamp: 1503588632.
- Example of how the time format conversion works
-
The following example demonstrates how the DATEFORMAT function converts epoch time to a text timestamp by using the specified date format, and then the PARSETIMESTAMP function is used to convert the text timestamp to an epoch time format.
SELECT starttime, DATEFORMAT(starttime,'EEE, MMM d, "yyyy"') AS "text time format", PARSETIMESTAMP('EEE, MMM d, "yyyy"', "text time format") AS 'epoch time returned' from events limit 5
The following example displays an extract of the output from the query:
starttime text time format epoch time returned 1503920389888 Mon, M08 28, "2017" 1503920389888
- Example of how PARSETIMESTAMP might be used to convert times to epoch time so that time calculations can be made.
-
In the following example, events are returned when the time difference between logout and login times is less that 1 hour.
The EEE, d MMM yyyy HH:mm:ss.SSSZ time format is just one example of a time format that you might use, and my_login and my_logout are custom properties in a known time format, for example, EEE, MMM d, "yy".
SELECT * from events WHERE PARSETIMESTAMP('EEE, d MMM yyyy HH:mm:ss.SSSZ', my_logout) - PARSETIMESTAMP('EEE, d MMM yyyy HH:mm:ss.SSSZ', my_login) < 3600000 last 10 days
NOW
- Purpose
- Returns the current time that is expressed as milliseconds since the time 00:00:00 Coordinated Universal Time (UTC) on January 1, 1970.
- Example
-
SELECT ASSETUSER(sourceip, NOW()) AS 'Asset user' FROM events
LOWER
- Purpose
-
Returns an all lowercase representation of a string.
- Example
-
SELECT LOWER(username), LOWER(LOGSOURCENAME(logsourceid)) FROM events
REPLACEALL
- Purpose
- Match a regex and replace all matches with text.
- Example
-
REPLACEALL('\d{16}', username, 'censored')
REPLACEFIRST
- Purpose
- Match a regex and replace the first match with text.
- Example
-
REPLACEFIRST('\d{16}', username, 'censored')
STR
- Purpose
- Converts any parameter to a string.
- Example
-
STR(sourceIP)
STRLEN
- Purpose
- Returns the length of this string.
- Example
-
SELECT STRLEN(sourceIP), STRLEN(username) from events
STRPOS
- Purpose
- Returns the position (index - starts at zero) of a string in another string. Searches in string for the index of the specified substring. You can optionally specify an extra parameter to indicate at what position (index) to start looking for the specified pattern.
- Examples
-
SELECT STRPOS(username, 'name') FROM events
SUBSTRING
- Purpose
- Copies a range of characters into a new string.
- Examples
-
SELECT SUBSTRING(userName, 0, 3) FROM events
UPPER
- Purpose
- Returns an all uppercase representation of a string.
- Example
-
SELECT UPPER(username), UPPER(LOGSOURCENAME(logsourceid)) FROM events
UTF8
- Purpose
- Returns the UTF8 string of a byte array.
- Example
-
SELECT UTF8(payload) FROM events WHERE sourceip='192.0.2.0'