-
Notifications
You must be signed in to change notification settings - Fork 115
Adding specification for the get random sample and get random sample stats APIs #5528
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
53b2e21
Adding get random sample API
masseyke f8329db
Adding get random sample API
masseyke fe9a064
renaming and correcting get random sample request and response
masseyke 644b9f8
adding get random sample stats
masseyke c1bdda0
fixing RawDocument
masseyke 7bcc8c1
prettier
masseyke d9f56b4
fixing a typo
masseyke 5acde95
changing visibility to feature flag
masseyke 831b8e3
fixed typo in rest_spec_name
masseyke 86b5587
reverting accidental changes
masseyke 01cb644
reverting accidental changes
masseyke 4193da6
reverting accidental changes
masseyke 94099ef
reverting changes to package.json
masseyke 1df580b
reverting changes to package.json
masseyke 8feb83c
making the docs url fit the current pattern
masseyke 7f95879
changing availability from serverless to stack
masseyke bdc738e
Merge branch 'main' into random-sample
masseyke 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
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -7,4 +7,4 @@ | |
| "@stoplight/spectral-cli": "^6.14.2" | ||
| }, | ||
| "version": "overlay" | ||
| } | ||
| } | ||
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
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
44 changes: 44 additions & 0 deletions
44
specification/indices/get_sample/GetRandomSampleRequest.ts
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,44 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { RequestBase } from '@_types/Base' | ||
| import { IndexName } from '@_types/common' | ||
|
|
||
| /** | ||
| * Request for a random sample of raw documents ingested into the given index or data stream. | ||
| * | ||
| * @rest_spec_name indices.get_sample | ||
| * @availability serverless visibility=feature_flag feature_flag=random_sampling since=9.3.0 stability=experimental | ||
| * @doc_id random_sample | ||
| * @doc_tag random_sample | ||
| */ | ||
| export interface Request extends RequestBase { | ||
| urls: [ | ||
| { | ||
| path: '/{index}/_sample' | ||
| methods: ['GET'] | ||
| } | ||
| ] | ||
| path_parts: { | ||
| /** | ||
| * Single index or data stream name. Wildcards are not supported. | ||
| */ | ||
| index: IndexName | ||
| } | ||
| } | ||
28 changes: 28 additions & 0 deletions
28
specification/indices/get_sample/GetRandomSampleResponse.ts
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,28 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { RawDocument } from './_types/RawDocument' | ||
|
|
||
| /** | ||
| * Response type for the get_random_samples API. | ||
| * It reuses the standard SearchResponse structure. | ||
| */ | ||
| export class Response { | ||
| body: { sample: RawDocument[] } | ||
| } |
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,33 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { PropertyName } from '@_types/common' | ||
| import { Property } from '@_types/mapping/Property' | ||
| import { Dictionary } from '@spec_utils/Dictionary' | ||
|
|
||
| export class RawDocument { | ||
| /** | ||
| * Name of the index for this raw document. | ||
| */ | ||
| index: string | ||
| /** | ||
| * The original raw source. | ||
| */ | ||
| source: Dictionary<PropertyName, Property> | ||
| } |
35 changes: 35 additions & 0 deletions
35
specification/indices/get_sample/examples/200_response/GetRandomSampleResponse1.yaml
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,35 @@ | ||
| # summary: '' | ||
| description: A successful response for retrieving the random sample for an index or data stream. | ||
| # type: response | ||
| # response_code: 200 | ||
| value: |- | ||
| { | ||
| "sample": [ | ||
| { | ||
| "index": "logs", | ||
| "source": { | ||
| "@timestamp": "2099-11-15T13:12:00", | ||
| "message": "Node 0 message", | ||
| "user": { | ||
| "id": "kimchy" | ||
| }, | ||
| "network": { | ||
| "name": "Guest" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "index": "logs", | ||
| "source": { | ||
| "@timestamp": "2079-11-15T13:12:00", | ||
| "message": "Node 1 message", | ||
| "user": { | ||
| "id": "kimchy" | ||
| }, | ||
| "network": { | ||
| "name": "Guest" | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } |
1 change: 1 addition & 0 deletions
1
specification/indices/get_sample/examples/request/GetRandomSampleRequest1.yaml
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 @@ | ||
| method_request: GET /my-index-000001/_sample |
44 changes: 44 additions & 0 deletions
44
specification/indices/get_sample_stats/GetRandomSampleStatsRequest.ts
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,44 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { RequestBase } from '@_types/Base' | ||
| import { IndexName } from '@_types/common' | ||
|
|
||
| /** | ||
| * Request stats for a random sample of raw documents ingested into the given index or data stream. | ||
| * | ||
| * @rest_spec_name indices.get_sample_stats | ||
| * @availability serverless visibility=feature_flag feature_flag=random_sampling since=9.3.0 stability=experimental | ||
| * @doc_id random_sample | ||
| * @doc_tag random_sample | ||
| */ | ||
| export interface Request extends RequestBase { | ||
| urls: [ | ||
| { | ||
| path: '/{index}/_sample/stats' | ||
| methods: ['GET'] | ||
| } | ||
| ] | ||
| path_parts: { | ||
| /** | ||
| * Single index or data stream name. Wildcards are not supported. | ||
| */ | ||
| index: IndexName | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
specification/indices/get_sample_stats/GetRandomSampleStatsResponse.ts
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,44 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { long } from '@_types/Numeric' | ||
| import { Duration, DurationValue, UnitMillis } from '@_types/Time' | ||
|
|
||
| /** | ||
| * Response type for the get_random_samples API. | ||
| * It reuses the standard SearchResponse structure. | ||
| */ | ||
| export class Response { | ||
| body: { | ||
| potential_samples: long | ||
| samples_rejected_for_max_samples_exceeded: long | ||
| samples_rejected_for_condition: long | ||
| samples_rejected_for_rate: long | ||
| samples_rejected_for_exception: long | ||
| samples_rejected_for_size: long | ||
| samples_accepted: long | ||
| time_sampling?: Duration | ||
| time_sampling_millis: DurationValue<UnitMillis> | ||
| time_evaluating_condition?: Duration | ||
| time_evaluating_condition_millis: DurationValue<UnitMillis> | ||
| time_compiling_condition?: Duration | ||
| time_compiling_condition_millis: DurationValue<UnitMillis> | ||
| last_exception?: string | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
...ication/indices/get_sample_stats/examples/200_response/GetRandomSampleStatsResponse1.yaml
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,20 @@ | ||
| # summary: '' | ||
| description: A successful response for retrieving the random sample stats for an index or data stream. | ||
| # type: response | ||
| # response_code: 200 | ||
| value: |- | ||
| { | ||
| "potential_samples": 2, | ||
| "samples_rejected_for_max_samples_exceeded": 0, | ||
| "samples_rejected_for_condition": 0, | ||
| "samples_rejected_for_rate": 0, | ||
| "samples_rejected_for_exception": 0, | ||
| "samples_rejected_for_size": 0, | ||
| "samples_accepted": 2, | ||
| "time_sampling": "415.7micros", | ||
| "time_sampling_millis": 0, | ||
| "time_evaluating_condition": "185.9micros", | ||
| "time_evaluating_condition_millis": 0, | ||
| "time_compiling_condition": "98.4micros", | ||
| "time_compiling_condition_millis": 0 | ||
| } |
1 change: 1 addition & 0 deletions
1
specification/indices/get_sample_stats/examples/request/GetRandomSampleStatsRequest1.yaml
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 @@ | ||
| method_request: GET /my-index-000001/_sample/stats |
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.
Just to clarify: this
@availabilityannotation will make this API available in serverless only. It will show up in the clients as not supported for stack unless you also add a stack@availabilityannotation.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.
Ohhh that's definitely not what I want!