Skip to content

Commit

Permalink
Merge branch 'master' into kibana-page-template-as-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Constance committed Jun 21, 2021
2 parents eea67d6 + 1f2de03 commit 70f776c
Show file tree
Hide file tree
Showing 59 changed files with 1,160 additions and 457 deletions.
5 changes: 0 additions & 5 deletions docs/user/alerting/alerting-getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,4 @@ Functionally, {kib} alerting differs in that:
At a higher level, {kib} alerting allows rich integrations across use cases like <<xpack-apm,*APM*>>, <<metrics-app,*Metrics*>>, <<xpack-siem,*Security*>>, and <<uptime-app,*Uptime*>>.
Pre-packaged *rule types* simplify setup and hide the details of complex, domain-specific detections, while providing a consistent interface across {kib}.

[float]
[[alerting-setup-prerequisites]]
== Prerequisites
<<alerting-prerequisites, Alerting prerequisites>>

--
4 changes: 2 additions & 2 deletions docs/user/alerting/alerting-setup.asciidoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[role="xpack"]
[[alerting-setup]]
== Alerting Setup
== Alerting Set up
++++
<titleabbrev>Setup</titleabbrev>
<titleabbrev>Set up</titleabbrev>
++++

The Alerting feature is automatically enabled in {kib}, but might require some additional configuration.
Expand Down
11 changes: 0 additions & 11 deletions docs/user/alerting/defining-rules.asciidoc

This file was deleted.

2 changes: 0 additions & 2 deletions docs/user/alerting/index.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
include::alerting-getting-started.asciidoc[]
include::alerting-setup.asciidoc[]
include::create-and-manage-rules.asciidoc[]
include::defining-rules.asciidoc[]
include::rule-management.asciidoc[]
include::rule-types.asciidoc[]
include::alerting-troubleshooting.asciidoc[]
5 changes: 0 additions & 5 deletions docs/user/alerting/rule-management.asciidoc

This file was deleted.

2 changes: 1 addition & 1 deletion docs/user/alerting/rule-types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ see {subscriptions}[the subscription page].
[[stack-rules]]
=== Stack rules

<<alert-management, Stack rules>> are built into {kib}. To access the *Stack Rules* feature and create and edit rules, users require the `all` privilege. See <<kibana-feature-privileges, feature privileges>> for more information.
<<create-and-manage-rules, Stack rules>> are built into {kib}. To access the *Stack Rules* feature and create and edit rules, users require the `all` privilege. See <<kibana-feature-privileges, feature privileges>> for more information.

[cols="2*<"]
|===
Expand Down
68 changes: 34 additions & 34 deletions docs/user/security/audit-logging.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ Refer to the corresponding {es} logs for potential write errors.
| `unknown` | User is creating a connector.
| `failure` | User is not authorized to create a connector.

.2+| `alert_create`
| `unknown` | User is creating an alert.
| `failure` | User is not authorized to create an alert.
.2+| `rule_create`
| `unknown` | User is creating a rule.
| `failure` | User is not authorized to create a rule.

.2+| `space_create`
| `unknown` | User is creating a space.
Expand Down Expand Up @@ -128,38 +128,38 @@ Refer to the corresponding {es} logs for potential write errors.
| `unknown` | User is updating a connector.
| `failure` | User is not authorized to update a connector.

.2+| `alert_update`
| `unknown` | User is updating an alert.
| `failure` | User is not authorized to update an alert.
.2+| `rule_update`
| `unknown` | User is updating a rule.
| `failure` | User is not authorized to update a rule.

.2+| `alert_update_api_key`
| `unknown` | User is updating the API key of an alert.
| `failure` | User is not authorized to update the API key of an alert.
.2+| `rule_update_api_key`
| `unknown` | User is updating the API key of a rule.
| `failure` | User is not authorized to update the API key of a rule.

.2+| `alert_enable`
| `unknown` | User is enabling an alert.
| `failure` | User is not authorized to enable an alert.
.2+| `rule_enable`
| `unknown` | User is enabling a rule.
| `failure` | User is not authorized to enable a rule.

.2+| `alert_disable`
| `unknown` | User is disabling an alert.
| `failure` | User is not authorized to disable an alert.
.2+| `rule_disable`
| `unknown` | User is disabling a rule.
| `failure` | User is not authorized to disable a rule.

.2+| `alert_mute`
.2+| `rule_mute`
| `unknown` | User is muting a rule.
| `failure` | User is not authorized to mute a rule.

.2+| `rule_unmute`
| `unknown` | User is unmuting a rule.
| `failure` | User is not authorized to unmute a rule.

.2+| `rule_alert_mute`
| `unknown` | User is muting an alert.
| `failure` | User is not authorized to mute an alert.

.2+| `alert_unmute`
.2+| `rule_alert_unmute`
| `unknown` | User is unmuting an alert.
| `failure` | User is not authorized to unmute an alert.

.2+| `alert_instance_mute`
| `unknown` | User is muting an alert instance.
| `failure` | User is not authorized to mute an alert instance.

.2+| `alert_instance_unmute`
| `unknown` | User is unmuting an alert instance.
| `failure` | User is not authorized to unmute an alert instance.

.2+| `space_update`
| `unknown` | User is updating a space.
| `failure` | User is not authorized to update a space.
Expand All @@ -183,9 +183,9 @@ Refer to the corresponding {es} logs for potential write errors.
| `unknown` | User is deleting a connector.
| `failure` | User is not authorized to delete a connector.

.2+| `alert_delete`
| `unknown` | User is deleting an alert.
| `failure` | User is not authorized to delete an alert.
.2+| `rule_delete`
| `unknown` | User is deleting a rule.
| `failure` | User is not authorized to delete a rule.

.2+| `space_delete`
| `unknown` | User is deleting a space.
Expand Down Expand Up @@ -218,13 +218,13 @@ Refer to the corresponding {es} logs for potential write errors.
| `success` | User has accessed a connector as part of a search operation.
| `failure` | User is not authorized to search for connectors.

.2+| `alert_get`
| `success` | User has accessed an alert.
| `failure` | User is not authorized to access an alert.
.2+| `rule_get`
| `success` | User has accessed a rule.
| `failure` | User is not authorized to access a rule.

.2+| `alert_find`
| `success` | User has accessed an alert as part of a search operation.
| `failure` | User is not authorized to search for alerts.
.2+| `rule_find`
| `success` | User has accessed a rule as part of a search operation.
| `failure` | User is not authorized to search for rules.

.2+| `space_get`
| `success` | User has accessed a space.
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48479,7 +48479,7 @@ async function runBazelCommandWithRunner(bazelCommandRunner, bazelArgs, offline
stdio: 'pipe'
});

if (offline || !offline) {
if (offline) {
bazelArgs = [...bazelArgs, '--config=offline'];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/src/utils/bazel/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function runBazelCommandWithRunner(
stdio: 'pipe',
};

if (offline || !offline) {
if (offline) {
bazelArgs = [...bazelArgs, '--config=offline'];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,40 @@ export const mathColumn: ExpressionFunctionDefinition<
return id === args.id;
});
if (existingColumnIndex > -1) {
throw new Error('ID must be unique');
throw new Error(
i18n.translate('expressions.functions.mathColumn.uniqueIdError', {
defaultMessage: 'ID must be unique',
})
);
}

const newRows = input.rows.map((row) => {
return {
...row,
[args.id]: math.fn(
{
type: 'datatable',
columns: input.columns,
rows: [row],
},
{
expression: args.expression,
onError: args.onError,
},
context
),
};
const result = math.fn(
{
type: 'datatable',
columns: input.columns,
rows: [row],
},
{
expression: args.expression,
onError: args.onError,
},
context
);

if (Array.isArray(result)) {
if (result.length === 1) {
return { ...row, [args.id]: result[0] };
}
throw new Error(
i18n.translate('expressions.functions.mathColumn.arrayValueError', {
defaultMessage: 'Cannot perform math on array values at {name}',
values: { name: args.name },
})
);
}

return { ...row, [args.id]: result };
});
const type = newRows.length ? getType(newRows[0][args.id]) : 'null';
const newColumn: DatatableColumn = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ describe('mathColumn', () => {
});
});

it('extracts a single array value, but not a multi-value array', () => {
const arrayTable = {
...testTable,
rows: [
{
name: 'product1',
time: 1517842800950, // 05 Feb 2018 15:00:00 GMT
price: [605, 500],
quantity: [100],
in_stock: true,
},
],
};
const args = {
id: 'output',
name: 'output',
expression: 'quantity',
};
expect(fn(arrayTable, args).rows[0].output).toEqual(100);
expect(() => fn(arrayTable, { ...args, expression: 'price' })).toThrowError(
`Cannot perform math on array values`
);
});

it('handles onError', () => {
const args = {
id: 'output',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('getType()', () => {
});

test('throws if object has no .type property', () => {
expect(() => getType([])).toThrow();
expect(() => getType({})).toThrow();
expect(() => getType({ _type: 'foo' })).toThrow();
expect(() => getType({ tipe: 'foo' })).toThrow();
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/expressions/common/expression_types/get_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

export function getType(node: any) {
if (node == null) return 'null';
if (Array.isArray(node)) {
throw new Error('Unexpected array value encountered.');
}
if (typeof node === 'object') {
if (!node.type) throw new Error('Objects must have a type property');
return node.type;
Expand Down
Loading

0 comments on commit 70f776c

Please sign in to comment.