﻿---
title: ES|QL TS_INFO command
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/ts-info
products:
  - Elasticsearch
---

# ES|QL TS_INFO command
<applies-to>
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Generally available since 9.4
</applies-to>

The `TS_INFO` [processing command](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/processing-commands) retrieves
information about individual time series available in
[time series data streams](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/5113/manage-data/data-store/data-streams/time-series-data-stream-tsds),
along with the dimension values that identify each series.
`TS_INFO` is a more fine-grained variant of
[`METRICS_INFO`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/metrics-info). Where `METRICS_INFO` returns one row
per distinct metric, `TS_INFO` returns one row per metric **and** time series combination. This
lets you discover the exact dimension values (labels) that identify each series. Like
`METRICS_INFO`, any [`WHERE`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/where) filters that precede
`TS_INFO` narrow the set of time series considered.
<note>
  Prefer [`METRICS_INFO`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/metrics-info) when you only need
  metric-level metadata, such as metric names, types, units, or dimension field names. 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.
</note>


## Syntax

```esql
TS_INFO
```


## Parameters

<note>
  `TS_INFO` takes no parameters.
</note>


## Description

`TS_INFO` produces one row for every (metric, time series) combination that matches the
preceding filters. It includes all columns from
[`METRICS_INFO`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/metrics-info), plus a `dimensions` column
containing a JSON-encoded representation of the dimension key/value pairs that identify the
time series.
The output contains the following columns, all of type `keyword`:
<definitions>
  <definition term="metric_name">
    The name of the metric field (single-valued).
  </definition>
  <definition term="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).
  </definition>
  <definition term="unit">
    The [unit](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/elasticsearch/mapping-reference/mapping-field-meta) 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).
  </definition>
  <definition term="metric_type">
    The metric type, for example `counter`, `gauge`, or `histogram` (multi-valued when definitions differ
    across backing indices).
  </definition>
  <definition term="field_type">
    The Elasticsearch field type, for example `long`, `double`, `histogram`, `tdigest`, or
    `exponential_histogram` (multi-valued when definitions differ across backing indices).
  </definition>
  <definition term="dimension_fields">
    The dimension field names associated with this metric (multi-valued). The union of dimension
    keys across all time series for that metric.
  </definition>
  <definition term="dimensions">
    A JSON-encoded object containing the dimension key/value pairs that identify the time series (single-valued).
    For example: `{"job":"elasticsearch","instance":"instance_1"}`.
  </definition>
</definitions>


### Time range

<applies-to>
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Planned
</applies-to>

`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`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/where) on `@timestamp` ahead of the command.
- A range on `@timestamp` in the [Query DSL filter](/elastic/docs-builder/docs/5113/reference/query-languages/esql/esql-rest#esql-rest-filtering)
  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:
```text
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:
```esql
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](/elastic/docs-builder/docs/5113/reference/query-languages/promql/promql-http-api#promql-http-api-metadata)
of the Prometheus-compatible HTTP API that are built on these commands:
- [Series](/elastic/docs-builder/docs/5113/reference/query-languages/promql/promql-http-api#promql-http-api-series),
  [label names](/elastic/docs-builder/docs/5113/reference/query-languages/promql/promql-http-api#promql-http-api-labels), and
  [label values](/elastic/docs-builder/docs/5113/reference/query-languages/promql/promql-http-api#promql-http-api-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](/elastic/docs-builder/docs/5113/reference/query-languages/promql/promql-http-api#promql-http-api-metadata-endpoint): the
  endpoint takes no time range and looks back 24 hours, so only a limit below 24 hours shortens what it reads.

<applies-to>Elastic Cloud Serverless: Unavailable</applies-to> 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:
```console
PUT /_cluster/settings
{
  "persistent": {
    "esql.query.metrics_info_max_time_range": "7d"
  }
}
```


### Restrictions

- `TS_INFO` can only be used after a [`TS`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/ts) source command.
  Using it after `FROM` or other source commands produces an error.
- `TS_INFO` must appear before pipeline-breaking commands such as
  [`STATS`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/stats-by),
  [`SORT`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/sort), or
  [`LIMIT`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/limit).
- The output replaces the original table: downstream commands operate on the metadata rows, not the
  raw time series documents.


## Examples


### List all metric–time-series combinations in the selected time range

Return every (metric, time series) pair that has data in the selected time range of the targeted data
stream, sorted by metric name and dimension values. The time picker in Kibana can supply the time range.
With no time range selected, the command looks back one day by default. For details, refer to
[Time range](#esql-ts-info-time-range):
```esql
TS k8s
| TS_INFO
| SORT metric_name, dimensions
```


### Discover series matching a filter

Place a [`WHERE`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/where) clause before `TS_INFO` to restrict
the time series considered. Only metrics and series with matching data are returned:
```esql
TS k8s
| WHERE cluster == "prod"
| TS_INFO
| SORT metric_name, dimensions
```


### Select specific columns

Use [`KEEP`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/keep) to return only the columns you need:
```esql
TS k8s
| WHERE cluster == "prod"
| TS_INFO
| KEEP metric_name, dimensions
| SORT metric_name, dimensions
```


### Filter by metric type

Use [`WHERE`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/where) after `TS_INFO` to narrow results by
metadata:
```esql
TS k8s
| TS_INFO
| WHERE metric_type == "gauge"
| SORT metric_name, dimensions
```


### Count distinct time series per metric

Combine with [`STATS`](https://www.elastic.co/elastic/docs-builder/docs/5113/reference/query-languages/esql/commands/stats-by) to count how many
time series exist for each metric:
```esql
TS k8s
| TS_INFO
| STATS series_count = COUNT(*) BY metric_name
| SORT metric_name
```


| series_count:long | metric_name:keyword    |
|-------------------|------------------------|
| 9                 | network.eth0.rx        |
| 9                 | network.eth0.tx        |
| 9                 | network.total_bytes_in |
| 9                 | network.total_cost     |


### Count distinct metrics per time series

Find out how many different metrics each time series reports. This can help identify series that
report an unusually small or large number of metrics:
```esql
TS k8s
| TS_INFO
| STATS metric_count = COUNT_DISTINCT(metric_name) BY dimensions
| SORT dimensions
```


| metric_count:long | dimensions:keyword                                   |
|-------------------|------------------------------------------------------|
| 4                 | {"cluster":"prod","pod":"one","region":"[eu, us]"}   |
| 4                 | {"cluster":"prod","pod":"three","region":"[eu, us]"} |
| 4                 | {"cluster":"prod","pod":"two","region":"[eu, us]"}   |
| 4                 | {"cluster":"qa","pod":"one"}                         |
| 4                 | {"cluster":"qa","pod":"three"}                       |
| 4                 | {"cluster":"qa","pod":"two"}                         |
| 4                 | {"cluster":"staging","pod":"one","region":"us"}      |
| 4                 | {"cluster":"staging","pod":"three","region":"us"}    |
| 4                 | {"cluster":"staging","pod":"two","region":"us"}      |