-
Notifications
You must be signed in to change notification settings - Fork 578
adding data_stream stats api docs #10144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AntonEliatra
wants to merge
4
commits into
opensearch-project:main
Choose a base branch
from
AntonEliatra:adding-data_stream-stats-api-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
--- | ||
layout: default | ||
title: Data stream stats | ||
parent: Index APIs | ||
nav_order: 74 | ||
--- | ||
|
||
# Data stream stats | ||
|
||
The Data Stream Stats API provides statistics about one or more data streams. This includes information such as the number of backing indexes, store size, and maximum timestamp. This API is useful for monitoring storage and indexing activity across data streams. | ||
|
||
<!-- spec_insert_start | ||
api: indices.data_streams_stats | ||
component: endpoints | ||
--> | ||
## Endpoints | ||
```json | ||
GET /_data_stream/_stats | ||
GET /_data_stream/{name}/_stats | ||
``` | ||
<!-- spec_insert_end --> | ||
|
||
<!-- spec_insert_start | ||
api: indices.data_streams_stats | ||
component: path_parameters | ||
include_global: false | ||
include_deprecated: false | ||
pretty: false | ||
--> | ||
## Path parameters | ||
|
||
The following table lists the available path parameters. All path parameters are optional. | ||
|
||
| Parameter | Data type | Description | | ||
| :--- | :--- | :--- | | ||
| `name` | List or String | A comma-separated list of data streams used to limit the request. Wildcard expressions (`*`) are supported. To target all data streams in a cluster, omit this parameter or use `*`. | | ||
|
||
<!-- spec_insert_end --> | ||
|
||
<!-- spec_insert_start | ||
api: indices.data_streams_stats | ||
component: query_parameters | ||
include_global: true | ||
include_deprecated: false | ||
pretty: false | ||
--> | ||
## Query parameters | ||
|
||
The following table lists the available query parameters. All query parameters are optional. | ||
|
||
| Parameter | Data type | Description | Default | | ||
| :--- | :--- | :--- | :--- | | ||
| `error_trace` | Boolean | Whether to include the stack trace of returned errors. | `false` | | ||
| `filter_path` | List or String | Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field's name. You can also exclude fields with "-". | N/A | | ||
| `human` | Boolean | Whether to return human-readable values for statistics. | `false` | | ||
| `pretty` | Boolean | Whether to pretty format the returned JSON response. | `false` | | ||
| `source` | String | The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. | N/A | | ||
|
||
<!-- spec_insert_end --> | ||
|
||
## Example | ||
|
||
Create an index template with a matching pattern and data stream enabled: | ||
|
||
```json | ||
PUT /_index_template/template-logs-app | ||
{ | ||
"index_patterns": ["logs-app*"], | ||
"data_stream": {} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
Create the data stream: | ||
|
||
```json | ||
PUT /_data_stream/logs-app | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
Index a document to generate backing indexes: | ||
|
||
```json | ||
POST /logs-app/_doc | ||
{ | ||
"@timestamp": "2025-06-23T10:00:00Z", | ||
"message": "app started" | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
|
||
Retrieve data stream stats: | ||
|
||
```json | ||
GET /_data_stream/logs-app/_stats?human=true | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Example response | ||
|
||
The response contains storage and shard statistics for each data stream in the cluster: | ||
|
||
```json | ||
{ | ||
"_shards": { | ||
"total": 2, | ||
"successful": 2, | ||
"failed": 0 | ||
}, | ||
"data_stream_count": 1, | ||
"backing_indices": 1, | ||
"total_store_size": "16.8kb", | ||
"total_store_size_bytes": 17304, | ||
"data_streams": [ | ||
{ | ||
"data_stream": "logs-app", | ||
"backing_indices": 1, | ||
"store_size": "16.8kb", | ||
"store_size_bytes": 17304, | ||
"maximum_timestamp": 1750673100000 | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Response body fields | ||
|
||
| Field | Data type | Description | | ||
| `_shards.total` | Integer | The total number of shards involved in the request. | | ||
| `_shards.successful`| Integer | The number of successful shard fetches. | | ||
| `_shards.failed`| Integer | The number of failed shard fetches. | | ||
| `data_stream_count` | Integer | The total number of data streams returned in the response.| | ||
| `backing_indices` | Integer | The total number of backing indexes across all data streams.| | ||
| `total_store_size`| String| A human-readable total size of all data stream storage. Present only if `human=true`. | | ||
| `total_store_size_bytes`| Integer | The total storage used by all data streams, in bytes. | | ||
| `data_streams`| Array | A list of objects, one for each data stream.| | ||
| `data_streams[n].data_stream` | String| The name of the data stream.| | ||
| `data_streams[n].backing_indices` | Integer | The number of backing indexes for the data stream.| | ||
| `data_streams[n].store_size`| String| Human-readable storage used by the data stream. Present only if `human=true`. | | ||
| `data_streams[n].store_size_bytes`| Integer | The total storage used by the data stream, in bytes.| | ||
| `data_streams[n].maximum_timestamp` | Long| The maximum timestamp across all documents in the data stream. | |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.