-
Notifications
You must be signed in to change notification settings - Fork 507
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
Add CAT segment replication API #2937
Merged
+167
−1
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d4a2f36
Add CAT segment replication API
kolchfa-aws a72f37e
Refactoring after a conversation with SMEs
kolchfa-aws 3b81f81
Added copy buttons and changed sample to example
kolchfa-aws 8146072
Revise for 2.7
kolchfa-aws 2346f9e
Merge branch 'main' into Fix2627-cat-segment-api
kolchfa-aws fc5c174
Added aliases
kolchfa-aws 0b2c02d
Reorder pages
kolchfa-aws 29fefff
Update cat-segment-replication.md
kolchfa-aws 127007c
Apply suggestions from code review
kolchfa-aws d622659
Implemented doc review comments
kolchfa-aws 3dd12e1
Merge branch 'Fix2627-cat-segment-api' of https://github.com/opensear…
kolchfa-aws 5d12826
Update cat-segment-replication.md
kolchfa-aws c62d527
Apply suggestions from code review
kolchfa-aws b606a15
Implemented editorial review comment
kolchfa-aws ac28a03
Fix link
kolchfa-aws 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 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
This file contains 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,166 @@ | ||
--- | ||
layout: default | ||
title: CAT segment replication | ||
parent: CAT API | ||
nav_order: 53 | ||
has_children: false | ||
--- | ||
|
||
# CAT segment replication | ||
Introduced 2.7 | ||
{: .label .label-purple } | ||
|
||
The CAT segment replication operation returns information about active and last completed [segment replication]({{site.url}}{{site.baseurl}}/opensearch/segment-replication/index) events on each replica shard, including related shard-level metrics. These metrics provide information about how far behind the replicas are lagging with respect to the primary shard. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Last sentence: "These metrics provide information about how far behind the primary shard the replicas are lagging"? As written, this may be initially read as though something is lagging behind the replicas. |
||
|
||
Call the CAT Segment Replication API only on indexes with segment replication enabled. | ||
{: .note} | ||
|
||
## Path and HTTP methods | ||
|
||
```json | ||
GET /_cat/segment_replication | ||
GET /_cat/segment_replication/<index> | ||
``` | ||
|
||
## Path parameters | ||
|
||
The following table lists the available optional path parameter. | ||
|
||
Parameter | Type | Description | ||
:--- | :--- | :--- | ||
`index` | String | The name of the index, or a comma-separated list or a wildcard expression of index names used to filter results. If this parameter is not provided, the response contains information about all indexes in the cluster. | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Query parameters | ||
|
||
The CAT segment replication API operation supports the following optional query parameters. | ||
|
||
Parameter | Data type | Description | ||
:--- |:---| :--- | ||
`active_only` | Boolean | If `true`, the response only includes active segment replications. Defaults to `false`. | ||
[`detailed`](#additional-metrics-a-detailed-response-returns) | String | If `true`, the response includes additional metrics of each stage of a segment replication event. Defaults to `false`. | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`shards` | String | A comma-separated list of shards to display. | ||
`format` | String | A short version of the HTTP accept header. Valid values include `JSON` and `YAML`. | ||
`h` | String | A comma-separated list of column names to display. | ||
`help` | Boolean | If `true`, the response includes help information. Defaults to `false`. | ||
`time` | Time value | [Units]({{site.url}}{{site.baseurl}}/opensearch/units) used to display time values. Defaults to `ms` (milliseconds). | ||
`v` | Boolean | If `true`, the response includes column headings. Defaults to `false`. | ||
`s` | String | Specifies to sort the results. For example, `s=shardId:desc` sorts by shardId in descending order. | ||
|
||
## Examples | ||
natebower marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The following examples illustrate various segment replication responses. | ||
|
||
#### Example 1: No active segment replication events | ||
|
||
The following query requests segment replication metrics with column headings for all indexes: | ||
|
||
```json | ||
GET /_cat/segment_replication?v=true | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains the metrics for the preceding request: | ||
|
||
```bash | ||
shardId target_node target_host checkpoints_behind bytes_behind current_lag last_completed_lag rejected_requests | ||
[index-1][0] runTask-1 127.0.0.1 0 0b 0s 7ms 0 | ||
``` | ||
|
||
#### Example 2: Shard ID specified | ||
|
||
The following query requests segment replication metrics with column headings for shards with the ID `0` from indexes `index1` and `index2`: | ||
|
||
```json | ||
GET /_cat/segment_replication/index1,index2?v=true&shards=0 | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains the metrics for the preceding request. The column headings correspond to the metric names: | ||
|
||
```bash | ||
shardId target_node target_host checkpoints_behind bytes_behind current_lag last_completed_lag rejected_requests | ||
[index-1][0] runTask-1 127.0.0.1 0 0b 0s 3ms 0 | ||
[index-2][0] runTask-1 127.0.0.1 0 0b 0s 5ms 0 | ||
``` | ||
|
||
#### Example 3: Detailed response | ||
|
||
The following query requests detailed segment replication metrics with column headings for all indexes: | ||
|
||
```json | ||
GET /_cat/segment_replication?v=true&detailed=true | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains additional metrics about the files and stages of a segment replication event: | ||
|
||
```bash | ||
shardId target_node target_host checkpoints_behind bytes_behind current_lag last_completed_lag rejected_requests stage time files_fetched files_percent bytes_fetched bytes_percent start_time stop_time files files_total bytes bytes_total replicating_stage_time_taken get_checkpoint_info_stage_time_taken file_diff_stage_time_taken get_files_stage_time_taken finalize_replication_stage_time_taken | ||
[index-1][0] runTask-1 127.0.0.1 0 0b 0s 3ms 0 done 10ms 6 100.0% 4753 100.0% 2023-03-16T13:46:16.802Z 2023-03-16T13:46:16.812Z 6 6 4.6kb 4.6kb 0s 2ms 0s 3ms 3ms | ||
[index-2][0] runTask-1 127.0.0.1 0 0b 0s 5ms 0 done 7ms 3 100.0% 3664 100.0% 2023-03-16T13:53:33.466Z 2023-03-16T13:53:33.474Z 3 3 3.5kb 3.5kb 0s 1ms 0s 2ms 2ms | ||
``` | ||
|
||
#### Example 4: Sorting the results | ||
|
||
The following query requests segment replication metrics with column headings for all indexes, sorted by shard ID in descending order: | ||
|
||
```json | ||
GET /_cat/segment_replication?v&s=shardId:desc | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains the sorted results: | ||
|
||
```bash | ||
shardId target_node target_host checkpoints_behind bytes_behind current_lag last_completed_lag rejected_requests | ||
[test6][1] runTask-2 127.0.0.1 0 0b 0s 5ms 0 | ||
[test6][0] runTask-2 127.0.0.1 0 0b 0s 4ms 0 | ||
``` | ||
|
||
#### Example 5: Using a metric alias | ||
|
||
You can either use the metric's full name or one of its aliases in a request. The following query is the same as the preceding query, but it uses the alias `s` instead of `shardID` for sorting: | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```json | ||
GET /_cat/segment_replication?v&s=s:desc | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Response metrics | ||
|
||
The following table lists the response metrics that are returned for all requests. When referring to a metric in a query parameter, you can provide either the metric's full name or any of its aliases, as shown in the previous [example](#example-5-using-a-metric-alias). | ||
|
||
Metric | Alias | Description | ||
:--- | :--- | :--- | ||
`shardId` | `s` | The ID of a specific shard. | ||
`target_host` | `thost` | The target host IP address. | ||
`target_node` | `tnode` | The target node name. | ||
`checkpoints_behind` | `cpb` | The number of checkpoints by which the replica shard is behind the primary shard. | ||
`bytes_behind` | `bb` | The number of bytes by which the replica shard is behind the primary shard. | ||
`current_lag` | `clag` | The time elapsed while waiting for a replica shard to catch up to the primary shard. | ||
`last_completed_lag` | `lcl` | The time it took for a replica shard to catch up to the latest primary shard refresh. | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`rejected_requests` | `rr` | The number of rejected requests for the replication group. | ||
|
||
### Additional metrics a detailed response returns | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The following table lists the additional response fields returned if `detailed` is set to `true`. | ||
|
||
Metric | Alias | Description | ||
:--- |:--- |:--- | ||
`stage` | `st` | The current stage of a segment replication event. | ||
`time` | `t`, `ti` | The time a segment replication event took to complete, in milliseconds. | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`files_fetched` | `ff` | The number of files fetched so far for a segment replication event. | ||
`files_percent` | `fp` | The percentage of files fetched so far for a segment replication event. | ||
`bytes_fetched` | `bf` | The number of bytes fetched so far for a segment replication event. | ||
`bytes_percent` | `bp` | The number of bytes fetched so far for a segment replication event as a percentage. | ||
`start_time` | `start` | The segment replication start time. | ||
`stop_time` | `stop` | The segment replication stop time. | ||
`files` | `f` | The number of files that needs to be fetched for a segment replication event. | ||
`files_total` | `tf` | The total number of files that are part of this recovery, including both reused and recovered files. | ||
`bytes` | `b` | The number of bytes that needs to be fetched for a segment replication event. | ||
`bytes_total` | `tb` | The total number of bytes in the shard. | ||
`replicating_stage_time_taken` | `rstt` | The time the `replicating` stage of a segment replication event took to complete. | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`get_checkpoint_info_stage_time_taken` | `gcistt` | The time the `get checkpoint info` stage of a segment replication event took to complete. | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`file_diff_stage_time_taken` | `fdstt` | The time the `file diff` stage of a segment replication event took to complete. | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`get_files_stage_time_taken` | `gfstt` | The time the `get files` stage of a segment replication event took to complete. | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`finalize_replication_stage_time_taken` | `frstt` | The time the `finalize replication` stage of a segment replication event took to complete. | ||
kolchfa-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit, should we remove this blank line?