﻿---
title: ES|QL TS_INFO command
description: 
url: https://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/reference/query-languages/esql/commands/ts-info
products:
  - Elasticsearch
---

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

The `TS_INFO` [processing command](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/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-content/tree/main/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://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/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://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/reference/query-languages/esql/commands/where) filters that precede
`TS_INFO` narrow the set of time series considered.

## 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://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/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://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/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` or `gauge` (multi-valued when definitions differ across backing indices).
  </definition>
  <definition term="field_type">
    The Elasticsearch field type, for example `long`, `double`, or `integer` (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>


### Restrictions

- `TS_INFO` can only be used after a [`TS`](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/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://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/reference/query-languages/esql/commands/stats-by),
  [`SORT`](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/reference/query-languages/esql/commands/sort), or
  [`LIMIT`](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/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

Return every (metric, time series) pair in the targeted data stream, sorted by metric name and
dimension values:
```esql
TS k8s
| TS_INFO
| SORT metric_name, dimensions
```


### Discover series matching a filter

Place a [`WHERE`](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/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://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/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://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/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://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/145980/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"}      |