Lab_1_Common_Commands
Lab_1_Common_Commands
Common Commands
Practice DQL Basics - Labs
CONTENTS
1. Introduction .......................................................................................................................................... 3
2. Command: Fetch ................................................................................................................................... 3
⚙ 2.1 Lab – Fetch logs for a Specified Timeframe ........................................................................................................... 4
2.2 Additional Practice ............................................................................................................................................................ 4
3. Chaining Commands ............................................................................................................................. 5
⚙ 3.1 Lab – Chain Commands – Fetch and Sort ................................................................................................................5
3.2 Additional Practice ............................................................................................................................................................ 6
4. Command: Filter ................................................................................................................................... 7
⚙ 4.1 Lab – Filter ....................................................................................................................................................................... 7
4.2 Additional Practice............................................................................................................................................................ 8
5. Command: Limit .................................................................................................................................. 8
⚙ 5.1 Lab – Limit ...................................................................................................................................................................... 9
5.2 Additional Practice ............................................................................................................................................................ 9
2
1. Introduction
This lab introduces you to building query strings using Dynatrace Query Language. Within this lab you will use
the following commands:
• Fetch
• Sort
• Filter
• Limit
2. Command: Fetch
The DQL fetch command defines which data to load from Dynatrace. The fetch command requires a reference
to the kind of data that should be retrieved by the initial processing pipeline. This is called a resource.
By running the example query, fetch logs, Dynatrace will return all log records stored based on the global
timeframe specified within your environment.
A parameter is a named control offered by the user interface. Parameters can be added to a query to focus
your search. Here’s an example of a timeframe parameter. Based on this query, Dynatrace will query logs from
the last two hours.
3
Resources
4
3. Chaining Commands
After each operation, DQL returns a table or collection of tables containing data. To make the most of each
query statement we can add additional commands. To do this, use the operator | called a pipe.
The pipe operator funnels the records from the first table
into the next operator, where they will be further processed
or manipulated based on the next command used. Pipes
allow you to chain commands until the final, intended result
is achieved.
5
3.2 Additional Practice
You can also adjust your query down to the nanosecond. This example shows logs for a one-minute interval:
fetch logs, from:now() -1m
6
4. Command: Filter
The filter command allows you to narrow down the requested record using Boolean expressions. You will use
additional operators with filters to include or exclude specific values.
Resources
�
Here are some useful hints:
• Command: filterOut
• Function: isNull
• Function: if
• Function: concat
7
The results will look something like this:
5. Command: Limit
The Limit command allows you to indicate the number of
records that should be returned by your query. This is useful
when there are a large number of records that satisfy the query
conditions.
8
⚙ 5.1 Lab – Limit
The goal of this lab is to use the filter command to limit the number of records returned.
1. Navigate to Logs and Events
2. Enter the following query: fetch logs
3. On the next line, enter the following query: | limit 10
4. Run query.
The results will look something like this: