You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Docs] Add documentation about storage indexers (#1374)
This PR adds documentation about the indexers used by the Elastic
Package Registry, focusing on the storage indexers (in technical preview).
In this PR, the information about the current endpoints has been updated,
including the available query parameters for `/search` and `/categories`
endpoints; and the Storage indexer based on Google Cloud Storage has
been set as GA.
*`/health`: Health of the service. Returns 200 if service is ready.
8
9
*`/search`: Search for packages. By default returns all the most recent packages available.
9
10
*`/categories`: List of the existing package categories and how many packages are in each category.
10
11
*`/package/{name}/{version}`: Info about a package
@@ -20,6 +21,17 @@ The `/search` API endpoint has few additional query parameters. More might be ad
20
21
*`category`: Filters the package by the given category. Available categories can be seen when going to `/categories` endpoint.
21
22
*`package`: Filters by a specific package name, for example `mysql`. Returns the most recent version.
22
23
*`all`: This can be set to `true` to list all package versions. This is set to `false` by default.
24
+
*`type`: Filters by a specific package type, for example `input`.
25
+
*`capabilities`: Filters the packages according to the given capabilities. This query parameter accepts a comma-separated list.
26
+
*`spec.min` and `spec.max`: Filters the packages by their `format_version` field given the version (major and minor numbers) set in the query parameter. It is not required to set both parameters. Examples:
27
+
-`?spec.min=2.2&spec.max=3.3`
28
+
-`?spec.max=3.3`
29
+
-`?spec.min=3.0`
30
+
*`discovery`: Returns the packages that define the `discovery` setting and fulfill the conditions in the query parameter. There are two different options:
31
+
- Based on fields: Packages must include discovery fields in their manifest and all of fields must be included in the list included in the request
32
+
- Example: Packages that contain both `process.pid` and `host.os.name` fields: `?discovery=fields:process.pid,host.os.name`
33
+
- Based on datasets: Packages must include discovery datasets in their manifest and at least one of the datasets must be included in the list included in the request:
34
+
- Example: Packages that contain at least one of `nginx.access` or `nginx.error` datasets: `?discovery=datasets:nginx.access,nginx.error`
23
35
*`prerelease`: This can be set to `true` to list prerelease versions of packages. Versions are considered prereleases if they are not stable according to semantic versioning, that is, if they are 0.x versions, or if they contain a prerelease tag. This is set to `false` by default.
24
36
*`experimental` (deprecated): This can be set to `true` to list packages considered to be experimental. This is set to `false` by default.
25
37
@@ -33,6 +45,12 @@ The `/categories` API endpoint has two additional query parameters.
33
45
*`prerelease`: This can be set to `true` to list prerelease versions of packages. Versions are considered prereleases if they are not stable according to semantic versioning, that is, if they are 0.x versions, or if they contain a prerelease tag. This is set to `false` by default.
34
46
*`experimental` (deprecated): This can be set to `true` to list categories from experimental packages. This is set to `false` by default.
35
47
*`include_policy_templates`: This can be set to `true` to include categories from policy templates. This is set to `false` by default.
48
+
*`capabilities`: List categories filtering the packages according to the given capabilities. This query parameter accepts a comma-separated list.
49
+
*`spec.min` and `spec.max`: List categories filtering the packages by their `format_version` field given the version (major and minor numbers) set in the query parameter. It is not required to set both parameters. Examples:
50
+
-`?spec.min=2.2&spec.max=3.3`
51
+
-`?spec.max=3.3`
52
+
-`?spec.min=3.0`
53
+
*`discovery`: List categories filtering the packages that define the `discovery` setting and fulfill the conditions in the query parameter. These query parameter follow the same syntax and behaviour to obtain the corresponding categories as in [`/search` endpoint](#search).
36
54
37
55
## Package structure
38
56
@@ -170,130 +188,6 @@ For that, you need to build a new Package Registry docker image from your requir
170
188
elastic-package stack up -v -d
171
189
```
172
190
173
-
### Testing Storage indexers
174
-
175
-
By default, Package Registry uses the FileSystem indexers.
176
-
177
-
#### Start services locally
178
-
Storage indexers can be tested locally following in two different ways:
179
-
1. Running Package Registry and a fake GCS server as independent services:
180
-
1. Launch the fake GCS server in one terminal:
181
-
- It creates a new folder with the expected contents for the bucket.
182
-
- It manages a docker-compose scenario with the fake GCS server.
183
-
- The search index JSON file can be downloaded from the [internal CI](https://buildkite.com/elastic/package-storage-infra-indexing/builds?branch=main) and set that file via `-i` parameter.
184
-
```shell
185
-
cd /path/to/repo/package-registry/
186
-
cd dev
187
-
bash launch_fake_gcs_server.sh -i ../storage/testdata/search-index-all-full.json -b example -c 1
188
-
```
189
-
2. Tune the configuration used by Package Registry as you require:
190
-
- By default, it uses the `config.yml` file at the root of the repository.
191
-
3. Launch EPR service in a different terminal:
192
-
- It builds package-registry with the contents of the working copy.
193
-
- It triggers the EPR service with the required environment variables to use storage indexers.
3. To stop these services, you just need to press `CTRL+Z` on this terminal.
213
-
214
-
Following these steps, EPR service should be reading files from the storage indexer and there should be log messages like these ones:
215
-
```json
216
-
{"log.level":"info","@timestamp":"2024-05-27T20:03:35.489+0200","log.origin":{"function":"github.com/elastic/package-registry/storage.(*Indexer).updateIndex","file.name":"storage/indexer.go","file.line":181},"message":"cursor will be updated","cursor.current":"","cursor.next":"1","ecs.version":"1.6.0"}
217
-
{"log.level":"info","@timestamp":"2024-05-27T20:03:35.827+0200","log.origin":{"function":"github.com/elastic/package-registry/storage.(*Indexer).updateIndex","file.name":"storage/indexer.go","file.line":192},"message":"Downloaded new search-index-all index","index.packages.size":"1133","ecs.version":"1.6.0"}
218
-
```
219
-
220
-
Package registry service is available at `http://localhost:8080`. Example of query using `curl`:
221
-
```shell
222
-
curl -s "http://localhost:8080/search"
223
-
```
224
-
225
-
#### Update indices locally
226
-
227
-
Following the steps mentioned above, a fake GCS server with the contents bucket is going to be
228
-
available at http://localhost:4443.
229
-
230
-
You can query directly to check if the contents of the bucket are available:
As this URL is available, it can also be updated the contents of the bucket to test the update index process
279
-
in the Elastic Package Registry service locally. For that you need to follow these steps:
280
-
1. Check the current cursor set. In EPR logs should be a log like this:
281
-
```json
282
-
{"log.level":"info","@timestamp":"2025-06-11T10:02:17.680+0200","log.origin":{"function":"github.com/elastic/package-registry/storage.(*Indexer).updateIndex","file.name":"storage/indexer.go","file.line":178},"message":"cursor is up-to-date","cursor.current":"1","ecs.version":"1.6.0"}
283
-
```
284
-
2. Update the new index JSON file to the new path `v2/metadata/<cursor>/search-index-all.json` and also update `cursor.json` file in the fake GCS server using the script helper:
After following these steps, the next log messages must appear in the EPR service:
292
-
```json
293
-
{"log.level":"info","@timestamp":"2025-06-11T10:07:17.680+0200","log.origin":{"function":"github.com/elastic/package-registry/storage.(*Indexer).updateIndex","file.name":"storage/indexer.go","file.line":181},"message":"cursor will be updated","cursor.current":"1","cursor.next":"2","ecs.version":"1.6.0"}
294
-
{"log.level":"info","@timestamp":"2025-06-11T10:07:25.749+0200","log.origin":{"function":"github.com/elastic/package-registry/storage.(*Indexer).updateIndex","file.name":"storage/indexer.go","file.line":192},"message":"Downloaded new search-index-all index","index.packages.size":"10775","ecs.version":"1.6.0"}
295
-
```
296
-
297
191
### Healthcheck
298
192
299
193
Availability of the service can be queried using the `/health` endpoint. As soon as `/health` returns a 200, the service is ready to handle requests.
Elastic Package Registry (EPR) supports multiple ways to retrieve package information. By default, it uses the File system indexer to read packages (folders or zip files) from the paths defined in the `config.yml`.
293
+
294
+
[Here](./docs/storage_indexers.md#storage-indexers-used-in-elastic-package-registry) you can read more about the different
295
+
indexers available in EPR as well as how to test EPR locally using these storage indexers without configuring a remote bucket.
0 commit comments