On this page
dedup command
Keep the first row, or first N rows, for each distinct combination of fields.
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
| Argument | Required | Description |
|---|---|---|
<count> | Optional | How many rows to keep for each combination. Defaults to 1. |
<field>, ... | Required | The 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, hostOne row per service and host pair, the newest one.
2. Three samples per service
ObiQL
level="error" | dedup 3 serviceUp to three of the newest errors from each service.
3. Keep the slowest request per route
ObiQL
| sort -duration_ms | dedup routeThe 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 appSums one row per date and app, so duplicates do not inflate the total.