Work with Queries in Trace Explorer
You can work with the out-of-the-box queries displayed in the Quick Picks in Trace Explorer or edit them to filter trace data by dimensions.
About Trace Explorer Queries
A query in Trace Explorer follows a simplified SQL-like syntax and consists of:
- Clauses: Statements that filter, categorize, and display information in Trace Explorer.
- Dimensions: Metadata or attributes defined by tagging a span, which enable the effective monitoring of the various tiers of an application. A complete list of dimensions is available in Fields in Trace Explorer.
The queries in Trace Explorer are a combination of clauses and dimensions, which you can use to filter trace data. You can either use the out-of-the-box queries available in each quick pick such as Traces and Services or edit these queries to further customize results to meet your specific requirements.
When editing queries, add or update clauses in the order given in the
following syntax. The required clause is in italics
and the
other clauses are optional.
SHOW (TRACES) or (SPANS)
dimensioncolumnsToShow_oneOrMore
WHERE filtersdimensions_oneOrMore
GROUP BY dimensioncolumnsToShow_oneOrMore
HAVING expressionOverdimensionColumns_one
ORDER BY dimensioncolumnsToShow_oneOrMore
FIRST <n> ROWS
TIMESERIES (FOR dimensions_oneOrMore) (<n> minutes)
BETWEEN time AND time
In the syntax, note that ' '
(single quotes) are used
for string constants and " "
(double quotes) for quoted
identifiers. If the identifier is a single word, then the double quotes are
optional. Note that the dimension values added with various clauses such as
where
and group by
are case-sensitive.
Arithmetic operations such as, addition, subtraction, multiplication, and division, can be used in expressions as you can see below:
show (traces) min(UserName) as "User Name",
min(BrowserName) as "Browser Name",
min(BrowserVersion) as "Browser Version",
sum(PageResponseTime) as "Total Response Time",
sum(PageViews) as "Page Views",
sum(ErrorCount) as "Error Count",
count(*) as "Traces",
avg(ConnectTime) as "Connect Time",
max(TraceLatestSpanEndTime) - min(TraceFirstSpanStartTime) as "Session Duration"
where ApmrumPageUpdateType is not omitted OR ApmrumType='Connection'
group by SessionId
order by max(TraceLatestSpanEndTime) - min(TraceFirstSpanStartTime)
Detailed information on the clauses that can be used in a Trace Explorer query is given in the following table:
Clause | Description |
---|---|
show |
Specifies the source of the base data for the query, which can be spans, traces, or a request for trace or span dimensions.
Example:
This is not a required clause. If not specified, the query assumes that all traces must be displayed. |
Selection clause |
Finds a set of traces or spans that will be searched by the rest of the query. Syntax: Example:
A limit is required in this clause, as only a limited number of items may be used for the search, and this clause can only be used inside a trace query. |
Returned Expressions clause | Specifies which trace or span dimensions or aggregate functions must be displayed as columns in the list. The as identifier optionally provides an alias for each column heading. Note that the alias must be unique.
Example:
Note that if there is a space after the Here are the supported functions that can be used with this clause:
|
where |
Filters the results before they are grouped.
Example:
Here are the supported expressions:
|
group by |
Groups the results by a certain dimension and
displays them in rows.
Example:
If the
Example:
In the
example, the spans are grouped by the |
having |
Further filters the results grouped by the
group by clause.
Example:
|
order by |
Defines the ordering of the list by a particular
dimension in ascending (asc ) or descending
(desc ) order.
Example:
This is an optional clause and if it's not specified, then the following order is displayed by default:
|
Limit clause | Limits the list to the specified number. If omitted, the default is FIRST 100 ROWS .
Example:
|
timeseries |
Displays a times series graph for the dimensions selected in the select clause for a defined time range. You can determine the dimension for which you want to see the time series graph in the timeseries clause, and if a dimension is not specified, then the time series graphs are displayed for each numeric dimension in the Returned Expressions clause.
The supported time ranges are 1 minute, 15 minutes, 60 minutes, and 720 minutes. If the time range ( Examples:
|
between |
Displays results for the selected timestamps in UTC
time. If this clause is used, it overrides the time period selected
in Trace Explorer.
Example:
|