-
Notifications
You must be signed in to change notification settings - Fork 508
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 bytes
into "Query parameters" for CAT Segment Replication API
#4731
Add bytes
into "Query parameters" for CAT Segment Replication API
#4731
Conversation
Signed-off-by: Tianli Feng <ftianli@amazon.com>
Signed-off-by: Tianli Feng <ftianli@amazon.com>
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.
Thanks, @tlfeng! Could you clarify the default values for these? An example could help as well.
@@ -39,10 +39,11 @@ Parameter | Data type | Description | |||
`active_only` | Boolean | If `true`, the response only includes active segment replications. Defaults to `false`. | |||
[`detailed`](#additional-detailed-response-metrics) | String | If `true`, the response includes additional metrics for each stage of a segment replication event. Defaults to `false`. | |||
`shards` | String | A comma-separated list of shards to display. | |||
`byte` | Byte size | [Units]({{site.url}}{{site.baseurl}}/opensearch/units/) used to display byte size values. |
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.
Is there a default for this parameter? Since it's optional, I assume there should be a default units to display byte values.
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.
`byte` | Byte size | [Units]({{site.url}}{{site.baseurl}}/opensearch/units/) used to display byte size values. | |
`byte` | Byte units | [Units]({{site.url}}{{site.baseurl}}/opensearch/units/) used to display byte size values. |
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.
Sorry to show the Elastic's document https://www.elastic.co/guide/en/elasticsearch/reference/7.10/cat.html#numeric-formats, but that can make the explanation easier.
By default, the value of "bytes" and "time" fields are formatted to be human-readable. The value will be added with the most suitable unit.
For example:
When file size larger than 1000 byte, the unit will be shown as "kb", otherwise shown as "b".
When the time is more than 1000 milliseconds, the unit will be shown as "s", otherwise shown as "ms".
When the number is even larger, a higher-level unit will be shown.
$ curl "opens-clust-xxx.elb.us-west-2.amazonaws.com/_cat/segment_replication?v"
shardId target_node target_host checkpoints_behind bytes_behind current_lag last_completed_lag rejected_requests
[logs-221998][7] ip-10-0-4-86.us-west-2.compute.internal 10.0.4.86 1 3b 988ms 823ms 0
[logs-221998][7] ip-10-0-3-170.us-west-2.compute.internal 10.0.3.170 1 39.2kb 988ms 1.2s 0
[logs-231998][0] ip-10-0-3-66.us-west-2.compute.internal 10.0.3.66 1 31.6kb 791ms 699ms 0
This is an example of the API response when assigning the parameters time=ms
and bytes=b
, the value will be purely numeric and directly comparable.
$ curl "opens-clust-xxx.elb.us-west-2.amazonaws.com/_cat/segment_replication?v&time=ms&bytes=b"
shardId target_node target_host checkpoints_behind bytes_behind current_lag last_completed_lag rejected_requests
[logs-221998][0] ip-10-0-5-102.us-west-2.compute.internal 10.0.5.102 1 7480 1116 1664 0
[logs-221998][0] ip-10-0-3-36.us-west-2.compute.internal 10.0.3.36 1 16034 1116 1316 0
[logs-221998][0] ip-10-0-4-86.us-west-2.compute.internal 10.0.4.86 1 16034 1116 2018 0
The source codes of adding the most suitable unit when output are here:
https://github.com/opensearch-project/OpenSearch/blob/7278f434cd83f095623e34c2105f1b79d247af18/libs/core/src/main/java/org/opensearch/core/common/unit/ByteSizeValue.java#L166
https://github.com/opensearch-project/OpenSearch/blob/7278f434cd83f095623e34c2105f1b79d247af18/libs/common/src/main/java/org/opensearch/common/unit/TimeValue.java#L251
`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). | ||
`time` | Time | [Units]({{site.url}}{{site.baseurl}}/opensearch/units/) used to display time values. |
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.
Same in this line... if time
is not specified, what are the units used to display time values?
`time` | Time | [Units]({{site.url}}{{site.baseurl}}/opensearch/units/) used to display time values. | |
`time` | Time units | [Units]({{site.url}}{{site.baseurl}}/opensearch/units/) used to display time values. |
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.
Please see my above comment #4731 (comment). Forgot to add a clear example for the default situation earlier.
Signed-off-by: Tianli Feng <ftianli@amazon.com>
byte
into "Query parameters" for CAT Segment Replication APIbytes
into "Query parameters" for CAT Segment Replication API
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.
Thanks a lot for the explanation. In this case, I think "Time units" and "Byte units" makes the most sense for the data types of these parameters. I'd also like to add an explanation that you provided and the examples to the documentation but I can address that in another PR.
It make sense! I also thought about using "Time/Byte Unit" as the data type. I finally changed my mind to make inconsistent with other CAT API pages. |
…d 'Time unites' Signed-off-by: Tianli Feng <ftianli@amazon.com>
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.
LGTM. Thanks, @tlfeng!
…4731) * Add `byte` into "Query parameters" for CAT Segment Replication API Signed-off-by: Tianli Feng <ftianli@amazon.com> * Add a trailing slash to the links Signed-off-by: Tianli Feng <ftianli@amazon.com> * Correct the parameter name to bytes Signed-off-by: Tianli Feng <ftianli@amazon.com> * Change data type of 'bytes' and 'time' parameters to 'Byte unites' and 'Time unites' Signed-off-by: Tianli Feng <ftianli@amazon.com> --------- Signed-off-by: Tianli Feng <ftianli@amazon.com> (cherry picked from commit 4d6106a) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…4731) (#4735) * Add `byte` into "Query parameters" for CAT Segment Replication API * Add a trailing slash to the links * Correct the parameter name to bytes * Change data type of 'bytes' and 'time' parameters to 'Byte unites' and 'Time unites' --------- (cherry picked from commit 4d6106a) Signed-off-by: Tianli Feng <ftianli@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…pensearch-project#4731) * Add `byte` into "Query parameters" for CAT Segment Replication API Signed-off-by: Tianli Feng <ftianli@amazon.com> * Add a trailing slash to the links Signed-off-by: Tianli Feng <ftianli@amazon.com> * Correct the parameter name to bytes Signed-off-by: Tianli Feng <ftianli@amazon.com> * Change data type of 'bytes' and 'time' parameters to 'Byte unites' and 'Time unites' Signed-off-by: Tianli Feng <ftianli@amazon.com> --------- Signed-off-by: Tianli Feng <ftianli@amazon.com>
…4731) * Add `byte` into "Query parameters" for CAT Segment Replication API Signed-off-by: Tianli Feng <ftianli@amazon.com> * Add a trailing slash to the links Signed-off-by: Tianli Feng <ftianli@amazon.com> * Correct the parameter name to bytes Signed-off-by: Tianli Feng <ftianli@amazon.com> * Change data type of 'bytes' and 'time' parameters to 'Byte unites' and 'Time unites' Signed-off-by: Tianli Feng <ftianli@amazon.com> --------- Signed-off-by: Tianli Feng <ftianli@amazon.com>
Description
bytes
parameter into "Query parameters" section for CAT Segment Replication APIThis is a common parameters for CAT API, and I think it's worth to mention here, because it's available for "cat-segment-replication" REST API.
time
parameter. The default value is not milliseconds, but no default value. By default, the response is human-formatted, for example,1.2s
instead of1209
. Besides, the "data type" is not Time "value", but Time "unit".An example for the API response:
In addition, the format and description in the CAT Segment Replication API is a bit distinct with other CAT APIs, such as CAT Recovery.
1 There is no "code" (``) style for the parameter names for the other pages.
2 The descriptions for the parameters are different from other pages.
I didn't make changes to make "cat-segment-replication" align with other pages.
Issues Resolved
n/a
Checklist
For more information on following Developer Certificate of Origin and signing off your commits, please check here.