Created
January 10, 2022 17:18
-
-
Save mshustov/a97bf6493c91536ca7459eb04637d639 to your computer and use it in GitHub Desktop.
generate empty dashboard and index-pattern SOs
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
/** | |
* A script to generate a bunch on empty dashboard and index-pattern SOs. | |
* Result of the script is written into bulk-create-api.json file. | |
* Created file can be imported into a Cloud instance with any network client. | |
* An example with curl: | |
POST https://{cloud_url}/s/{space-name}/api/saved_objects/_bulk_create?overwrite=true | |
Authorization: Basic {token} | |
Accept: application/json | |
Content-Type: application/json | |
kbn-xsrf: true | |
< /xxx/bulk-create-api.json | |
*/ | |
const Fs = require('fs'); | |
const startIndex = 250_000; | |
const indexPatterns = [...Array(50_000).keys()].map((value) => ({ | |
type: 'index-pattern', | |
id: `my-pattern-${startIndex + value}`, | |
attributes: { title: `my-${startIndex + value}-pattern-*` }, | |
})); | |
const dashboards = [...Array(50_000).keys()].map((value) => ({ | |
type: 'dashboard', | |
id: `my-dashboard-${startIndex + value}`, | |
attributes: { title: `my-${startIndex + value}-dashboard-title` }, | |
})); | |
const objects = [...indexPatterns, ...dashboards]; | |
Fs.writeFileSync(`${__dirname}/bulk-create-api.json`, JSON.stringify(objects)); | |
console.log(`Written ${objects.length} objects to ${__dirname}/bulk-create-api.json`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment