forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI Reporter for saved objects field count (elastic#70580)
* CI Reporter for saved objects field count * Metrics needs to be an array * Fix type failures * Link to field count issue * Revert "Link to field count issue" This reverts commit 8c0126b. * Break down field count per type * Don't log total metric as metrics report already calculates this * Add saved objects field count ci metrics test to codeowners * Address review comments * Add field count CI metrics for disabled plugins Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
21fc56e
commit 2f905e7
Showing
5 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
source test/scripts/jenkins_test_setup_xpack.sh | ||
|
||
checks-reporter-with-killswitch "Capture Kibana Saved Objects field count metrics" \ | ||
node scripts/functional_tests \ | ||
--debug --bail \ | ||
--kibana-install-dir "$installDir" \ | ||
--config test/saved_objects_field_count/config.ts; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; | ||
import { testRunner } from './runner'; | ||
|
||
export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
const kibanaCommonTestsConfig = await readConfigFile( | ||
require.resolve('../../../test/common/config.js') | ||
); | ||
|
||
return { | ||
...kibanaCommonTestsConfig.getAll(), | ||
|
||
testRunner, | ||
|
||
esTestCluster: { | ||
license: 'trial', | ||
from: 'snapshot', | ||
serverArgs: ['path.repo=/tmp/'], | ||
}, | ||
|
||
kbnTestServer: { | ||
...kibanaCommonTestsConfig.get('kbnTestServer'), | ||
serverArgs: [ | ||
...kibanaCommonTestsConfig.get('kbnTestServer.serverArgs'), | ||
// Enable plugins that are disabled by default to include their metrics | ||
// TODO: Find a way to automatically enable all discovered plugins | ||
'--xpack.ingestManager.enabled=true', | ||
'--xpack.lists.enabled=true', | ||
'--xpack.securitySolution.enabled=true', | ||
], | ||
}, | ||
}; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CiStatsReporter } from '@kbn/dev-utils'; | ||
import { FtrProviderContext } from './../functional/ftr_provider_context'; | ||
|
||
const IGNORED_FIELDS = [ | ||
// The following fields are returned by the _field_caps API but aren't counted | ||
// towards the index field limit. | ||
'_seq_no', | ||
'_id', | ||
'_version', | ||
'_field_names', | ||
'_ignored', | ||
'_feature', | ||
'_index', | ||
'_routing', | ||
'_source', | ||
'_type', | ||
'_nested_path', | ||
'_timestamp', | ||
// migrationVersion is dynamic so will be anywhere between 1..type count | ||
// depending on which objects are present in the index when querying the | ||
// field caps API. See https://github.com/elastic/kibana/issues/70815 | ||
'migrationVersion', | ||
]; | ||
|
||
export async function testRunner({ getService }: FtrProviderContext) { | ||
const log = getService('log'); | ||
const es = getService('es'); | ||
|
||
const reporter = CiStatsReporter.fromEnv(log); | ||
|
||
log.debug('Saved Objects field count metrics starting'); | ||
|
||
const { | ||
body: { fields }, | ||
} = await es.fieldCaps({ | ||
index: '.kibana', | ||
fields: '*', | ||
}); | ||
|
||
const fieldCountPerTypeMap: Map<string, number> = Object.keys(fields) | ||
.map((f) => f.split('.')[0]) | ||
.filter((f) => !IGNORED_FIELDS.includes(f)) | ||
.reduce((accumulator, f) => { | ||
accumulator.set(f, accumulator.get(f) + 1 || 1); | ||
return accumulator; | ||
}, new Map()); | ||
|
||
const metrics = Array.from(fieldCountPerTypeMap.entries()) | ||
.sort((a, b) => a[0].localeCompare(b[0])) | ||
.map(([fieldType, count]) => ({ | ||
group: 'Saved Objects .kibana field count', | ||
id: fieldType, | ||
value: count, | ||
})); | ||
|
||
log.debug( | ||
'Saved Objects field count metrics:\n', | ||
metrics.map(({ id, value }) => `${id}:${value}`).join('\n') | ||
); | ||
await reporter.metrics(metrics); | ||
log.debug('Saved Objects field count metrics done'); | ||
} |