Skip to content
Tutorials Center
My learning

Topics

Lesson 18 of 37 ยท Logs

Datadog Log Explorer: Search Syntax, Facets, Patterns and Analytics

Master the Datadog Log Explorer: search syntax with tags, attributes and wildcards, boolean logic, facets, list/timeseries/top list views, group by, patterns and saved views.

Logs only help if you can find the right ones fast. The Log Explorer (under Logs) has a search bar, a facet panel on the left, a time range, and views that turn a list into charts. Learning the search syntax pays back every incident. Datadog is not available on this site, so the examples are described as queries, and the stand-ins implement a tiny matcher so you can feel how the syntax behaves.

A search is a set of terms. By default terms are combined with AND.

TEXT
service:checkout status:error

finds logs from the checkout service whose status is error. Building blocks:

Syntax Meaning
error Free text in the message
"payment failed" Exact phrase
service:checkout Reserved attribute or tag key:value
@http.status_code:500 Parsed attribute (note the @)
@http.status_code:>=500 Numeric comparison (>, >=, <, <=)
@duration:[100 TO 500] Numeric range (inclusive)
host:web-* Wildcard: * any characters, ? one character
-status:info Negation (also NOT)
status:(error OR warn) Grouping with OR
env:prod AND (service:a OR service:b) Boolean logic with parentheses
@user.id:* The attribute exists
[email protected]:* The attribute is missing

Remember: tags and reserved attributes (host, service, status, source, env) have no @; custom attributes you parsed do. Many people lose an hour searching http.status_code:500 and getting nothing; the fix is @http.status_code:500. An attribute must be a facet to appear in the sidebar and be used for grouping, but you can search any attribute directly with @.

Special characters in values (/, :, spaces) need backslash escaping or quotes: @http.url:"/api/v1/cart" or @http.url:\/api\/v1\/cart.

Facets and measures

A facet is an indexed attribute or tag you can filter and group by. A measure is a numeric facet (duration, bytes) that supports ranges and statistics. Create one by clicking an attribute in a log's detail panel and choosing Create facet / measure for @attribute. Attributes without a facet remain searchable with @; a facet adds the sidebar filter and grouping. Facets are the left-panel filters: click values to build the query without typing.

Choose facets for things you group by often: @http.status_code, @http.method, @usr.id is too high-cardinality for casual grouping (it is fine to search by it). Name attributes to a consistent standard (for example http.status_code, duration, error.kind) so one facet works across services.

The Visualize as control changes how results appear, while the query and time range stay the same:

  • List shows individual logs, with chosen columns. Click one to open the side panel: raw message, attributes, tags, related trace and the host's metrics.
  • Timeseries charts counts or measure statistics over time, optionally grouped (group by @http.status_code).
  • Top List ranks values (top 10 endpoints by errors).
  • Table gives multi-dimension breakdowns.
  • Tree map, pie, scatter plot and Patterns offer other angles.

You can export any of these to a dashboard widget or a monitor with one click, which is the standard path to an alert such as "error logs for checkout above 50 in 5 minutes".

Log Patterns

When 40,000 similar errors drown you, switch to Patterns. Datadog clusters logs by their text shape, replacing variable parts (IDs, numbers) with placeholders, and shows how many logs fit each pattern and how that changes over time. A new pattern after a deploy is often the cause.

  • Time: use the time picker or drag on a chart to zoom. Logs show in your selected timezone (UTC toggle available).
  • Live Tail streams logs in real time with a filter, ideal while reproducing a bug. Live Tail does not need logs to be indexed.
  • Related items: from a log you can open the trace, the host or container, and from a trace you can see logs.
  • Saved views keep a query, columns and time range for you or your team (for example "Checkout errors").
  • Shortcuts: click a value in the side panel to add it to the query; hold shift to exclude it.

Reading the numbers correctly

Counts in the explorer cover indexed logs only. If an exclusion filter drops 90% of info logs, then "how many info logs" is wrong in the explorer, but a log-based metric (see the next lesson) counts logs before exclusion and stays accurate. Also note that sampled or excluded logs cannot be rehydrated later unless you archive them.

Python Stand-in: a mini log search

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Stand-in: group by and top list over logs

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The first stand-in implements only a few operators, so it is a toy; the real search bar also supports phrases, ranges, OR, parentheses and more.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which query finds logs whose parsed attribute http.status_code is 500 or higher?

    Custom attributes need the @ prefix, and >= works for numeric comparisons.
  2. 2. How do you exclude info logs?

    A leading minus (or NOT) negates the term.
  3. 3. What view groups logs by text shape to find a new error type after a deploy?

    Patterns cluster similar messages and show counts over time.
  4. 4. Why can explorer counts understate the real number of logs?

    Exclusion filters drop logs from the index; log-based metrics count before exclusion.

Summary

  • Search terms combine with AND; use quotes, -, OR, parentheses, wildcards and ranges.
  • Tags and reserved attributes are plain key:value; parsed attributes need @.
  • Facets and measures power filters and grouping; views include list, timeseries, top list, table and patterns.
  • Live Tail streams logs; saved views and one-click widget/monitor creation speed up routine work.

Next: Log Indexes, Archives and Log-Based Metrics