Skip to content

Commit 8b7d621

Browse files
seanzatzdevCopilotelasticsearchmachine
authored
add get all action for sampling configs (#137065)
* add get all action for sampling configs * Update server/src/main/java/org/elasticsearch/action/admin/indices/sampling/GetAllSampleConfigurationAction.java Co-authored-by: Copilot <[email protected]> * nit fix * [CI] Auto commit changes from spotless * implement indicesrequest.replaceable --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: elasticsearchmachine <[email protected]>
1 parent 7b0573e commit 8b7d621

File tree

10 files changed

+1094
-1
lines changed

10 files changed

+1094
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"indices.get_all_sample_configuration": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-all-sample-configuration",
5+
"description": "Get sampling configurations for all indices and data streams"
6+
},
7+
"stability": "experimental",
8+
"visibility": "public",
9+
"headers": {
10+
"accept": [
11+
"application/json"
12+
]
13+
},
14+
"url": {
15+
"paths": [
16+
{
17+
"path": "/_sample/config",
18+
"methods": [
19+
"GET"
20+
]
21+
}
22+
]
23+
},
24+
"params": {
25+
"master_timeout": {
26+
"type": "time",
27+
"description": "Timeout for connection to master node"
28+
}
29+
}
30+
}
31+
}
32+
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
---
2+
setup:
3+
- requires:
4+
cluster_features: [ "random_sampling" ]
5+
reason: requires feature 'random_sampling' to get random samples
6+
7+
---
8+
teardown:
9+
- do:
10+
indices.delete:
11+
index: "*test*"
12+
ignore_unavailable: true
13+
allow_no_indices: true
14+
15+
---
16+
"Get all sampling configurations with no configurations":
17+
- do:
18+
indices.create:
19+
index: test-no-config-index-1
20+
21+
- do:
22+
indices.create:
23+
index: test-no-config-index-2
24+
25+
- do:
26+
indices.get_all_sample_configuration: {}
27+
28+
# Should return an empty array
29+
- length: { $body: 0 }
30+
31+
---
32+
"Get all sampling configurations with single configuration":
33+
- do:
34+
indices.create:
35+
index: test-single-config-index
36+
37+
- do:
38+
indices.put_sample_configuration:
39+
index: test-single-config-index
40+
body:
41+
rate: 0.5
42+
max_samples: 100
43+
max_size: "10mb"
44+
time_to_live: "1h"
45+
46+
- match: { acknowledged: true }
47+
48+
- do:
49+
indices.get_all_sample_configuration:
50+
human: true
51+
52+
- length: { $body: 1 }
53+
- match: { 0.index: "test-single-config-index" }
54+
- match: { 0.configuration.rate: 0.5 }
55+
- match: { 0.configuration.max_samples: 100 }
56+
- match: { 0.configuration.max_size: "10mb" }
57+
- match: { 0.configuration.time_to_live: "1h" }
58+
59+
---
60+
"Get all sampling configurations with multiple configurations":
61+
- do:
62+
indices.create:
63+
index: test-multi-config-index-1
64+
65+
- do:
66+
indices.create:
67+
index: test-multi-config-index-2
68+
69+
- do:
70+
indices.create:
71+
index: test-multi-config-index-3
72+
73+
- do:
74+
indices.put_sample_configuration:
75+
index: test-multi-config-index-1
76+
body:
77+
rate: 0.3
78+
max_samples: 50
79+
80+
- match: { acknowledged: true }
81+
82+
- do:
83+
indices.put_sample_configuration:
84+
index: test-multi-config-index-2
85+
body:
86+
rate: 0.7
87+
max_samples: 200
88+
max_size: "20mb"
89+
90+
- match: { acknowledged: true }
91+
92+
- do:
93+
indices.put_sample_configuration:
94+
index: test-multi-config-index-3
95+
body:
96+
rate: 1.0
97+
if: "ctx?.field == 'sample_me'"
98+
99+
- match: { acknowledged: true }
100+
101+
- do:
102+
indices.get_all_sample_configuration:
103+
human: true
104+
105+
- length: { $body: 3 }
106+
# Note: Array order may vary, so we just verify all 3 configurations exist
107+
- is_true: 0.index
108+
- is_true: 0.configuration
109+
- is_true: 1.index
110+
- is_true: 1.configuration
111+
- is_true: 2.index
112+
- is_true: 2.configuration
113+
114+
---
115+
"Get all sampling configurations with mixed indices":
116+
- do:
117+
indices.create:
118+
index: test-mixed-configured-1
119+
120+
- do:
121+
indices.create:
122+
index: test-mixed-unconfigured
123+
124+
- do:
125+
indices.create:
126+
index: test-mixed-configured-2
127+
128+
- do:
129+
indices.put_sample_configuration:
130+
index: test-mixed-configured-1
131+
body:
132+
rate: 0.4
133+
max_samples: 75
134+
135+
- match: { acknowledged: true }
136+
137+
- do:
138+
indices.put_sample_configuration:
139+
index: test-mixed-configured-2
140+
body:
141+
rate: 0.6
142+
time_to_live: "2h"
143+
144+
- match: { acknowledged: true }
145+
146+
- do:
147+
indices.get_all_sample_configuration:
148+
human: true
149+
150+
# Should only return configured indices (2 items)
151+
- length: { $body: 2 }
152+
- is_true: 0.index
153+
- is_true: 0.configuration
154+
- is_true: 1.index
155+
- is_true: 1.configuration
156+
157+
---
158+
"Get all sampling configurations after update":
159+
- do:
160+
indices.create:
161+
index: test-update-all-index
162+
163+
# Set initial configuration
164+
- do:
165+
indices.put_sample_configuration:
166+
index: test-update-all-index
167+
body:
168+
rate: 0.2
169+
max_samples: 30
170+
171+
- match: { acknowledged: true }
172+
173+
- do:
174+
indices.get_all_sample_configuration:
175+
human: true
176+
177+
- length: { $body: 1 }
178+
- match: { 0.index: "test-update-all-index" }
179+
- match: { 0.configuration.rate: 0.2 }
180+
- match: { 0.configuration.max_samples: 30 }
181+
182+
# Update configuration
183+
- do:
184+
indices.put_sample_configuration:
185+
index: test-update-all-index
186+
body:
187+
rate: 0.9
188+
max_samples: 150
189+
max_size: "15mb"
190+
191+
- match: { acknowledged: true }
192+
193+
# Verify updated configuration in get all
194+
- do:
195+
indices.get_all_sample_configuration:
196+
human: true
197+
198+
- length: { $body: 1 }
199+
- match: { 0.index: "test-update-all-index" }
200+
- match: { 0.configuration.rate: 0.9 }
201+
- match: { 0.configuration.max_samples: 150 }
202+
- match: { 0.configuration.max_size: "15mb" }
203+
204+
---
205+
"Get all sampling configurations after deletion":
206+
- do:
207+
indices.create:
208+
index: test-delete-all-index-1
209+
210+
- do:
211+
indices.create:
212+
index: test-delete-all-index-2
213+
214+
- do:
215+
indices.put_sample_configuration:
216+
index: test-delete-all-index-1
217+
body:
218+
rate: 0.5
219+
max_samples: 100
220+
221+
- match: { acknowledged: true }
222+
223+
- do:
224+
indices.put_sample_configuration:
225+
index: test-delete-all-index-2
226+
body:
227+
rate: 0.8
228+
max_samples: 200
229+
230+
- match: { acknowledged: true }
231+
232+
# Verify both configurations exist
233+
- do:
234+
indices.get_all_sample_configuration:
235+
human: true
236+
237+
- length: { $body: 2 }
238+
239+
# Delete one configuration
240+
- do:
241+
indices.delete_sample_configuration:
242+
index: test-delete-all-index-1
243+
244+
- match: { acknowledged: true }
245+
246+
# Verify only one configuration remains
247+
- do:
248+
indices.get_all_sample_configuration:
249+
human: true
250+
251+
- length: { $body: 1 }
252+
- match: { 0.index: "test-delete-all-index-2" }
253+
- match: { 0.configuration.rate: 0.8 }
254+
- match: { 0.configuration.max_samples: 200 }

0 commit comments

Comments
 (0)