Aql Flow and Event Query Cli Guide: Ibm Security Qradar
Aql Flow and Event Query Cli Guide: Ibm Security Qradar
Note: Before using this information and the product that it supports, read the information in Notices and
Trademarks on page 21.
© Copyright IBM Corp. 2012, 2013 All Rights Reserved US Government Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
CONTENTS
The AQL Event and Flow Query CLI Guide provides you with information for using
the AQL CLI. This guide assumes you have advanced knowledge of Linux
command line functionality.
Intended Audience This guide is intended to inform users of the commands required to view event or
flow data stored in the ariel database.
NOTE
Indicates that the information provided is supplemental to the associated feature
or instruction.
CAUTION
Indicates that the information is critical. A caution alerts you to potential loss of
data or potential damage to an application, system, device, or network.
WARNING
Indicates that the information is critical. A warning alerts you to potential dangers,
threats, or potential personal injury. Read any and all warnings carefully before
proceeding.
Technical For information on how to access more technical documentation, technical notes,
Documentation and release notes, see the Accessing IBM Security QRadar Documentation
Technical Note.
(http://www.ibm.com/support/docview.wss?rs=0&uid=swg21614644)
Contacting For information on contacting customer support, see the Support and Download
Customer Support Technical Note.
(http://www.ibm.com/support/docview.wss?rs=0&uid=swg21612861)
You can use the AQL Event and Flow Query Command Line Interface (CLI) to
access flows and events stored in the Ariel database.
About the AQL The AQL Event and Flow Query CLI allows you to access raw flows and events
Query CLI stored in the Ariel database. The AQL query CLI includes syntax that is a subset of
the SQL92 standard and provides support for two tables: events and flows.
NOTE
The AQL CLI does not provide support for joining tables.
The AQL Event and Flow Query CLI functions in the following modes:
• Interactive mode - This is the default mode. Using a simple shell, you can
enter queries interactively and view the results in a standard output. At the
query prompt, any valid AQL statement is accepted. If time is not specified
(using -start and -end options), the last minute is assumed as the time
range. You can also access previous commands by using the Up arrow key.
• Non-interactive mode - You can enter the non-interactive mode by adding the
-execute <AQL query> parameter to the command. The -execute
command must be followed by a valid AQL query surrounded by double quotes.
Non-interactive mode does not include a prompt enabling you to redirect the
output to a file using regular UNIX pipe syntax. By default, the results are sent
to a standard output.
Option Description
-range <first Restricts the number of records sent to the output within the
record> <last specified range. This is used for viewing a selection of
record> records generated by an ordered query. For example, if you
want to view the first ten records, you must specify -range 1
10.
-debug Generates debugging output during execution.
-start <time>, Specifies the start and end time of the query.
-end <time>
Where <time> specifies the time. You must specify the time
as either a UNIX timestamp or a date using the following
format: yyyy/mm/dd-hh:mm:ss.
For example:
/opt/qradar/bin/arielClient - start
2007/08/11-01:15:00 -end 2007/08/11-01:17:00
-exectime <time Specifies the maximum period of time, in seconds, a single
limit> query will continue processing.
-execute <AQL Enables non-interactive mode that is used to process a query
query> that is sent to standard output. The query must include double
quotes. If you do not include this option, the command is
entered in interactive mode.
Option Description
-f <output Specifies the output format for the query results. The table
format> format is an ASCII drawing of a multi-column table while the
csv format provides a comma separated list.
Where <output format> indicates the output format. The
options are table or csv.
-remote Specifies the connection to a specific Ariel query host and
<host:port> port.
For example:
Using a Select You can use a select statement that includes one or more fields from the flow or
Statement event tables. You can also use an asterisk (*) to denote all columns. All field names
are case sensitive, however, the terms select and from are not case sensitive.
For example:
select sourceIP, destinationIP, application from flows where
protocol = ‘TCP.tcp_ip’
select category, credibility from events where severity > 8
select * from events where credibility >=9
NOTE
All fields on the event and flow tables can be selected. The idlist.sh shell script
determines the most commonly used fields when the describe command is
used. These fields are denoted in Table 1-2. For more information on using the
describe command, see Listing AQL Fields.
Visible using
Table Field Name Description Field Type describe
Flows anyDestinationFlag Destination Flags Numeric No
anySourceFlag Source Flags Numeric No
application Application String Yes
applicationId Application Numeric Yes
bytesIn Bytes In Numeric No
bytesOut Bytes Out Numeric No
destinationAssetName Destination Asset Name String No
destinationASN Destination ASN Numeric Yes
destinationBytes Destination Bytes Numeric Yes
destinationByteRatio Destination Byte Ratio Numeric No
destinationDSCP Destination DSCP Numeric Yes
destinationDscpOnly Destination DSCP Numeric No
destinationFlags Destination Flags Numeric Yes
destinationIP Destination IP String Yes
destinationIPSearch Destination IP Search String No
destinationIfIndex Destination If Index Numeric Yes
destinationNetwork Destination Network String Yes
destinationPackets Destination Packets Numeric Yes
destinationPacketRatio Destination Packet Ratio Numeric No
destinationPayload Destination Payload String Yes
destinationPayloadHex Destination Payload As Hex Hexadecimal No
destinationPort Destination Port Numeric Yes
destinationPrecedence Destination Precedence Numeric Yes
destinationPrecedanceOnly Destination Precedence Numeric No
destinationTOS Destination QoS Composite Yes
destinationv6 IPv6 Destination Hexadecimal No
firstPacketTime First Packet Time Numeric Yes
flowBias Flow Bias String Yes
flowDirection Flow Direction: String Yes
• Local-to-Local (L2L)
• Local-to-Remote (L2R)
• Remote-to-Local (R2L)
• Remote-to-Remote (R2R)
flowSource Flow Source Numeric Yes
flowType Flow Type Numeric Yes
Visible using
Table Field Name Description Field Type describe
geographic Matches Geographic Location String Yes
hasDestinationPayload Has Destination Payload Boolean No
hasSourcePayload Has Source Payload Boolean No
icmpType ICMP Type/Code Numeric Yes
interface Flow Interface String Yes
intervalId Interval ID Numeric Yes
lastPacketTime Last Packet Time Numeric Yes
packetsIn Packets In Numeric No
packetsOut Packets Out Numeric No
protocol Protocol String Yes
protocolId Protocol Numeric Yes
remoteHost Remote Host String No
remoteNet Matches Remote Network String No
remoteServices Matches Remote Service String No
sourceASN Source ASN Numeric Yes
sourceAssetName Source Asset Name String No
sourceByteRatio Source Byte Ratio Numeric No
sourceBytes Source Bytes Numeric Yes
sourceDSCP Source DSCP Numeric Yes
sourceDscpOnly Source DSCP Numeric No
sourceFlags Source Flags Numeric Yes
sourceIP Source IP String Yes
sourceIPSearch Source IP Search String No
sourceIfIndex Source If Index Numeric Yes
sourceNetwork Source Network String Yes
sourceOrDestinationIP Source or Destination IP String No
sourcePackets Source Packets Numeric Yes
sourcePacketRatio Source Packet Ratio Numeric No
sourcePayload Source Payload String Yes
sourcePayloadHex Source Payload As Hex Hexadecimal No
sourcePort Source Port Numeric Yes
sourcePrecedence Source Precedence Numeric Yes
sourcePrecedanceOnly Source Precedence Numeric No
sourceTOS Source QoS Composite Yes
sourcev6 IPv6 Source Hexadecimal No
Visible using
Table Field Name Description Field Type describe
token Associated With Offense Numeric Yes
totalBytes Total Bytes Numeric No
totalPackets Total Packets Numeric No
viewObjectPair View/Object String No
Events category Low Level Category Numeric Yes
creEventList Matched Custom Rule String No
credibility Credibility Numeric Yes
destinationAssetName Destination Asset Name String No
destinationIP Destination IP String Yes
destinationMAC Destination MAC Hexadecimal Yes
destinationNetwork Destination Network String Yes
destinationPort Destination Port Numeric Yes
destinationv6 IPv6 Destination Hexadecimal No
device Log Source Numeric Yes
deviceGroup Log Source Group Numeric Yes
deviceTime Log Source Time Numeric No
deviceType Log Source Type Numeric Yes
duration Duration Numeric Yes
endTime End Time Numeric Yes
eventCount Event Count Numeric Yes
eventDirection Event Direction: String Yes
• Local-to-Local
• Local-to-Remote
• Remote-to-Local
• Remote-to-Remote
eventProcessor Event Processor Numeric Yes
hasIdentity Has Identity Boolean Yes
hasOffense Associated With Offense Boolean Yes
highLevelCategory High Level Category Numeric Yes
isCREEvent Is CRE Event Boolean No
identityExtendedField Identity Extended Field String Yes
identityGroupName Identity Group Name String Yes
identityHostName Identity Host Name String Yes
identityIP Identity IP String Yes
identityMAC Identity MAC Hexadecimal Yes
Visible using
Table Field Name Description Field Type describe
identityNetBiosName Identity NetBIOS Name String Yes
identityUserName Identity User Name String Yes
magnitude Magnitude Numeric Yes
payload Payload String Yes
payloadHex Payload As Hex Hexadecimal No
postNatDestinationIP Post NAT Destination IP String Yes
postNatDestinationPort Post NAT Destination Port Numeric Yes
postNatSourceIP Post NAT Source IP String Yes
postNatSourcePort Post NAT Source Port Numeric No
preNatDestinationIP Pre NAT Destination IP String Yes
preNatDestinationPort Pre NAT Destination Port Numeric Yes
preNatSourceIP Pre NAT Source IP String Yes
preNatSourcePort Pre NAT Source Port Numeric Yes
protocol Protocol String Yes
qid Event Name ID Numeric Yes
relevance Relevance Numeric Yes
severity Severity Numeric Yes
sourceAssetName Source Asset Name String No
sourceIP Source IP String Yes
sourceMAC Source MAC Hexadecimal Yes
sourceNetwork Source Network String Yes
sourcePort Source Port Numeric Yes
sourcev6 IPv6 Source Hexadecimal No
startTime Start Time Numeric Yes
token Token Associated With Offense Numeric Yes
unparsed Event Is Unparsed Boolean Yes
userName Username String Yes
You can also use CIDR-based queries using the select statement. To query by
source IP address (sourceIP) or by destination IP address (destinationIP) using a
CIDR, use the following format:
For example:
select * from flows where sourceCIDR = '10.100.100/24'
This command returns all flows coming from the 10.100.100 subnet. To capture
flows coming from and into the subnet, use the regular OR expression as follows:
select * from flows where sourceCIDR = '10.100.100/24' OR
destinationCIDR = '10.100.100/24'
For more information on flow or event fields described using idlist.sh, see
Identifying AQL Fields.
Using Where You can restrict your AQL queries using where clauses. The supported logical
Clauses operators in the clause include and, OR, and parentheses. AQL queries also
support the following relational operators:, =, <, >, >=, <=, and !=.
For example:
select sourceIP, category, credibility from events where
severity > 9 and category = 5013
select sourceIP, category, credibility from events where
(severity > 9 and category = 5013) or (severity < 5 and
credibility > 8)
The where clause also supports the arieltime variable, which overrides the time
settings passed to the AQL CLI. The arieltime variable must be used with the
between keyword to specify the start and end time bounds of the query. All time
You can only use the arieltime variable once in a single query. Therefore, you
can only query a continuous span of time in a single AQL command.
The logical operator for the arieltime variable and the remainder of the where
clause should be the and operator. We recommend that you use the arieltime
variable as the last constraint of the query and the and operator between the
arieltime variable and the rest of the where clause.
Using the Group By You can use the group by clause to aggregate your data. Normally, data
Clause aggregation is combined with arithmetic functions on remaining columns to provide
meaningful results of the aggregation. For example, to enter a query to investigate
the IP addresses that sent more than 1 million bytes within all flows in a specific
time frame, you must enter:
------------------------------
| sourceIP | sourceBytes |
------------------------------
| 64.124.201.151 | 1448629 |
| 10.105.2.10 | 2412426 |
| 10.103.70.243 | 1793095 |
| 10.103.77.143 | 1449148 |
| 10.105.32.29 | 1097523 |
| 10.105.96.148 | 4096834 |
| 64.124.201.151 | 2833961 |
| 10.105.2.10 | 2490083 |
| 10.103.73.206 | 1629768 |
| 10.103.70.243 | 1009620 |
| 10.105.32.29 | 1369660 |
| 10.103.77.143 | 1864222 |
| 10.105.96.148 | 4228522 |
------------------------------
In addition to the sum operator, the min, max, avgnonzero and avg arithmetic
aggregation functions are also supported.
Using the Order By You can add a single order by clause to the end of your AQL CLI query. Only
Clause one field can be used in the order by clause. Also, sorting can be switched
between ascending or descending by appending the asc or desc keyword to the
order by clause, respectively. By default, the query returns results in descending
order.
For example:
select sourceBytes, sourceIP from flows where sourceBytes >
1000000 order by sourceBytes
Combing the group by and the order by clauses in a single query can be used
to create data, such as TopN lists, to determine the most abnormal events or the
most bandwidth intensive IP addresses. For example, the following query displays
the most traffic intensive IP address in descending order:
Using the Count(*) You can use the count(*) clause to count the number of records matching your
Clause query. For example, if you want to count all events with credibility equal to or
greater than 9, type the following query:
Using the Distinct You can use the distinct clause to select unique rows based on a column or a
Clause group of columns. This clause is similar to the group by clause, however, the
distinct clause ensures ANSI SQL compatibility. For example:
Using the Count You can use the standard SQL Count(Distinct ...) clause to obtain unique
(Distinct ...) Clause counts. Using the AQL CLI, you can only use one field. For example, if you want to
view all the IP addresses that are connected to a specific IP address over time:
select count(distinct sourceIP) from flows where destinationIP =
'192.168.61.71'
Or, if you want to view the number of unique source IP addresses communicating
with a particular destination IP address:
select destinationIP, count(distinct sourceIP) from flows group
by destinationIP
Using UniqueCount also returns unique counts for items in the table:
select destinationIP, UniqueCount(sourceIP) from flows
NOTE
Using this clause could require additional system resources. Therefore,
depending on the query, the amount of time to return results could vary.
Using the The materialize view clause allows you to produce query results as a virtual
Materialize View table and run subsequent queries against the view. You can also specify the period
Clause of time that the materialized view is accessible.
Where:
• <time> specifies the time you want the materialized view to be
accessible.
• <statement> specifies a valid select statement.
For example, if you want to create a materialized view containing flows with
more than 1,000,000 source bytes, type the following command:
materialize view LargeSourceBytesFlows as select * from flows
where sourceBytes >1000000
To select from this view, enter the select statement as you would a valid table:
select * from LargeSourceBytesFlows
NOTE
You cannot create a materialized view statement based on a previously
created materialized view
Then you can refer to the alias in a subsequent query against MyView:
Using the Like You can search text fields using the standard like clause. You can also use the
Clause two wild card options supported by the AQL Query CLI: % and _. The percentage
(%) wild card option matches zero or more characters while the _ wild card option
only matches one character.
For example:
To match names such as Joe, Joanne, Joseph, or any other name beginning with
Jo, type the following query:
select * from events where userName like ‘jo%’
To match names beginning with Jo that are three characters long, such as, Joe or
Jon, type the following query:
select * from events where userName like ‘jo_’
You can enter the wild card option at any point in the command. For example:
select * from flows where sourcePayload like ‘%xyz’
select * from events where payload like ‘%xyz%’
select * from events where payload like ‘_yz’
Using the Boolean Boolean clauses allow you to restrict your AQL queries to return data matching
Clause values you specify using true or false with relational operators. AQL queries
support the following relational operators, = and !=.
For example:
To sort events that are unparsed, type the following query:
select * from events where payload = “false”
If you want to sort flows to find a specific source IP address that has an offense,
type the following query:
select * from events where sourceIP = '231.12.37.17' and
hasOffense = “true”
If you want to display a list of source IP addresses and protocols that have an
offense you can use BooleanTrueCount, and type the following query:
---------------------------------
| sourceIP | protocol |
---------------------------------
| 64.124.201.151 | TCP.tcp.ip |
| 10.105.2.10 | UDP.udp.ip |
| 10.103.70.243 | UDP.udp.ip |
| 10.103.77.143 | UDP.udp.ip |
| 10.105.32.29 | TCP.tcp.ip |
| 10.105.96.148 | TCP.tcp.ip |
| 64.124.201.151 | TCP.tcp.ip |
| 10.105.2.10 | ICMP.icmp.ip |
---------------------------------
Identifying AQL AQL queries to event or flow fields could return numeric codes making query
Fields responses or searches difficult. The shell script idlist.sh provides additional
information from numeric AQL fields in the event and flow tables.
Parameters Description
-f Specifies that the script is to identify a field from the flows table.
For example:
/opt/qradar/bin/idlist.sh -f application
-e Specifies that the script is to identify a field from the events table.
For example:
/opt/qradar/bin/idlist.sh -e category
<field name> Specifies the field name of the event or flow you want to identify. See
Table 1-2 for a complete list of fields that can be identified using
idlist.sh.
NOTE
You can search the idlist.sh output using standard operators such as fowardslash.
Search terms are case sensitive in the idlist.sh output.
Listing AQL Fields AQL supports a large number of field names for the event and flow tables. To view
a list of the most commonly used field names for a select statement, you can use
the describe command.
Step 4 Enter the following command to view a list of fields from the events table:
describe events
The following events are listed.
Table 1-6 Describe Events
Notices This information was developed for products and services offered in the U.S.A.
IBM may not offer the products, services, or features discussed in this document in
other countries. Consult your local IBM representative for information on the
products and services currently available in your area. Any reference to an IBM
product, program, or service is not intended to state or imply that only that IBM
product, program, or service may be used. Any functionally equivalent product,
program, or service that does not infringe any IBM intellectual property right may
be used instead. However, it is the user's responsibility to evaluate and verify the
operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter
described in this document. The furnishing of this document does not grant you
any license to these patents. You can send license inquiries, in writing, to:
IBM Director of Licensing
IBM Corporation
North Castle Drive
Armonk, NY 10504-1785 U.S.A.
For license inquiries regarding double-byte character set (DBCS) information,
contact the IBM Intellectual Property Department in your country or send inquiries,
in writing, to:
Intellectual Property Licensing
Legal and Intellectual Property Law
IBM Japan Ltd.
19-21, Nihonbashi-Hakozakicho, Chuo-ku
Tokyo 103-8510, Japan
The following paragraph does not apply to the United Kingdom or any other
country where such provisions are inconsistent with local law:
The licensed program described in this document and all licensed material
available for it are provided by IBM under terms of the IBM Customer Agreement,
IBM International Program License Agreement or any equivalent agreement
between us.
Information concerning non-IBM products was obtained from the suppliers of those
products, their published announcements or other publicly available sources. IBM
has not tested those products and cannot confirm the accuracy of performance,
compatibility or any other claims related to non-IBM products. Questions on the
All statements regarding IBM's future direction or intent are subject to change or
withdrawal without notice, and represent goals and objectives only.
All IBM prices shown are IBM's suggested retail prices, are current and are subject
to change without notice. Dealer prices may vary.
This information contains examples of data and reports used in daily business
operations. To illustrate them as completely as possible, the examples include the
names of individuals, companies, brands, and products. All of these names are
fictitious and any similarity to the names and addresses used by an actual
business enterprise is entirely coincidental.
If you are viewing this information softcopy, the photographs and color illustrations
may not appear.
Trademarks IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of
International Business Machines Corp., registered in many jurisdictions worldwide.
Other product and service names might be trademarks of IBM or other companies.
A current list of IBM trademarks is available on the Web at “Copyright and
trademark information” at http:\\www.ibm.com/legal/copytrade.shtml.
UNIX is a registered trademark of The Open Group in the United States and other
countries.