Skip to content

TS_INFO information retrieval command#142721

Merged
leontyevdv merged 87 commits intoelastic:mainfrom
leontyevdv:feat/ts-info-information-retrieval-command
Mar 2, 2026
Merged

TS_INFO information retrieval command#142721
leontyevdv merged 87 commits intoelastic:mainfrom
leontyevdv:feat/ts-info-information-retrieval-command

Conversation

@leontyevdv
Copy link
Copy Markdown
Contributor

@leontyevdv leontyevdv commented Feb 19, 2026

Adds the TS_INFO command, a time-series metadata introspection command built on top of METRICS_INFO (#141667). While METRICS_INFO returns one row per distinct metric across all time series, TS_INFO returns one row per (metric, time-series) combination, providing finer-grained visibility into individual time series.

TS_INFO produces the same 6 columns as METRICS_INFO plus an additional dimensions column:

TS k8s | METRICS_INFO | SORT metric_name
metric_name data_stream unit metric_type field_type dimension_fields
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]

TS_INFO expands this to one row per time series, adding the dimensions column:

TS k8s | TS_INFO | KEEP metric_name, dimensions | WHERE metric_name == "network.eth0.rx" | SORT dimensions
metric_name dimensions
network.eth0.rx {"cluster": "prod", "pod": "one", "region": "[eu, us]"}
network.eth0.rx {"cluster": "prod", "pod": "three", "region": "[eu, us]"}
network.eth0.rx {"cluster": "prod", "pod": "two", "region": "[eu, us]"}
network.eth0.rx {"cluster": "qa", "pod": "one"}
network.eth0.rx {"cluster": "qa", "pod": "three"}
network.eth0.rx {"cluster": "qa", "pod": "two"}
network.eth0.rx {"cluster": "staging", "pod": "one", "region": "us"}
network.eth0.rx {"cluster": "staging", "pod": "three", "region": "us"}
network.eth0.rx {"cluster": "staging", "pod": "two", "region": "us"}

This PR contains generative tests for both METRICS_INFO and TS_INFO commands.

Closes #139296
Closes #141413

leontyevdv and others added 30 commits February 2, 2026 16:25
Add METRICS_INFO command to retrieve metrics-related metadata.

Part of elastic#139296
Add mata.unit to the k8s-mappings.json

Part of elastic#139296
# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java
Regenerate ESQL parser to fix conflicts

Part of elastic#139296
Change METRICS_INFO to scan documents with unique _tsid to retrieve
metrics and dimensions metadata from them.

Part of elastic#139296
# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
Fix a compilation error occurred due to the merge with main.

Part of elastic#139296
- Address review comments.
- Optimize DistinctByOperator
- Optimize collection of metrics and dimensions

Part of elastic#139296
Change grouping by adding a concept of MetricSignature and 2 steps of
grouping.

Part of elastic#139296
Add MetricsInfoOperatorTests

Part of elastic#139296
Ban PipelineBreakers before METRICS_INFO.

Part of elastic#139296
Make MetricsInfo a PipelineBreaker.
Add deduplication of information.
# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
Make MetricsInfo a PipelineBreaker.
Add deduplication of information.
Change grouping to take into account a data stream name
# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer.interp
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/PlanWritables.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java
Add INTERMEDIATE reduction
@leontyevdv
Copy link
Copy Markdown
Contributor Author

Not sure if you're planning to add docs in this PR, but if yes there's some info in the README :)

Hey @leemthompo ! We are not going to add any documentation so far because it's going to be a command for internal use. Kibana is going to use it to build dashboards.

@leemthompo
Copy link
Copy Markdown
Member

it's going to be a command for internal use. Kibana is going to use it to build dashboards.

Not sure if it makes sense to have a release note in that case?

@leontyevdv
Copy link
Copy Markdown
Contributor Author

it's going to be a command for internal use. Kibana is going to use it to build dashboards.

Not sure if it makes sense to have a release note in that case?

Yes, I agree. It's generated automatically. I wonder if I can remove it and if I can remove the one that I merged for a similar METRICS_INFO command.

@leontyevdv leontyevdv requested a review from dnhatn February 25, 2026 14:00
Copy link
Copy Markdown
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks Dima!

One main concern: from my perspective, the terms TS and Metrics are interchangeable, so TS_INFO and METRICS_INFO also seem interchangeable. Would it make sense to introduce a parameter to METRICS_INFO to distinguish the behavior instead of two commands?

@kkrik-es Are you okay with this?

@kkrik-es
Copy link
Copy Markdown
Member

One main concern: from my perspective, the terms TS and Metrics are interchangeable, so TS_INFO and METRICS_INFO also seem interchangeable. Would it make sense to introduce a parameter to METRICS_INFO to distinguish the behavior instead of two commands?

We do use time series and metrics interchangeably, but this goes to the actual retrieved information: the former retrieves information per time series (tsid), while the latter does so per metric name (field). These two are fairly different - and we could have DIMENSIONS_INFO for retrieving dimension names along with associated metrics. Now, we could just use METRICS_INFO for all of them, passing args to differentiate what we retrieve. TS_INFO doesn't seem to add too much overhead, implementation-wise, and I like the clean semantics, but can be convinced either way. Let's also check with @felixbarny who proposed TS_INFO in the first place.

@leontyevdv
Copy link
Copy Markdown
Contributor Author

leontyevdv commented Feb 26, 2026

I've done some benchmarking using the 240M-high-cardinality dataset. Here are the results:

TS metrics-hostmetricsreceiver.otel-default | METRICS_INFO | SORT metric_name
  
real    0m5.287s
user    0m0.001s
sys     0m0.007s

---

TS metrics-hostmetricsreceiver.otel-default | METRICS_INFO | KEEP metric_name, metric_type | SORT metric_name

real    0m3.995s
user    0m0.003s
sys     0m0.005s

---

TS metrics-hostmetricsreceiver.otel-default | METRICS_INFO | STATS metric_count = COUNT(*) BY metric_type | SORT metric_type
  
real    0m3.860s
user    0m0.005s
sys     0m0.002s

---

TS metrics-hostmetricsreceiver.otel-default | TS_INFO | SORT metric_name, dimensions

real    0m19.630s
user    0m0.007s
sys     0m0.013s

---

TS metrics-hostmetricsreceiver.otel-default | TS_INFO | STATS ts_count = COUNT(*) BY metric_name | SORT metric_name

real    0m15.327s
user    0m0.004s
sys     0m0.004s

fyi: @kkrik-es , @dnhatn , @felixbarny

@felixbarny
Copy link
Copy Markdown
Member

One main concern: from my perspective, the terms TS and Metrics are interchangeable, so TS_INFO and METRICS_INFO also seem interchangeable. Would it make sense to introduce a parameter to METRICS_INFO to distinguish the behavior instead of two commands?

Time series and metric are not interchangeable terms. A metric is defined by the metric name. A time series is defined by the combination of all dimensions and the metric name. See also https://opentelemetry.io/docs/specs/otel/metrics/data-model/#timeseries-model.

That's exactly how the two commands differ: METRICS_INFO returns a row per metric name while TS_INFO returns a row per unique metric name and _tsid.

private final MetricsInfoOperator.MetricFieldLookup fieldLookup;
private final int metadataSourceChannel;
private final int indexChannel;
/** FINAL-mode field: input channel indices for the 7 output columns. Null in INITIAL mode. */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** FINAL-mode field: input channel indices for the 7 output columns. Null in INITIAL mode. */
/** FINAL-mode field: input channel indices for the 7 output columns. Nulls in INITIAL mode. */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, the filed is an array of primitive types (int[]) so it cannot contain nulls. In this particular case, the null value is assigned to the field and not to the values inside the array.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for the context @leontyevdv

@leontyevdv leontyevdv merged commit 4be64f2 into elastic:main Mar 2, 2026
35 checks passed
szybia added a commit to szybia/elasticsearch that referenced this pull request Mar 2, 2026
…locations

* upstream/main: (94 commits)
  Mute org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT test {p0=esql/40_tsdb/TS Command grouping on text field} elastic#142544
  Mute org.elasticsearch.index.store.StoreDirectoryMetricsIT testDirectoryMetrics elastic#143419
  Mute org.elasticsearch.xpack.esql.qa.multi_node.GenerativeIT test elastic#143023
  TS_INFO information retrieval command (elastic#142721)
  ESQL: External source parallel execution and distribution (elastic#143349)
  Mute org.elasticsearch.index.mapper.blockloader.FlattenedFieldRootBlockLoaderTests testBlockLoaderForFieldInObject {preference=Params[syntheticSource=false, preference=DOC_VALUES]} elastic#143414
  Mute org.elasticsearch.index.mapper.blockloader.FlattenedFieldRootBlockLoaderTests testBlockLoaderForFieldInObject {preference=Params[syntheticSource=false, preference=NONE]} elastic#143413
  Mute org.elasticsearch.index.mapper.blockloader.FlattenedFieldRootBlockLoaderTests testBlockLoaderForFieldInObject {preference=Params[syntheticSource=false, preference=STORED]} elastic#143412
  Removing ingest random sampling (elastic#143289)
  Mute org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT test elastic#143023
  [Transform] Clean up internal tests (elastic#143246)
  Skip time series field type merge for non-TS agg queries (elastic#143262)
  Enable zero-copy SIMD vector scoring on searchable snapshots (frozen tier) (elastic#141718)
  Mute org.elasticsearch.xpack.search.CrossClusterAsyncSearchIT testCancelViaExpirationOnRemoteResultsWithMinimizeRoundtrips elastic#143407
  Fix MemorySegmentUtilsTests (elastic#143391)
  Unmute testWorkflowsRestrictionAllowsAccess (elastic#143308)
  Cancel async query on expiry (elastic#143016)
  ESQL: Finish migrating error testing (elastic#143322)
  Reduce LuceneOperator.Status memory consumption with large QueryDSL queries (elastic#143175)
  ESQL: Generative testing with full text functions (elastic#142961)
  ...
tballison pushed a commit to tballison/elasticsearch that referenced this pull request Mar 3, 2026
Add a TS_INFO command - a time-series metadata introspection command built on top of METRICS_INFO (elastic#141667). While METRICS_INFO returns one row per distinct metric across all time series, TS_INFO returns one row per (metric, time-series) combination, providing finer-grained visibility into individual time series.

TS_INFO produces the same 6 columns as METRICS_INFO plus an additional dimensions column.

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
Co-authored-by: Liam Thompson <leemthompo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >enhancement :StorageEngine/ES|QL Timeseries / metrics / PromQL / logsdb capabilities in ES|QL Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:StorageEngine v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PromQL Generative tests: Use METRICS_INFO to get field info Time series information retrieval

7 participants