Skip to content

Commit

Permalink
Merge branch 'master' into kertal-pr-2019-12-12-discover-table-header…
Browse files Browse the repository at this point in the history
…-wrap
  • Loading branch information
elasticmachine authored May 7, 2020
2 parents e53e082 + 39427f5 commit 90add7c
Show file tree
Hide file tree
Showing 177 changed files with 4,311 additions and 2,763 deletions.
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"kibana_utils": "src/plugins/kibana_utils",
"navigation": "src/plugins/navigation",
"newsfeed": "src/plugins/newsfeed",
"regionMap": "src/legacy/core_plugins/region_map",
"regionMap": "src/plugins/region_map",
"savedObjects": "src/plugins/saved_objects",
"savedObjectsManagement": "src/plugins/saved_objects_management",
"server": "src/legacy/server",
Expand Down
22 changes: 11 additions & 11 deletions docs/user/alerting/action-types/email.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ Password:: password for 'login' type authentication.

[source,text]
--
id: 'my-email'
name: preconfigured-email-action-type
actionTypeId: .email
config:
from: testsender@test.com <1.1>
host: validhostname <1.2>
port: 8080 <1.3>
secure: false <1.4>
secrets:
user: testuser <2.1>
password: passwordkeystorevalue <2.2>
my-email:
name: preconfigured-email-action-type
actionTypeId: .email
config:
from: testsender@test.com <1.1>
host: validhostname <1.2>
port: 8080 <1.3>
secure: false <1.4>
secrets:
user: testuser <2.1>
password: passwordkeystorevalue <2.2>
--

`config` defines the action type specific to the configuration and contains the following properties:
Expand Down
14 changes: 7 additions & 7 deletions docs/user/alerting/action-types/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ Execution time field:: This field will be automatically set to the time the ale

[source,text]
--
id: 'my-index'
name: action-type-index
actionTypeId: .index
config:
index: .kibana <1>
refresh: true <2>
executionTimeField: somedate <3>
my-index:
name: action-type-index
actionTypeId: .index
config:
index: .kibana <1>
refresh: true <2>
executionTimeField: somedate <3>
--

`config` defines the action type specific to the configuration and contains the following properties:
Expand Down
14 changes: 7 additions & 7 deletions docs/user/alerting/action-types/pagerduty.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ Integration Key:: A 32 character PagerDuty Integration Key for an integration

[source,text]
--
id: 'my-pagerduty'
name: preconfigured-pagerduty-action-type
actionTypeId: .pagerduty
config:
apiUrl: https://test.host <1.1>
secrets:
routingKey: testroutingkey <2.1>
my-pagerduty:
name: preconfigured-pagerduty-action-type
actionTypeId: .pagerduty
config:
apiUrl: https://test.host <1.1>
secrets:
routingKey: testroutingkey <2.1>
--

`config` defines the action type specific to the configuration and contains the following properties:
Expand Down
6 changes: 3 additions & 3 deletions docs/user/alerting/action-types/server-log.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Name:: The name of the connector. The name is used to identify a connector

[source,text]
--
id: 'my-server-log'
name: test
actionTypeId: .server-log
my-server-log:
name: test
actionTypeId: .server-log
--

[float]
Expand Down
10 changes: 5 additions & 5 deletions docs/user/alerting/action-types/slack.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Webhook URL:: The URL of the incoming webhook. See https://api.slack.com/messa

[source,text]
--
id: 'my-slack'
name: preconfigured-slack-action-type
actionTypeId: .slack
config:
webhookUrl: 'https://hooks.slack.com/services/abcd/efgh/ijklmnopqrstuvwxyz' <1>
my-slack:
name: preconfigured-slack-action-type
actionTypeId: .slack
config:
webhookUrl: 'https://hooks.slack.com/services/abcd/efgh/ijklmnopqrstuvwxyz' <1>
--

`config` defines the action type specific to the configuration and contains the following properties:
Expand Down
22 changes: 11 additions & 11 deletions docs/user/alerting/action-types/webhook.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ Password:: An optional password. If set, HTTP basic authentication is used. Cur

[source,text]
--
id: 'my-webhook'
name: preconfigured-webhook-action-type
actionTypeId: .webhook
config:
url: https://test.host <1.1>
method: POST <1.2>
headers: <1.3>
testheader: testvalue
secrets:
user: testuser <2.1>
password: passwordkeystorevalue <2.2>
my-webhook:
name: preconfigured-webhook-action-type
actionTypeId: .webhook
config:
url: https://test.host <1.1>
method: POST <1.2>
headers: <1.3>
testheader: testvalue
secrets:
user: testuser <2.1>
password: passwordkeystorevalue <2.2>
--

`config` defines the action type specific to the configuration and contains the following properties:
Expand Down
8 changes: 4 additions & 4 deletions docs/user/alerting/pre-configured-connectors.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ The following example shows a valid configuration of two out-of-the box connecto

```js
xpack.actions.preconfigured:
- id: 'my-slack1' <1>
my-slack1: <1>
actionTypeId: .slack <2>
name: 'Slack #xyz' <3>
config: <4>
webhookUrl: 'https://hooks.slack.com/services/abcd/efgh/ijklmnopqrstuvwxyz'
- id: 'webhook-service'
webhook-service:
actionTypeId: .webhook
name: 'Email service'
config:
Expand All @@ -44,7 +44,7 @@ The following example shows a valid configuration of two out-of-the box connecto
password: changeme
```

<1> `id` is the action connector identifier.
<1> the key is the action connector identifier, eg `my-slack1` in this example.
<2> `actionTypeId` is the action type identifier.
<3> `name` is the name of the preconfigured connector.
<4> `config` is the action type specific to the configuration.
Expand All @@ -69,7 +69,7 @@ The following example shows a valid configuration of preconfigured action type w
```js
xpack.actions.enabledActionTypes: ['.slack', '.email', '.index'] <1>
xpack.actions.preconfigured: <2>
- id: 'my-server-log'
my-server-log:
actionTypeId: .server-log
name: 'Server log #xyz'
```
Expand Down
10 changes: 8 additions & 2 deletions packages/kbn-dev-utils/src/ci_stats_reporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This class integrates with the `ciStats.trackBuild {}` Jenkins Pipeline function

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

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

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

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

const log = new ToolingLog(...);
const reporter = CiStatsReporter.fromEnv(log)
reporter.metric('Build speed', specificBuildName, timeToRunBuild)
reporter.metrics([
{
group: 'Build size',
id: specificBuildName,
value: sizeOfBuild
}
])
```
19 changes: 9 additions & 10 deletions packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,31 @@ export class CiStatsReporter {
return !!this.config;
}

async metric(name: string, subName: string, value: number) {
async metrics(metrics: Array<{ group: string; id: string; value: number }>) {
if (!this.config) {
return;
}

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

while (true) {
attempt += 1;

try {
await Axios.request({
method: 'POST',
url: '/metric',
url: '/v1/metrics',
baseURL: this.config.apiUrl,
params: {
buildId: this.config.buildId,
},
headers: {
Authorization: `token ${this.config.apiToken}`,
},
data: {
name,
subName,
value,
buildId: this.config.buildId,
metrics,
},
});

Expand All @@ -125,14 +124,14 @@ export class CiStatsReporter {
this.log.warning(
`error recording metric [status=${error.response.status}] [resp=${inspect(
error.response.data
)}] [${name}/${subName}=${value}]`
)}] ${bodySummary}`
);
return;
}

if (attempt === maxAttempts) {
this.log.warning(
`failed to reach kibana-ci-stats service too many times, unable to record metric [${name}/${subName}=${value}]`
`failed to reach kibana-ci-stats service too many times, unable to record metric ${bodySummary}`
);
return;
}
Expand Down
30 changes: 20 additions & 10 deletions packages/kbn-optimizer/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'source-map-support/register';

import Path from 'path';

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

import { logOptimizerState } from './log_optimizer_state';
import { OptimizerConfig } from './optimizer';
Expand Down Expand Up @@ -82,9 +82,9 @@ run(
throw createFlagError('expected --scan-dir to be a string');
}

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

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

let update$ = runOptimizer(config);

if (reportStatsName) {
if (reportStats) {
const reporter = CiStatsReporter.fromEnv(log);

if (!reporter.isEnabled()) {
throw createFailError('Unable to initialize CiStatsReporter from env');
log.warning('Unable to initialize CiStatsReporter from env');
}

update$ = update$.pipe(reportOptimizerStats(reporter, reportStatsName));
update$ = update$.pipe(reportOptimizerStats(reporter, config));
}

await update$.pipe(logOptimizerState(log, config)).toPromise();
},
{
flags: {
boolean: ['core', 'watch', 'oss', 'examples', 'dist', 'cache', 'profile', 'inspect-workers'],
string: ['workers', 'scan-dir', 'report-stats'],
boolean: [
'core',
'watch',
'oss',
'examples',
'dist',
'cache',
'profile',
'inspect-workers',
'report-stats',
],
string: ['workers', 'scan-dir'],
default: {
core: true,
examples: true,
Expand All @@ -136,7 +146,7 @@ run(
--dist create bundles that are suitable for inclusion in the Kibana distributable
--scan-dir add a directory to the list of directories scanned for plugins (specify as many times as necessary)
--no-inspect-workers when inspecting the parent process, don't inspect the workers
--report-stats=[name] attempt to report stats about this execution of the build to the kibana-ci-stats service using this name
--report-stats attempt to report stats about this execution of the build to the kibana-ci-stats service using this name
`,
},
}
Expand Down
17 changes: 14 additions & 3 deletions packages/kbn-optimizer/src/report_optimizer_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import { materialize, mergeMap, dematerialize } from 'rxjs/operators';
import { CiStatsReporter } from '@kbn/dev-utils';

import { OptimizerUpdate$ } from './run_optimizer';
import { OptimizerState } from './optimizer';
import { OptimizerState, OptimizerConfig } from './optimizer';
import { pipeClosure } from './common';

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

if (n.kind === 'C' && lastState) {
await reporter.metric('@kbn/optimizer build time', name, lastState.durSec);
await reporter.metrics(
config.bundles.map(bundle => {
// make the cache read from the cache file since it was likely updated by the worker
bundle.cache.refresh();

return {
group: `@kbn/optimizer bundle module count`,
id: bundle.id,
value: bundle.cache.getModuleCount() || 0,
};
})
);
}

return n;
Expand Down
Loading

0 comments on commit 90add7c

Please sign in to comment.