This Repo contains the labs we are going to work though as part of the Log on Grail - DQL Hands On Workshop.

For the purposes of the Hands-On, we will automate and make the steps seamless for the participants

Prerequisites

What You'll Learn

We will start with simple use-cases such as simple filters and aggregations to more refined scenarios where arithmetics is used to calculate time distances between significant events.

In this part the workshop tutor will explain the fundamentals of DQL.

Task: Get an Overview of the current state of the DQL capabilities by exploring the documentation

Task: Try to find narrow down the hosts where hipstershop is running

Intended result:assets/bootcamp/logs-dql/DQL_Logs_H1_intendedresult.png

Directions and supporting material

Task: Get an overview about whether processes suffer from significant logs on a specific host.

Intended result:assets/bootcamp/logs-dql/DQL_Logs_H2_intendedresult.png

Directions and supporting material

Task: Find the most recent ERROR log for a specific host

Intended result:

assets/bootcamp/logs-dql/DQL_Logs_H3_intendedresult.png

Directions and supporting material

Task: Calculate the age in seconds and minutes of the most recent Error log

Intended result:assets/bootcamp/logs-dql/DQL_Logs_H4_intendedresult.png

Directions and supporting material

Task: Did the same ip-address have both a successful and unsuccessful checkout event within a 10 minute time window?

Intended result:assets/bootcamp/logs-dql/DQL_Logs_H5_intendedresult.png

Directions and supporting material

...
| summarize success = countIf(http_s>=200 and http_s <=400), fail = ...  , by:{ip, bin(timestamp, 10m)}  | sort fail desc

Now let's go a few steps ahead and get a glimps what can already be done with DQL!

Task 6.1: Let‘s find all IP addresses that first have put a product into the cart and afterwards failed to checkout. Also, let‘s calculate the time distance between those events

Intended result:

assets/bootcamp/logs-dql/DQL_Logs_H61_intendedresult.png

Task 6.2: Calculating the time distance between cart events and checkout fails

Extend the query used in task 6.1 and add the following five pipeline processing steps and try to understand what happens. Feel free to add each line sequentially to see the intermediate results up to the final stage!

...
| fieldsAdd isCheckout = contains(content,"checkout")
| fieldsAdd checkout_fail_ts = if(isCheckout and http_s == 500, toLong(timestamp)), 
            cart_success_ts = if(NOT isCheckout and http_s <= 302, toLong(timestamp))
| summarize cart_success_first = first(cart_success_ts), checkout_fail_first = first(checkout_fail_ts), by:ip
| fieldsAdd delay_seconds = (checkout_fail_first - cart_success_first)/1000000000 
| fieldsAdd failAfterCart = if(delay_seconds > 0, true, else:false)

Intended result:

fetch logs, from:now()-30m
| filter host.name == "i-040585ffc09e5c519"
| filter contains(content, "POST /cart")
| parse content, "IPADDR:ip LD 'HTTP/1.1' SPACE LONG:http_s SPACE LD"
| fields timestamp, content, ip, http_s
| fieldsAdd isCheckout = contains(content,"checkout")
| fieldsAdd checkout_fail_ts = if(isCheckout and http_s == 500, toLong(timestamp)), 
 cart_success_ts = if(NOT isCheckout and http_s <= 302, toLong(timestamp))
| summarize cart_success_first = first(cart_success_ts), checkout_fail_first = first(checkout_fail_ts), by:ip
| fieldsAdd delay_seconds = (checkout_fail_first - cart_success_first)/1000000000 
| fieldsAdd failAfterCart = if(delay_seconds > 0, true, else:false)

assets/bootcamp/logs-dql/DQL_Logs_H62_intendedresult.png