Skip to content

es_archiver empty-monitoring-index action#112376

Closed
matschaffer wants to merge 1 commit intoelastic:mainfrom
matschaffer:empty-monitoring-indices
Closed

es_archiver empty-monitoring-index action#112376
matschaffer wants to merge 1 commit intoelastic:mainfrom
matschaffer:empty-monitoring-indices

Conversation

@matschaffer
Copy link
Copy Markdown
Contributor

@matschaffer matschaffer commented Sep 16, 2021

Summary

Adds a node scripts/es_archiver.js empty-monitoring-index

Should be runnable like this against the observablity-dev docker testing setup.

node scripts/es_archiver.js empty-monitoring-index --es-url https://elastic:changeme@localhost:9200 --es-ca ca.crt 

But you first have to grab the ca from the docker volume.

I also seem to be running into some stale javascript file issues, yarn kbn bootstrap seems to be needed to ensure you're using the latest local code.

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @matschaffer

}

function isMonitoringIndex(index?: string): index is string {
return Boolean(index && /^\.monitoring-.*$/.test(index));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a necessary check? Can't we trust that since we only asked for indexes matching .monitoring-* that this will always return true?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not, just a hackey first cut to get the string assertion.


async function fetchMonitoringIndices(client: KibanaClient) {
const resp = await client.cat.indices(
{ index: '.monitoring-*', format: 'json' },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than hard-coding the .monitoring-* index pattern here I'd much prefer that require specifying an index pattern on the CLI and then pass it in, so that all indexes which match that wildcard pattern will be deleted. Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Sure could. I don't consider this PR final, hence the draft status. I was basically just trying it out as a stub here. Curious to get your thoughts on #88986 (comment) before proceeding.

Copy link
Copy Markdown
Contributor Author

@matschaffer matschaffer Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per feedback there, I'll plan to update this to be node scripts/es_archiver.js delete-indices '.monitoring-*' so we can use on any index pattern needed.

stats: Stats;
log: ToolingLog;
}) {
deleteMonitoringIndices({ client, stats, log });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you await here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@matschaffer
Copy link
Copy Markdown
Contributor Author

Closing this down. It seemed like a good idea at the time, but in practice it's easy enough to restart yarn es to get a clean data space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants