On this page
lookup command
Enrich results from a lookup table. On its own it finds the field named after the table's key column and adds every other column.
Enriches results with columns from a lookup table, matching an event field against the table's key column. Events with no match pass through unchanged.
On its own, | lookup <table> finds the event field that best matches the table's key column by name and adds every other column of the table.
Syntax
ObiQL
| lookup <table> [<event field> [AS <key column>]] [OUTPUT <column> [, <column> ...]]Square brackets mark an optional part, and angle brackets a value you supply.
Arguments
| Argument | Required | Description |
|---|---|---|
<table> | Required | The lookup table to read. Quote a name that contains a space: | lookup "Prod Hosts". |
<event field> | Optional | The event field to match on. Leave it off to match on the event field whose name is closest to the table's key column. |
AS <key column> | Optional | The table's key column, when its name differs from the event field. Omit it when the names match. |
OUTPUT <column>, ... | Optional | The table columns to add to matching events. Leave it off to add every column that is not a key column. |
Usage
- Unmatched events are kept and gain no new columns.
- eval, stats, timechart and fields can use the columns a lookup adds. where, sort, dedup, rename and the argument of an aggregation cannot, and say so with an error.
Examples
1. Add the owning team to each event
ObiQL
service=web-frontend | lookup hostname_map hostname AS host OUTPUT owner_teamMatches the event's host against the table's hostname column and adds owner_team.
2. Let the table choose
ObiQL
| lookup country_currencyMatches on the field closest in name to the table's key column and adds every other column.
3. Group by an enriched column
ObiQL
level="error" | lookup hostname_map hostname AS host OUTPUT owner_team | stats count() by owner_teamError counts per owning team.