QRadar AQL
Authoritative AQL query patterns for extracting QRadar event inventory, severity distribution, migration inputs, and offense-oriented views.
Ariel Query Language (AQL) is QRadar’s structured query language for the Ariel event and flow database. AQL syntax is SQL-like but not SQL. It has QRadar-specific functions, clauses, and behavioral differences. Queries can be submitted via the Log Activity console UI or via the REST API. See QRadar API for API submission workflow.
Field Model
| Field | Type | Description |
|---|---|---|
|
NUMBER |
Internal ID of the log source. Use |
|
NUMBER |
Internal ID of the log source type. Use |
|
NUMBER |
QRadar event ID. Use |
|
NUMBER |
QRadar category ID. Use |
|
NUMBER (0-10) |
How serious the event is. |
|
NUMBER (0-10) |
How trustworthy the source is. Low credibility often indicates noisy or unreliable sources. |
|
NUMBER (0-10) |
How relevant the event is to the network environment. |
|
NUMBER (0-10) |
Composite of severity, credibility, and relevance. Primary driver of offense generation. |
|
TIMESTAMP |
Device-reported event time. Use for time filtering. |
|
NUMBER |
Number of bundled events represented by the record. |
Time Filtering
AQL without a time clause queries only the last 5 minutes of Ariel data by default. Always be explicit about time range.
devicetime was the reliable time field in QRadar 7.5.0 UP13.
STARTTIME was unreliable and queries using it returned no results.
LAST N DAYS syntax was not supported in QRadar 7.5.0 UP13.
Epoch values in QRadar 7.5.0 UP13 were non-standard, roughly in the 1.775E12 range.
Always run a MIN/MAX devicetime query first to confirm the actual data window before applying filters.
| Approach | Syntax |
|---|---|
No time filter (all available data) |
Omit the |
Specific epoch range |
|
|
Do not use. Causes parse error. |
AQL Functions
| Function | Available in 7.5.0 UP13 | Purpose |
|---|---|---|
|
Yes |
Resolve log source ID to name. |
|
Yes |
Resolve device type ID to vendor or technology name. |
|
Yes |
Resolve QID to event name. |
|
Yes |
Resolve category ID to category name. |
|
No |
High-level category helper not available and causes parse error. |
|
Yes |
Standard aggregate functions. |
AQL Gotchas
|
Production-verified against QRadar 7.5.0 UP13 at CHLA. |
| Gotcha | Detail |
|---|---|
Default window is 5 minutes |
AQL without a time clause only queries the last 5 minutes. Always specify a time range explicitly. |
|
Causes parse error in QRadar 7.5.0 UP13. Use |
|
Field was not reliably populated. Use |
|
Values were in the |
|
Not available in QRadar 7.5.0 UP13. Use |
|
Offenses are only accessible via REST API at |
GROUP BY required for COUNT |
Any non-aggregate column in |
|
When reading results via oracledb thin mode. Avoid selecting timezone timestamp columns directly. Use plain |
Ariel retention approximately 3 days at CHLA |
Approximately 3 days of data were available. Extend retention or pull from archive for longer windows. |
Data Shaping for Pandas
When exporting for pandas processing:
-
Avoid
TIMESTAMP(6) WITH TIME ZONEcolumns. They causeDPY-3022in oracledb thin mode. -
Use
COUNT(*)rather thaneventcountfor grouped aggregations. -
Lookup functions such as
LOGSOURCENAME,QIDNAME, andCATEGORYNAMEresolve at query time. -
Results via the REST API return as JSON. Use
pd.json_normalize(data["events"])to load them into a DataFrame. -
Column names in results match the
ASaliases defined in the query.
Query Patterns
SELECT MIN(devicetime) AS earliest, MAX(devicetime) AS latest FROM events
SELECT COUNT(*) AS TotalRawEvents, SUM(eventcount) AS TotalEventCount FROM events
SELECT
LOGSOURCENAME(logsourceid) AS LogSource,
LOGSOURCETYPENAME(devicetype) AS LogSourceType,
QIDNAME(qid) AS EventName,
CATEGORYNAME(category) AS Category,
severity,
credibility,
relevance,
magnitude,
COUNT(*) AS EventCount
FROM events
GROUP BY logsourceid, devicetype, qid, category,
severity, credibility, relevance, magnitude
ORDER BY LogSource, EventCount DESC
SELECT
LOGSOURCENAME(logsourceid) AS LogSource,
COUNT(*) AS EventCount
FROM events
GROUP BY logsourceid
ORDER BY EventCount DESC
SELECT DISTINCT
LOGSOURCENAME(logsourceid) AS LogSource,
LOGSOURCETYPENAME(devicetype) AS LogSourceType
FROM events
SELECT
CATEGORYNAME(category) AS Category,
COUNT(*) AS EventCount
FROM events
GROUP BY category
ORDER BY EventCount DESC
SELECT
severity,
COUNT(*) AS EventCount
FROM events
GROUP BY severity
ORDER BY severity DESC
SELECT
magnitude,
COUNT(*) AS EventCount
FROM events
GROUP BY magnitude
ORDER BY magnitude DESC
SELECT
LOGSOURCENAME(logsourceid) AS LogSource,
QIDNAME(qid) AS EventName,
CATEGORYNAME(category) AS Category,
severity,
magnitude,
COUNT(*) AS EventCount
FROM events
WHERE magnitude >= 7
GROUP BY logsourceid, qid, category, severity, magnitude
ORDER BY magnitude DESC, EventCount DESC
SELECT
QIDNAME(qid) AS EventName,
COUNT(*) AS EventCount
FROM events
GROUP BY qid
ORDER BY EventCount DESC
SELECT sourceip, COUNT(*) AS EventCount
FROM events
GROUP BY sourceip
ORDER BY EventCount DESC
SELECT
LOGSOURCENAME(logsourceid) AS LogSource,
COUNT(*) AS EventCount
FROM events
WHERE devicetime BETWEEN 1775529395000 AND 1775719679000
GROUP BY logsourceid
ORDER BY EventCount DESC
SELECT
LOGSOURCENAME(logsourceid) AS LogSource,
LOGSOURCETYPENAME(devicetype) AS LogSourceType,
QIDNAME(qid) AS EventName,
CATEGORYNAME(category) AS Category,
severity,
credibility,
relevance,
magnitude,
COUNT(*) AS EventCount
FROM events
GROUP BY logsourceid, devicetype, qid, category,
severity, credibility, relevance, magnitude
ORDER BY LogSource, EventCount DESC
SELECT severity, credibility, relevance, magnitude FROM events LIMIT 5
SELECT CATEGORYNAME(category) AS Category FROM events LIMIT 5
SELECT
LOGSOURCENAME(logsourceid) AS LogSource,
LOGSOURCETYPENAME(devicetype) AS LogSourceType
FROM events LIMIT 5
SELECT view_name
FROM all_views
WHERE owner = 'DATACONNECT'
ORDER BY view_name
SELECT column_name, data_type
FROM all_tab_columns
WHERE owner = 'DATACONNECT'
AND table_name = 'RADIUS_AUTHENTICATIONS_WEEK'
ORDER BY column_id
Quick Reference
| Query | Purpose |
|---|---|
|
Confirm available data window. Always run first. |
|
Validate total event volume. |
|
Quick source inventory with type. |
|
Category breakdown. |
|
Severity distribution. |
|
Magnitude distribution. |
|
Top event names. |
|
Source IP hotspots. |
|
List ISE DataConnect views. |
|
Inspect view schema. |
|
Version gotchas for QRadar 7.5.0 UP13:
|