ES|QL DESCRIBE command
The DESCRIBE command returns one row for each column of its input, with what the column is and where it comes from.
DESCRIBE
DESCRIBE takes no arguments. It describes the columns the query has at that point, after views, renames and computations are resolved, without running the query. Its output is a table like any other, so the rest of the query can filter, sort or aggregate it, and the default LIMIT applies to it, so add a larger LIMIT after DESCRIBE for an input with more columns.
DESCRIBE returns the following columns. New columns, and new values in columns such as role and origin, can be added in future versions, and the classification of a column can be refined. Use KEEP to select the columns you need rather than relying on their position.
name- The name of the column.
type- The ES|QL type of the column.
role- How the field the column reads is meant to be used:
time,dimension,metric,attribute,numeric,text,semantic,vector,metadataorother.dimensionandmetriccome from time series mappings. The others follow from the field type, andtimeis the@timestampfield.mixedmeans the indices disagree. A computed column istimewhen it rounds or converts a time column, for example withBUCKETorDATE_TRUNC, andnullotherwise. field- The field or dataset column the column reads, or
nullif it is computed. origin-
Where the column comes from:
mapped: a mapped field, under its own name.renamed: a mapped field or dataset column under another name.computed: the result of an expression or an aggregation.dataset: a column of a dataset.metadata: a metadata field, such as_index.unmapped: a field that no index maps.unsupported: a field of a type that ES|QL does not support.
metric_type- The
time_series_metricof the field, such asgaugeorcounter.mixedmeans the indices disagree. unit- The unit of the column, from the
unitin the field'smeta. A computed column has the unit that follows from the computation when there is one, for examplebytes/sfor the rate of a field inbytes. When the indices or the branches of a query disagree, the column lists every unit. interval- The interval of a date bucket, such as
1 houror1 month, when the column is computed byBUCKET,TBUCKETorDATE_TRUNCwith constant arguments. For a target number of buckets, it's the interval that was picked. time_zone- The time zone the buckets of
intervalare aligned in. description- The
descriptionin the field'smeta. When the indices, or the branches of a query that read the same field, disagree, the column lists every description. The listed units and descriptions are collected independently, so their positions don't match.
Describe the fields of an index:
FROM k8s
| DESCRIBE
| WHERE name IN ("@timestamp", "cluster", "event", "event_log", "client.ip", "network.bytes_in", "network.total_bytes_in", "network.eth0.rx")
| KEEP name, type, role, origin, metric_type, unit
| SORT name
| name:keyword | type:keyword | role:keyword | origin:keyword | metric_type:keyword | unit:keyword |
|---|---|---|---|---|---|
| @timestamp | date | time | mapped | null | null |
| client.ip | ip | attribute | mapped | null | null |
| cluster | keyword | dimension | mapped | null | null |
| event | keyword | attribute | mapped | null | null |
| event_log | text | text | mapped | null | null |
| network.bytes_in | long | numeric | mapped | null | null |
| network.eth0.rx | integer | metric | mapped | gauge | packets |
| network.total_bytes_in | counter_long | metric | mapped | counter | bytes |
Follow a column back to the field it reads:
FROM employees
| KEEP emp_no, salary, first_name
| RENAME salary AS pay
| EVAL bonus = pay * 2
| DESCRIBE
| KEEP name, type, field, origin, role
| name:keyword | type:keyword | field:keyword | origin:keyword | role:keyword |
|---|---|---|---|---|
| emp_no | integer | emp_no | mapped | numeric |
| pay | integer | salary | renamed | numeric |
| first_name | keyword | first_name | mapped | attribute |
| bonus | integer | null | computed | null |
Report the interval and time zone of date buckets:
FROM k8s
| EVAL day = DATE_TRUNC(1 day, @timestamp)
| STATS c = COUNT(*) BY b = BUCKET(@timestamp, 1 hour), day
| RENAME b AS hour
| EVAL month = DATE_TRUNC(1 month, hour), ninety = DATE_TRUNC(90 minutes, hour)
| DESCRIBE
| KEEP name, role, interval, time_zone
| name:keyword | role:keyword | interval:keyword | time_zone:keyword |
|---|---|---|---|
| c | null | null | null |
| hour | time | 1 hour | UTC |
| day | time | 1 day | UTC |
| month | time | 1 month | UTC |
| ninety | time | 90 minutes | UTC |
Summarize the fields of an index by role:
FROM k8s
| DESCRIBE
| STATS fields = COUNT(*) BY role
| SORT role
| fields:long | role:keyword |
|---|---|
| 7 | attribute |
| 3 | dimension |
| 5 | metric |
| 4 | numeric |
| 2 | other |
| 1 | text |
| 1 | time |