Skip to content

Commit af8734f

Browse files
committed
Merge branch 'master' into uptime_a11y-tests
2 parents 19c008d + 2903e2f commit af8734f

File tree

20 files changed

+210
-46
lines changed

20 files changed

+210
-46
lines changed

packages/kbn-dev-utils/src/ci_stats_reporter/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This class integrates with the `ciStats.trackBuild {}` Jenkins Pipeline function
88

99
To create an instance of the reporter, import the class and call `CiStatsReporter.fromEnv(log)` (passing it a tooling log).
1010

11-
#### `CiStatsReporter#metric(name: string, subName: string, value: number)`
11+
#### `CiStatsReporter#metrics(metrics: Array<{ group: string, id: string, value: number }>)`
1212

1313
Use this method to record metrics in the Kibana CI Stats service.
1414

@@ -19,5 +19,11 @@ import { CiStatsReporter, ToolingLog } from '@kbn/dev-utils';
1919

2020
const log = new ToolingLog(...);
2121
const reporter = CiStatsReporter.fromEnv(log)
22-
reporter.metric('Build speed', specificBuildName, timeToRunBuild)
22+
reporter.metrics([
23+
{
24+
group: 'Build size',
25+
id: specificBuildName,
26+
value: sizeOfBuild
27+
}
28+
])
2329
```

packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,31 @@ export class CiStatsReporter {
8484
return !!this.config;
8585
}
8686

87-
async metric(name: string, subName: string, value: number) {
87+
async metrics(metrics: Array<{ group: string; id: string; value: number }>) {
8888
if (!this.config) {
8989
return;
9090
}
9191

9292
let attempt = 0;
9393
const maxAttempts = 5;
94+
const bodySummary = metrics
95+
.map(({ group, id, value }) => `[${group}/${id}=${value}]`)
96+
.join(' ');
9497

9598
while (true) {
9699
attempt += 1;
97100

98101
try {
99102
await Axios.request({
100103
method: 'POST',
101-
url: '/metric',
104+
url: '/v1/metrics',
102105
baseURL: this.config.apiUrl,
103-
params: {
104-
buildId: this.config.buildId,
105-
},
106106
headers: {
107107
Authorization: `token ${this.config.apiToken}`,
108108
},
109109
data: {
110-
name,
111-
subName,
112-
value,
110+
buildId: this.config.buildId,
111+
metrics,
113112
},
114113
});
115114

@@ -125,14 +124,14 @@ export class CiStatsReporter {
125124
this.log.warning(
126125
`error recording metric [status=${error.response.status}] [resp=${inspect(
127126
error.response.data
128-
)}] [${name}/${subName}=${value}]`
127+
)}] ${bodySummary}`
129128
);
130129
return;
131130
}
132131

133132
if (attempt === maxAttempts) {
134133
this.log.warning(
135-
`failed to reach kibana-ci-stats service too many times, unable to record metric [${name}/${subName}=${value}]`
134+
`failed to reach kibana-ci-stats service too many times, unable to record metric ${bodySummary}`
136135
);
137136
return;
138137
}

packages/kbn-optimizer/src/cli.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import 'source-map-support/register';
2121

2222
import Path from 'path';
2323

24-
import { run, REPO_ROOT, createFlagError, createFailError, CiStatsReporter } from '@kbn/dev-utils';
24+
import { run, REPO_ROOT, createFlagError, CiStatsReporter } from '@kbn/dev-utils';
2525

2626
import { logOptimizerState } from './log_optimizer_state';
2727
import { OptimizerConfig } from './optimizer';
@@ -82,9 +82,9 @@ run(
8282
throw createFlagError('expected --scan-dir to be a string');
8383
}
8484

85-
const reportStatsName = flags['report-stats'];
86-
if (reportStatsName !== undefined && typeof reportStatsName !== 'string') {
87-
throw createFlagError('expected --report-stats to be a string');
85+
const reportStats = flags['report-stats'] ?? false;
86+
if (typeof reportStats !== 'boolean') {
87+
throw createFlagError('expected --report-stats to have no value');
8888
}
8989

9090
const config = OptimizerConfig.create({
@@ -103,22 +103,32 @@ run(
103103

104104
let update$ = runOptimizer(config);
105105

106-
if (reportStatsName) {
106+
if (reportStats) {
107107
const reporter = CiStatsReporter.fromEnv(log);
108108

109109
if (!reporter.isEnabled()) {
110-
throw createFailError('Unable to initialize CiStatsReporter from env');
110+
log.warning('Unable to initialize CiStatsReporter from env');
111111
}
112112

113-
update$ = update$.pipe(reportOptimizerStats(reporter, reportStatsName));
113+
update$ = update$.pipe(reportOptimizerStats(reporter, config));
114114
}
115115

116116
await update$.pipe(logOptimizerState(log, config)).toPromise();
117117
},
118118
{
119119
flags: {
120-
boolean: ['core', 'watch', 'oss', 'examples', 'dist', 'cache', 'profile', 'inspect-workers'],
121-
string: ['workers', 'scan-dir', 'report-stats'],
120+
boolean: [
121+
'core',
122+
'watch',
123+
'oss',
124+
'examples',
125+
'dist',
126+
'cache',
127+
'profile',
128+
'inspect-workers',
129+
'report-stats',
130+
],
131+
string: ['workers', 'scan-dir'],
122132
default: {
123133
core: true,
124134
examples: true,
@@ -136,7 +146,7 @@ run(
136146
--dist create bundles that are suitable for inclusion in the Kibana distributable
137147
--scan-dir add a directory to the list of directories scanned for plugins (specify as many times as necessary)
138148
--no-inspect-workers when inspecting the parent process, don't inspect the workers
139-
--report-stats=[name] attempt to report stats about this execution of the build to the kibana-ci-stats service using this name
149+
--report-stats attempt to report stats about this execution of the build to the kibana-ci-stats service using this name
140150
`,
141151
},
142152
}

packages/kbn-optimizer/src/report_optimizer_stats.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import { materialize, mergeMap, dematerialize } from 'rxjs/operators';
2121
import { CiStatsReporter } from '@kbn/dev-utils';
2222

2323
import { OptimizerUpdate$ } from './run_optimizer';
24-
import { OptimizerState } from './optimizer';
24+
import { OptimizerState, OptimizerConfig } from './optimizer';
2525
import { pipeClosure } from './common';
2626

27-
export function reportOptimizerStats(reporter: CiStatsReporter, name: string) {
27+
export function reportOptimizerStats(reporter: CiStatsReporter, config: OptimizerConfig) {
2828
return pipeClosure((update$: OptimizerUpdate$) => {
2929
let lastState: OptimizerState | undefined;
3030
return update$.pipe(
@@ -35,7 +35,18 @@ export function reportOptimizerStats(reporter: CiStatsReporter, name: string) {
3535
}
3636

3737
if (n.kind === 'C' && lastState) {
38-
await reporter.metric('@kbn/optimizer build time', name, lastState.durSec);
38+
await reporter.metrics(
39+
config.bundles.map(bundle => {
40+
// make the cache read from the cache file since it was likely updated by the worker
41+
bundle.cache.refresh();
42+
43+
return {
44+
group: `@kbn/optimizer bundle module count`,
45+
id: bundle.id,
46+
value: bundle.cache.getModuleCount() || 0,
47+
};
48+
})
49+
);
3950
}
4051

4152
return n;

packages/kbn-pm/dist/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43933,30 +43933,29 @@ class CiStatsReporter {
4393343933
isEnabled() {
4393443934
return !!this.config;
4393543935
}
43936-
async metric(name, subName, value) {
43936+
async metrics(metrics) {
4393743937
var _a, _b, _c, _d;
4393843938
if (!this.config) {
4393943939
return;
4394043940
}
4394143941
let attempt = 0;
4394243942
const maxAttempts = 5;
43943+
const bodySummary = metrics
43944+
.map(({ group, id, value }) => `[${group}/${id}=${value}]`)
43945+
.join(' ');
4394343946
while (true) {
4394443947
attempt += 1;
4394543948
try {
4394643949
await axios_1.default.request({
4394743950
method: 'POST',
43948-
url: '/metric',
43951+
url: '/v1/metrics',
4394943952
baseURL: this.config.apiUrl,
43950-
params: {
43951-
buildId: this.config.buildId,
43952-
},
4395343953
headers: {
4395443954
Authorization: `token ${this.config.apiToken}`,
4395543955
},
4395643956
data: {
43957-
name,
43958-
subName,
43959-
value,
43957+
buildId: this.config.buildId,
43958+
metrics,
4396043959
},
4396143960
});
4396243961
return;
@@ -43968,11 +43967,11 @@ class CiStatsReporter {
4396843967
}
4396943968
if (((_b = error) === null || _b === void 0 ? void 0 : _b.response) && error.response.status !== 502) {
4397043969
// error response from service was received so warn the user and move on
43971-
this.log.warning(`error recording metric [status=${error.response.status}] [resp=${util_1.inspect(error.response.data)}] [${name}/${subName}=${value}]`);
43970+
this.log.warning(`error recording metric [status=${error.response.status}] [resp=${util_1.inspect(error.response.data)}] ${bodySummary}`);
4397243971
return;
4397343972
}
4397443973
if (attempt === maxAttempts) {
43975-
this.log.warning(`failed to reach kibana-ci-stats service too many times, unable to record metric [${name}/${subName}=${value}]`);
43974+
this.log.warning(`failed to reach kibana-ci-stats service too many times, unable to record metric ${bodySummary}`);
4397643975
return;
4397743976
}
4397843977
// we failed to reach the backend and we have remaining attempts, lets retry after a short delay

src/dev/build/tasks/build_kibana_platform_plugins.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ export const BuildKibanaPlatformPluginsTask = {
3939
});
4040

4141
const reporter = CiStatsReporter.fromEnv(log);
42-
const reportStatsName = build.isOss() ? 'oss distributable' : 'default distributable';
4342

4443
await runOptimizer(optimizerConfig)
4544
.pipe(
46-
reportOptimizerStats(reporter, reportStatsName),
45+
reportOptimizerStats(reporter, optimizerConfig),
4746
logOptimizerState(log, optimizerConfig)
4847
)
4948
.toPromise();

src/dev/build/tasks/create_archives_task.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,38 @@
1717
* under the License.
1818
*/
1919

20-
import path from 'path';
20+
import Path from 'path';
21+
import Fs from 'fs';
22+
import { promisify } from 'util';
23+
24+
import { CiStatsReporter } from '@kbn/dev-utils';
25+
2126
import { mkdirp, compress } from '../lib';
2227

28+
const asyncStat = promisify(Fs.stat);
29+
2330
export const CreateArchivesTask = {
2431
description: 'Creating the archives for each platform',
2532

2633
async run(config, log, build) {
34+
const archives = [];
35+
2736
// archive one at a time, parallel causes OOM sometimes
2837
for (const platform of config.getTargetPlatforms()) {
2938
const source = build.resolvePathForPlatform(platform, '.');
3039
const destination = build.getPlatformArchivePath(platform);
3140

3241
log.info('archiving', source, 'to', destination);
3342

34-
await mkdirp(path.dirname(destination));
43+
await mkdirp(Path.dirname(destination));
3544

36-
switch (path.extname(destination)) {
45+
switch (Path.extname(destination)) {
3746
case '.zip':
47+
archives.push({
48+
format: 'zip',
49+
path: destination,
50+
});
51+
3852
await compress(
3953
'zip',
4054
{
@@ -51,6 +65,11 @@ export const CreateArchivesTask = {
5165
break;
5266

5367
case '.gz':
68+
archives.push({
69+
format: 'tar',
70+
path: destination,
71+
});
72+
5473
await compress(
5574
'tar',
5675
{
@@ -71,5 +90,20 @@ export const CreateArchivesTask = {
7190
throw new Error(`Unexpected extension for archive destination: ${destination}`);
7291
}
7392
}
93+
94+
const reporter = CiStatsReporter.fromEnv(log);
95+
if (reporter.isEnabled()) {
96+
await reporter.metrics(
97+
await Promise.all(
98+
archives.map(async ({ format, path }) => {
99+
return {
100+
group: `${build.isOss() ? 'oss ' : ''}distributable size`,
101+
id: format,
102+
value: (await asyncStat(path)).size,
103+
};
104+
})
105+
)
106+
);
107+
}
74108
},
75109
};

x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/__snapshots__/calendar_form.test.js.snap

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export const CalendarForm = ({
146146
}
147147
checked={isGlobalCalendar}
148148
onChange={onGlobalCalendarChange}
149+
disabled={saving === true || canCreateCalendar === false}
149150
/>
150151

151152
{isGlobalCalendar === false && (

x-pack/plugins/ml/server/models/data_recognizer/modules/auditbeat_process_docker_ecs/ml/docker_high_count_process_events_ecs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{
3131
"url_name": "Process rate",
3232
"time_range": "1h",
33-
"url_value": "kibana#/dashboard/ml_auditbeat_docker_process_event_rate_ecs?_g=(time:(from:\u0027$earliest$\u0027,mode:absolute,to:\u0027$latest$\u0027))&_a=(filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:INDEX_PATTERN_ID,key:event.module,negate:!f,params:(query:auditd),type:phrase,value:auditd),query:(match:(event.module:(query:auditd,type:phrase)))),('$state':(store:appState),meta:(alias:!n,disabled:!f,index:INDEX_PATTERN_ID,key:container.runtime,negate:!f,params:(query:docker),type:phrase,value:docker),query:(match:(container.runtime:(query:docker,type:phrase)))),('$state':(store:appState),exists:(field:auditd.data.syscall),meta:(alias:!n,disabled:!f,index:INDEX_PATTERN_ID,key:auditd.data.syscall,negate:!f,type:exists,value:exists))),query:(language:kuery,query:\u0027container.name:\u0022$container.name$\u0022\u0027))"
33+
"url_value": "kibana#/dashboard/ml_auditbeat_docker_process_event_rate_ecs?_g=(time:(from:\u0027$earliest$\u0027,mode:absolute,to:\u0027$latest$\u0027))&_a=(filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:\u0027INDEX_PATTERN_ID\u0027,key:event.module,negate:!f,params:(query:auditd),type:phrase,value:auditd),query:(match:(event.module:(query:auditd,type:phrase)))),('$state':(store:appState),meta:(alias:!n,disabled:!f,index:\u0027INDEX_PATTERN_ID\u0027,key:container.runtime,negate:!f,params:(query:docker),type:phrase,value:docker),query:(match:(container.runtime:(query:docker,type:phrase)))),('$state':(store:appState),exists:(field:auditd.data.syscall),meta:(alias:!n,disabled:!f,index:\u0027INDEX_PATTERN_ID\u0027,key:auditd.data.syscall,negate:!f,type:exists,value:exists))),query:(language:kuery,query:\u0027container.name:\u0022$container.name$\u0022\u0027))"
3434
},
3535
{
3636
"url_name": "Raw data",

0 commit comments

Comments
 (0)