kibana/packages/kbn-es-archiver
Tre b76b5c3b64
[ES Archiver][Load Action] Add perf option override to cli (#175781)
## Summary

With the merge of https://github.com/elastic/kibana/pull/174631, we've
need of a follow up pr,
to extend the performance override, to the command line interface.

Also, modify the type of the performance option override, by making both
the batch size and the concurrency optional.
- With this change, if one or the other of the two options (batch size &
concurrency) are not provided, the defaults are used.

### How to Test locally

Start the server in one terminal, such as:

`$ node scripts/functional_tests_server.js --config
test/functional/apps/console/config.ts`

Then in a second terminal:

`$ node scripts/es_archiver.js load
x-pack/test/functional/es_archives/logstash_functional --batch-size 300
--concurrency 2`

#### Additional Testing (regarding only using one option or the other)

_Just batch size_
`$ node scripts/es_archiver.js load
x-pack/test/functional/es_archives/logstash_functional --batch-size 300`

_Just concurrency_
`$ node scripts/es_archiver.js load
x-pack/test/functional/es_archives/logstash_functional --concurrency 2`

#### To Slow the Load Action Down (good for testing)

Load an archive with very low numbers

`node scripts/es_archiver.js load
x-pack/test/functional/es_archives/logstash_functional --concurrency 1
--batch-size 10`

You should see the progress indicator due to the forced latency

```
 info [x-pack/test/functional/es_archives/logstash_functional] Created index "logstash-2015.09.20"
 info [x-pack/test/functional/es_archives/logstash_functional] Deleted existing index "logstash-2015.09.21"
 info [x-pack/test/functional/es_archives/logstash_functional] Created index "logstash-2015.09.21"
 info progress: 2940
 info progress: 6040
 info progress: 9380
 info progress: 12451
 info [x-pack/test/functional/es_archives/logstash_functional] Indexed 4634 docs into "logstash-2015.09.22"
 info [x-pack/test/functional/es_archives/logstash_functional] Indexed 4757 docs into "logstash-2015.09.20"
 info [x-pack/test/functional/es_archives/logstash_functional] Indexed 4614 docs into "logstash-2015.09.21"
```

---------

Co-authored-by: Robert Oskamp <traeluki@gmail.com>
2024-02-02 14:24:04 +00:00
..
src [ES Archiver][Load Action] Add perf option override to cli (#175781) 2024-02-02 14:24:04 +00:00
index.ts [Es Archiver][Load Action] New Overridable Batch Size + Concurrency (#174631) 2024-01-26 14:42:16 +00:00
jest.config.js Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
kibana.jsonc [codeowners] add appex-qa for ftr-related packages (#155230) 2023-05-24 08:53:09 +02:00
package.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
README.mdx [Es Archiver][Load Action] New Overridable Batch Size + Concurrency (#174631) 2024-01-26 14:42:16 +00:00
tsconfig.json [esArchiver] restrict from modifying saved objects indexes (#169852) 2023-10-27 11:27:10 -07:00

---
id: kibDevDocsOpsEsArchiver
slug: /kibana-dev-docs/ops/es-archiver
title: "ES Archiver"
description: A tool which helps developers capture and restore ES indexes
date: 2024-01-11
tags: ['kibana', 'dev', 'contributor', 'operations', 'ci', 'es-archiver', 'load', 'es-archiver-load-action', 'performance']
---

The ES Archiver is a service primarily used by the Functional Tests to load up ES indexes using the bulk API which makes the archives more resilient to ES upgrades and easier to inspect/edit locally because they are just plain text files containing newline-delimited JSON (though they are sometimes compressed).

## CLI

This tool also has a CLI which can be used to save indexes to new archives or load additional archives into a specific ES instance.

To teach the ES Archiver how to talk to ES and Kibana it is ideal to start ES and Kibana using `node scripts/functional_test_servers --config some/config/file.ts` and then use the same `--config` flag when running `node scripts/es_archiver` so that it can access the location and authorization information about the ES instace from the FTR config file.

Additional information about what functionality the CLI provides can be found by running `node scripts/es_archiver --help`

## Performance Option Parameter

We now have a performance parameter for the es-archiver#load(), entry-point 
function.
This parameter is optional, with defaults:

 - Batch size: 5000
 - Concurrency (maximum number of bulk requests that can be active in parallel): 4 

According to our benchmarks, these default settings are giving the best results in terms of loading time for 
the majority of the archives. 
However, there might be cases where different settings are needed, so they can be overridden when loading an archive.


### How to override the default performance settings in test files

To control the batch size and concurrency

#### Example 

```typescript
await esArchiver.load('x-pack/test/functional/es_archives/getting_started/shakespeare', {
  performance: {
    batchSize: 300,
    concurrency: 1,
  },
});
```