Skip to content

Commit 6f23db4

Browse files
authored
[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.
1 parent 1f70b97 commit 6f23db4

9 files changed

Lines changed: 208 additions & 133 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
* Skip adding to cache requests containing package query parameter. [#1378](https://github.com/elastic/package-registry/pull/1378)
1717
* Added cache for categories endpoint (SQL storage indexer). [#1379](https://github.com/elastic/package-registry/1379)
1818
* Update default values for cache search and TTL settings search (SQL storage indexer). [#1379](https://github.com/elastic/package-registry/1379)
19+
* Storage indexer based on Google Cloud Storage is now GA. [#1374](https://github.com/elastic/package-registry/pull/1374)
1920

2021
### Deprecated
2122

README.md

Lines changed: 25 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Endpoints:
66

77
* `/`: Info about the registry
8+
* `/health`: Health of the service. Returns 200 if service is ready.
89
* `/search`: Search for packages. By default returns all the most recent packages available.
910
* `/categories`: List of the existing package categories and how many packages are in each category.
1011
* `/package/{name}/{version}`: Info about a package
@@ -20,6 +21,17 @@ The `/search` API endpoint has few additional query parameters. More might be ad
2021
* `category`: Filters the package by the given category. Available categories can be seen when going to `/categories` endpoint.
2122
* `package`: Filters by a specific package name, for example `mysql`. Returns the most recent version.
2223
* `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`
2335
* `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.
2436
* `experimental` (deprecated): This can be set to `true` to list packages considered to be experimental. This is set to `false` by default.
2537

@@ -33,6 +45,12 @@ The `/categories` API endpoint has two additional query parameters.
3345
* `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.
3446
* `experimental` (deprecated): This can be set to `true` to list categories from experimental packages. This is set to `false` by default.
3547
* `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).
3654

3755
## Package structure
3856

@@ -170,130 +188,6 @@ For that, you need to build a new Package Registry docker image from your requir
170188
elastic-package stack up -v -d
171189
```
172190
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.
194-
```shell
195-
cd /path/to/repo/package-registry/
196-
cd dev
197-
bash launch_epr_service_storage_indexer.sh -p ../config.yml
198-
```
199-
4. To stop both services, you just need to press `CTRL+Z` on each terminal. The scripts also manage the cleanup process.
200-
2. Running just Package Registry (fake GCS server runs using the golang library within Package Registry service):
201-
1. Tune the configuration used by Package Registry as you require:
202-
- By default, it uses the `config.yml` file at the root of the repository.
203-
2. Launch EPR service:
204-
- It builds package-registry with the contents of the working copy.
205-
- It triggers the EPR service with the required environment variables to use storage indexers.
206-
- Fake GCS server will run as part of the same process via the Golang library.
207-
```shell
208-
cd /path/to/repo/package-registry/
209-
cd dev
210-
bash launch_epr_service_storage_indexer.sh -i ../storage/testdata/search-index-all-full.json -p ../config.yml
211-
```
212-
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:
231-
- `http://localhost:4443/storage/v1/b/<bucket>/o`
232-
- Example:
233-
```shell
234-
$ curl -s http://localhost:4443/storage/v1/b/fake-package-storage-internal/o |jq -r .
235-
{
236-
"kind": "storage#objects",
237-
"items": [
238-
{
239-
"kind": "storage#object",
240-
"name": "v2/metadata/1/search-index-all.json",
241-
"id": "fake-package-storage-internal/v2/metadata/1/search-index-all.json",
242-
"bucket": "fake-package-storage-internal",
243-
"size": "22157319",
244-
"crc32c": "s7tNlg==",
245-
"md5Hash": "49AZWmusj2eLpjH98ePdCw==",
246-
"etag": "49AZWmusj2eLpjH98ePdCw==",
247-
"storageClass": "STANDARD",
248-
"timeCreated": "2025-06-11T09:54:21.239848+02:00",
249-
"timeStorageClassUpdated": "2025-06-11T09:54:21.239848+02:00",
250-
"updated": "2025-06-11T09:54:21.239848+02:00",
251-
"generation": "1749628461332535",
252-
"selfLink": "/storage/v1/b/fake-package-storage-internal/o/v2%2Fmetadata%2F1%2Fsearch-index-all.json",
253-
"mediaLink": "/download/storage/v1/b/fake-package-storage-internal/o/v2%2Fmetadata%2F1%2Fsearch-index-all.json?alt=media",
254-
"metageneration": "1"
255-
},
256-
{
257-
"kind": "storage#object",
258-
"name": "v2/metadata/cursor.json",
259-
"id": "fake-package-storage-internal/v2/metadata/cursor.json",
260-
"bucket": "fake-package-storage-internal",
261-
"size": "15",
262-
"crc32c": "oP5v4Q==",
263-
"md5Hash": "vxi+8LZ201P+UukYETdzvQ==",
264-
"etag": "vxi+8LZ201P+UukYETdzvQ==",
265-
"storageClass": "STANDARD",
266-
"timeCreated": "2025-06-11T09:54:21.239843+02:00",
267-
"timeStorageClassUpdated": "2025-06-11T09:54:21.239847+02:00",
268-
"updated": "2025-06-11T09:54:21.239847+02:00",
269-
"generation": "1749628461239867",
270-
"selfLink": "/storage/v1/b/fake-package-storage-internal/o/v2%2Fmetadata%2Fcursor.json",
271-
"mediaLink": "/download/storage/v1/b/fake-package-storage-internal/o/v2%2Fmetadata%2Fcursor.json?alt=media",
272-
"metageneration": "1"
273-
}
274-
]
275-
}
276-
```
277-
278-
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:
285-
```shell
286-
# bash dev/updateIndexDatabase.sh -i <path_to_index> -c <cursor_string> -b <bucket>
287-
# Example adding a new index using as cursor "2":
288-
bash dev/updateIndexDatabase.sh -i ./search-index-all.json -c 2 -b fake-package-storage-internal
289-
```
290-
291-
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-
297191
### Healthcheck
298192
299193
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.
@@ -393,6 +287,13 @@ For example:
393287
package-registry --feature-proxy-mode=true -proxy-to=https://epr.elastic.co
394288
```
395289
290+
### Storage indexers
291+
292+
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.
296+
396297
397298
## Release
398299

dev/launch_epr_service_storage_indexer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export EPR_CONFIG="${CONFIG_PATH}"
118118
# export EPR_SQL_INDEXER_CATEGORIES_CACHE_SIZE=100
119119
# export EPR_SQL_INDEXER_CATEGORIES_CACHE_TTL=24h
120120
# export EPR_SQL_INDEXER_READ_PACKAGES_BATCH_SIZE=2000
121-
# export EPR_SQL_INDEXER_DB_INSERT_BATCH_SIZE=2000
121+
# export EPR_SQL_INDEXER_DB_INSERT_BATCH_SIZE=500
122122

123123
./package-registry
124124

0 commit comments

Comments
 (0)