ES|QL METRICS_INFO command

The METRICS_INFO processing command retrieves information about the metrics available in time series data streams, along with their applicable dimensions and other metadata.

Use METRICS_INFO to discover which metrics exist, what types and units they have, and which dimensions apply to them without having to inspect index mappings or rely on the field capabilities API. Any WHERE filters that precede METRICS_INFO narrow the set of time series considered, so only metrics with matching data are returned.

Note

Prefer METRICS_INFO over TS_INFO when you only need metric-level metadata. It avoids producing a row for every metric and time series combination, which reduces memory use and processing cost. Use TS_INFO when you need metadata for individual series, including their dimension values, or aggregates that depend on the number of series, such as counting series per metric.

METRICS_INFO
		
Note

METRICS_INFO takes no parameters.

METRICS_INFO produces one row per distinct metric signature — that is, per unique combination of metric name and its properties across backing indices. When the same metric is defined with different properties (for example, different units) in different data streams, separate rows are returned for each variant.

The output contains the following columns, all of type keyword:

metric_name
The name of the metric field (single-valued).
data_stream
The data stream(s) that contain this metric (multi-valued when the metric is included in multiple data streams which align on the unit, metric type, and field type).
unit
The unit declared in the field mapping, such as bytes or packets (multi-valued when definitions differ across backing indices; may be null if no unit is declared).
metric_type
The metric type, for example counter, gauge, or histogram (multi-valued when definitions differ across backing indices).
field_type
The Elasticsearch field type, for example long, double, histogram, tdigest, or exponential_histogram (multi-valued when definitions differ across backing indices).
dimension_fields
The dimension field names associated with this metric (multi-valued). The union of dimension keys across all time series for that metric.

METRICS_INFO and TS_INFO read every time series in their time range, so they get slower as the time range gets wider. By default, they read at most the most recent day of the time range that the request asks for. The time range comes from:

  • A WHERE on @timestamp ahead of the command.
  • A range on @timestamp in the Query DSL filter of the request, for example the time picker in Kibana.

If the request has both, the time range is what both allow. A time range of one day or less is read in full. From a wider one, the commands read the most recent day:

  • If the time range ends in the past, the day before its end.
  • If the time range has no end or ends in the future, or if the request has no time range, the day before the query runs.

When the time range is narrowed, the response includes this warning:

METRICS_INFO and TS_INFO are limited to the most recent [1d]
		

To read older data, select a time range of up to a day:

TS k8s
| WHERE @timestamp >= "2024-05-10T00:00:00Z" AND @timestamp <= "2024-05-10T12:00:00Z"
| METRICS_INFO
		

The limit also applies to the metadata and discovery endpoints of the Prometheus-compatible HTTP API that are built on these commands:

  • Series, label names, and label values for the __name__ label: the time range is the one between the start and end parameters. The values of other labels are not limited.
  • Metric metadata: the endpoint takes no time range and looks back 24 hours, so only a limit below 24 hours shortens what it reads.

To read more than a day at a time, change the limit with the esql.query.metrics_info_max_time_range dynamic cluster setting. It takes a time value such as 12h or 7d, and -1 removes the limit:

				PUT /_cluster/settings
					{
  "persistent": {
    "esql.query.metrics_info_max_time_range": "7d"
  }
}
		
  • METRICS_INFO can only be used after a TS source command. Using it after FROM or other source commands produces an error.
  • METRICS_INFO must appear before pipeline-breaking commands such as STATS, SORT, or LIMIT.
  • The output replaces the original table: downstream commands operate on the metadata rows, not the raw time series documents.

Return every metric that has data in the selected time range of the targeted time series data stream, sorted alphabetically by name. The time picker in Kibana can supply the time range. With no time range selected, the command looks back one day by default, refer to Time range:

TS k8s
| METRICS_INFO
| SORT metric_name
		
metric_name:keyword data_stream:keyword unit:keyword metric_type:keyword field_type:keyword dimension_fields:keyword
network.eth0.rx k8s packets gauge integer [cluster, pod, region]
network.eth0.tx k8s packets gauge integer [cluster, pod, region]
network.total_bytes_in k8s bytes counter long [cluster, pod, region]
network.total_cost k8s usd counter double [cluster, pod, region]

Place a WHERE clause before METRICS_INFO to restrict the time series considered. Only metrics that have actual data matching the filter are returned:

TS k8s
| WHERE cluster == "prod"
| METRICS_INFO
| SORT metric_name
		
metric_name:keyword data_stream:keyword unit:keyword metric_type:keyword field_type:keyword dimension_fields:keyword
network.eth0.rx k8s packets gauge integer [cluster, pod, region]
network.eth0.tx k8s packets gauge integer [cluster, pod, region]
network.total_bytes_in k8s bytes counter long [cluster, pod, region]
network.total_cost k8s usd counter double [cluster, pod, region]

Use KEEP to return only the columns you need:

TS k8s
| WHERE cluster == "prod"
| METRICS_INFO
| KEEP metric_name, metric_type
| SORT metric_name
		
metric_name:keyword metric_type:keyword
network.eth0.rx gauge
network.eth0.tx gauge
network.total_bytes_in counter
network.total_cost counter

Use WHERE after METRICS_INFO to narrow results by metadata, for example to only counter metrics:

TS k8s
| METRICS_INFO
| WHERE metric_type == "counter"
| SORT metric_name
		
metric_name:keyword data_stream:keyword unit:keyword metric_type:keyword field_type:keyword dimension_fields:keyword
network.total_bytes_in k8s bytes counter long [cluster, pod, region]
network.total_cost k8s usd counter double [cluster, pod, region]

Use a LIKE pattern after METRICS_INFO to find metrics whose name matches a prefix or wildcard. This is useful for exploring a specific subsystem when you know part of the metric name:

TS k8s
| METRICS_INFO
| WHERE metric_name LIKE "network.eth0*"
| SORT metric_name
		
metric_name:keyword data_stream:keyword unit:keyword metric_type:keyword field_type:keyword dimension_fields:keyword
network.eth0.rx k8s packets gauge integer [cluster, pod, region]
network.eth0.tx k8s packets gauge integer [cluster, pod, region]

Combine with STATS to aggregate the metadata. For example, count distinct metrics whose name matches a pattern:

TS k8s
| METRICS_INFO
| WHERE metric_name LIKE "network.total*"
| STATS matching_metrics = COUNT_DISTINCT(metric_name)
		
matching_metrics:long
2

Group the metric catalogue by metric_type to see how many counter, gauge, or other metrics exist:

TS k8s
| METRICS_INFO
| STATS metric_count = COUNT(*) BY metric_type
| SORT metric_type
		
metric_count:long metric_type:keyword
2 counter
2 gauge