{"id":40844,"date":"2023-10-07T17:39:09","date_gmt":"2023-10-07T17:39:09","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=40844"},"modified":"2023-10-07T17:39:11","modified_gmt":"2023-10-07T17:39:11","slug":"dynatrace-tutorials-dynatrace-query-language-dql","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/dynatrace-tutorials-dynatrace-query-language-dql\/","title":{"rendered":"Dynatrace Tutorials: Dynatrace Query Language &#8211; DQL"},"content":{"rendered":"\n<p><strong>Chaining commands with the pipe operator<\/strong><\/p>\n\n\n\n<p>A DQL query contains at least one or more commands, each of which returns tabular output containing records (lines or rows) and fields (columns). All commands are sequenced by a | (pipe). The data flows or is funneled from one command to the next. The data is filtered or manipulated at each step and then streamed into the following step.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"190\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x190.png\" alt=\"\" class=\"wp-image-40845\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x190.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/10\/image-22-300x56.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/10\/image-22-768x143.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/10\/image-22-1536x286.png 1536w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/10\/image-22-2048x381.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The Dynatrace Query Language (DQL) is a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more based on data stored in Dynatrace Grail storage.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Here is a list of DQL commands:<\/h2>\n\n\n\n<p>Here is a list of DQL commands:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>fetch<\/strong>&nbsp;&#8211; Fetches data from a specific data type, such as logs, metrics, or business events.<\/li>\n\n\n\n<li><strong>filter<\/strong>&nbsp;&#8211; Filters the data based on a specified condition.<\/li>\n\n\n\n<li><strong>fields<\/strong>&nbsp;&#8211; Selects the fields that you want to include in the output.<\/li>\n\n\n\n<li><strong>fieldsAdd<\/strong>&nbsp;&#8211; Adds new fields to the output.<\/li>\n\n\n\n<li><strong>parse<\/strong>&nbsp;&#8211; Parses the data into a different format.<\/li>\n\n\n\n<li><strong>summarize<\/strong>&nbsp;&#8211; Performs aggregations on the data, such as counting the number of rows, or finding the average value of a column.<\/li>\n\n\n\n<li><strong>sort<\/strong>&nbsp;&#8211; Sorts the data based on a specified field.<\/li>\n\n\n\n<li><strong>limit<\/strong>&nbsp;&#8211; Limits the number of rows that are returned in the output.<\/li>\n\n\n\n<li><strong>timeseries<\/strong>&nbsp;&#8211; Produces a time series of aggregated data.<\/li>\n\n\n\n<li><strong>fieldsSummary<\/strong>&nbsp;&#8211; Calculates the cardinality of field values that the specified fields have.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Here is a list of DQL Functions:<\/h2>\n\n\n\n<p>The following is a list of DQL functions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>avg<\/strong>&nbsp;&#8211; Calculates the average of the values in a column.<\/li>\n\n\n\n<li><strong>count<\/strong>&nbsp;&#8211; Counts the number of rows in a table.<\/li>\n\n\n\n<li><strong>count_distinct<\/strong>&nbsp;&#8211; Counts the number of distinct&nbsp;values in a column.<\/li>\n\n\n\n<li><strong>first<\/strong>&nbsp;&#8211; Returns the first value in a column.<\/li>\n\n\n\n<li><strong>last<\/strong>&nbsp;&#8211; Returns the last value in a column.<\/li>\n\n\n\n<li><strong>max<\/strong>&nbsp;&#8211; Returns the maximum value in a column.<\/li>\n\n\n\n<li><strong>min<\/strong>&nbsp;&#8211; Returns the minimum value in a column.<\/li>\n\n\n\n<li><strong>percentile<\/strong>&nbsp;&#8211; Returns the percentile value of the values in a column.<\/li>\n\n\n\n<li><strong>sum<\/strong>&nbsp;&#8211; Calculates the sum of the values in a column.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">DQL operators<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"numerical-operators\">Numerical operators<\/h2>\n\n\n\n<p>The types&nbsp;<code>long<\/code>,&nbsp;<code>double<\/code>&nbsp;and&nbsp;<code>timestamp<\/code>&nbsp;real represent numerical types. The following operators can be used between pairs of these types<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Operator<\/th><th>Description<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td><code>+<\/code><\/td><td>Addition<\/td><td><code>2+2.5<\/code><\/td><\/tr><tr><td><code>-<\/code><\/td><td>Subtraction<\/td><td><code>0.2-0.11<\/code><\/td><\/tr><tr><td><code>*<\/code><\/td><td>Multiplication<\/td><td><code>4*5, 60*1s<\/code><\/td><\/tr><tr><td><code>\/<\/code><\/td><td>Division<\/td><td><code>10\/2, 1h\/60<\/code><\/td><\/tr><tr><td><code>%<\/code><\/td><td>Modulo<\/td><td><code>4%2<\/code><\/td><\/tr><tr><td><code>&lt;<\/code><\/td><td>Lower<\/td><td><code>8 &lt; 9, now()-1m &lt; now()<\/code><\/td><\/tr><tr><td><code>&lt;=<\/code><\/td><td>Lower than or equal<\/td><td><code>4&lt;=5<\/code><\/td><\/tr><tr><td><code>&gt;<\/code><\/td><td>Greater<\/td><td><code>5 &gt; 4<\/code><\/td><\/tr><tr><td><code>&gt;=<\/code><\/td><td>Greater than or equal<\/td><td><code>4 &gt;=4<\/code><\/td><\/tr><tr><td><code>==<\/code><\/td><td>Equals<\/td><td><code>2 == 2<\/code><\/td><\/tr><tr><td><code>!=<\/code><\/td><td>Not equals<\/td><td><code>1 != 2<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"dql-logical-or-equality-operators\">Logical or equality operators<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Operator<\/th><th>Description<\/th><th>Example (yields true)<\/th><\/tr><\/thead><tbody><tr><td><code>==<\/code><\/td><td>Equals &#8211; Yields true if both operands are not null and equal to each other. Otherwise, false.<\/td><td><code>2==2<\/code>,&nbsp;<code>\"a\" == \"a\"<\/code><\/td><\/tr><tr><td><code>!=<\/code><\/td><td>Not equals &#8211; Yields null, if one of the operands is null, or if the operands are not equal to each other.<\/td><td><code>2!=1, \"b\" != \"a\"<\/code><\/td><\/tr><tr><td><code>NOT<\/code><\/td><td>Negation &#8211; Negates a logical state<\/td><td><code>NOT 2==1<\/code><\/td><\/tr><tr><td><code>AND<\/code><\/td><td>Logical and (multiplication) &#8211; Yields true if both operands are true.<\/td><td><code>NOT 2==1 AND 1&lt;2<\/code><\/td><\/tr><tr><td><code>OR<\/code><\/td><td>Logical or (addition) &#8211; Yields true if one of the operands is true, regardless of the other operand.<\/td><td><code>1 &lt; 2 OR 1 &gt; 2<\/code><\/td><\/tr><tr><td><code>XOR<\/code><\/td><td>Exclusive or &#8211; Yields true if one of the operands is true, but false in case both are true.<\/td><td><code>1 &lt; 2 XOR 1 &gt; 2<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Chaining commands with the pipe operator A DQL query contains at least one or more commands, each of which returns tabular output containing records (lines or rows) and fields (columns). All commands are sequenced by a | (pipe). The data flows or is funneled from one command to the next. The data is filtered or&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-40844","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/40844","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=40844"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/40844\/revisions"}],"predecessor-version":[{"id":40846,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/40844\/revisions\/40846"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=40844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=40844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=40844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}