Logstreem
Worked examples

Worked examples

Queries that answer questions you will actually be asked.

Each of these is copy-paste ready against a dataset with the usual HTTP fields. Adjust the dataset name and go.

What is broken right now?

LSQL
read top to bottom
1['api-gateway-prod']
2| where _time > ago(15m)
3| summarize requests = count(), errors = countif(status >= 500) by service
4| extend error_rate = round(100.0 * errors / requests, 2)
5| where errors > 0
6| order by error_rate desc

The slowest endpoint, with context

LSQL
read top to bottom
1['api-gateway-prod']
2| where _time > ago(1h)
3| summarize p95 = percentile(latency, 95), calls = count() by route
4| where calls > 50
5| order by p95 desc
6| take 10

Did the deploy make it worse?

LSQL
read top to bottom
1['api-gateway-prod']
2| where _time > ago(2h)
3| extend window = iff(_time < ago(1h), "before", "after")
4| summarize p95 = percentile(latency, 95), errors = countif(status >= 500) by service, window
5| order by service asc, window asc

Which service is costing me the most?

LSQL
read top to bottom
1['api-gateway-prod']
2| where _time > ago(7d)
3| summarize events = count(), bytes = sum(estimate_size()) by service
4| extend share = round(100.0 * bytes / toscalar(sum(bytes)), 1)
5| order by bytes desc

Follow one request across services

LSQL
read top to bottom
1['api-gateway-prod']
2| where ['trace.id'] == "7b2d93c3ab4c2f10"
3| project _time, service, route, status, latency, message
4| order by _time asc

Errors we have never seen before

LSQL
read top to bottom
1['api-gateway-prod']
2| where _time > ago(1h) and status >= 500
3| summarize seen_now = count() by message
4| join kind=leftanti (
5 ['api-gateway-prod']
6 | where _time between (ago(30d) .. ago(1h)) and status >= 500
7 | distinct message
8 ) on message
9| order by seen_now desc

Save the ones you re-run

Any of these can become a saved query, a dashboard element or a monitor without being rewritten.