Browse docs
On this page

dedup command

Keep the first row, or first N rows, for each distinct combination of fields.

All ObiQL commands

Keeps the first row, or the first N rows, for each distinct combination of the named fields, and drops the rest.

Which row counts as "first" depends on the order already in effect. Put a sort in front of dedup to choose which row survives. Without one, events are newest first, so dedup keeps the most recent.

Syntax

ObiQL
| dedup [<count>] <field> [, <field> ...]

Square brackets mark an optional part, and angle brackets a value you supply.

Arguments

ArgumentRequiredDescription
<count>OptionalHow many rows to keep for each combination. Defaults to 1.
<field>, ...RequiredThe fields whose combined values must be distinct. Separate them with commas or spaces.

Usage

  • Rows missing any of the named fields are dropped rather than grouped together.
  • sort, where and a second dedup cannot follow dedup. Move them in front of it.
  • stats and timechart can follow dedup, and aggregate one row per key. After a stats, dedup removes duplicate aggregate rows by their group fields.

Examples

1. The latest event from each host of each service

ObiQL
| dedup service, host

One row per service and host pair, the newest one.

2. Three samples per service

ObiQL
level="error" | dedup 3 service

Up to three of the newest errors from each service.

3. Keep the slowest request per route

ObiQL
| sort -duration_ms | dedup route

The sort makes the slowest request the first row for each route.

4. Count data that was collected more than once

ObiQL
| dedup cost_date, app | stats sum(amount) by app

Sums one row per date and app, so duplicates do not inflate the total.