Skip to content

Commit

Permalink
Merge branch 'main' into filter-activities-pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
js-jankisalvi authored Apr 3, 2023
2 parents 656cff0 + 9bfd8b6 commit 877c6a6
Show file tree
Hide file tree
Showing 137 changed files with 3,479 additions and 1,162 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ x-pack/test/alerting_api_integration/common/plugins/alerts @elastic/response-ops
x-pack/examples/alerting_example @elastic/response-ops
x-pack/test/functional_with_es_ssl/plugins/alerts @elastic/response-ops
x-pack/plugins/alerting @elastic/response-ops
x-pack/packages/kbn-alerting-state-types @elastic/response-ops
packages/kbn-alerts @elastic/security-solution
packages/kbn-alerts-as-data-utils @elastic/response-ops
x-pack/test/alerting_api_integration/common/plugins/alerts_restricted @elastic/response-ops
Expand Down Expand Up @@ -461,6 +462,7 @@ x-pack/plugins/ml @elastic/ml-ui
x-pack/packages/ml/query_utils @elastic/ml-ui
x-pack/packages/ml/route_utils @elastic/ml-ui
x-pack/packages/ml/string_hash @elastic/ml-ui
x-pack/packages/ml/trained_models_utils @elastic/ml-ui
x-pack/packages/ml/url_state @elastic/ml-ui
packages/kbn-monaco @elastic/appex-sharedux
x-pack/plugins/monitoring_collection @elastic/infra-monitoring-ui
Expand Down
6 changes: 5 additions & 1 deletion docs/settings/fleet-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ If configured in your `kibana.yml`, output settings are grayed out and
unavailable in the {fleet} UI. To make these settings editable in the UI, do not
configure them in the configuration file.
+
NOTE: The `xpack.fleet.outputs` settings are intended for advanced configurations such as having multiple outputs. We recommend not enabling the `xpack.fleet.agents.elasticsearch.host` settings when using `xpack.fleet.outputs`.
+
.Required properties of `xpack.fleet.outputs`
[%collapsible%open]
=====
Expand All @@ -161,7 +163,9 @@ configure them in the configuration file.
[%collapsible%open]
=====
`is_default`:::
If `true`, this output is the default output.
If `true`, the output specified in `xpack.fleet.outputs` will be the one used to send agent data unless there is another one configured specifically for the agent policy.
`is_default_monitoring`:::
If `true`, the output specified in `xpack.fleet.outputs` will be the one used to send agent monitoring data unless there is another one configured specifically for the agent policy.
=====
+
Example configuration:
Expand Down
1 change: 1 addition & 0 deletions docs/user/alerting/action-variables.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ If the rule's action frequency is not a summary of alerts, it passes the followi
`alert.actionSubgroup`:: The action subgroup of the alert that scheduled the action.
`alert.flapping`:: A flag on the alert that indicates whether the alert status is changing repeatedly.
`alert.id`:: The ID of the alert that scheduled the action.
`alert.uuid`:: A universally unique identifier for the alert. While the alert is active, the UUID value remains unchanged each time the rule runs. preview:[]

[float]
[[defining-rules-actions-variable-context]]
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"@kbn/alerting-example-plugin": "link:x-pack/examples/alerting_example",
"@kbn/alerting-fixture-plugin": "link:x-pack/test/functional_with_es_ssl/plugins/alerts",
"@kbn/alerting-plugin": "link:x-pack/plugins/alerting",
"@kbn/alerting-state-types": "link:x-pack/packages/kbn-alerting-state-types",
"@kbn/alerts": "link:packages/kbn-alerts",
"@kbn/alerts-as-data-utils": "link:packages/kbn-alerts-as-data-utils",
"@kbn/alerts-restricted-fixtures-plugin": "link:x-pack/test/alerting_api_integration/common/plugins/alerts_restricted",
Expand Down Expand Up @@ -476,6 +477,7 @@
"@kbn/ml-query-utils": "link:x-pack/packages/ml/query_utils",
"@kbn/ml-route-utils": "link:x-pack/packages/ml/route_utils",
"@kbn/ml-string-hash": "link:x-pack/packages/ml/string_hash",
"@kbn/ml-trained-models-utils": "link:x-pack/packages/ml/trained_models_utils",
"@kbn/ml-url-state": "link:x-pack/packages/ml/url_state",
"@kbn/monaco": "link:packages/kbn-monaco",
"@kbn/monitoring-collection-plugin": "link:x-pack/plugins/monitoring_collection",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"synthetics-param": "9776c9b571d35f0d0397e8915e035ea1dc026db7",
"synthetics-privates-locations": "7d032fc788905e32152029ae7ab3d6038c48ae44",
"tag": "87f21f07df9cc37001b15a26e413c18f50d1fbfe",
"task": "ebcc113df12f14bf627dbd335ba78507187b48a3",
"task": "ff760534a44c4cfabcf4baf8cfe8283f717cab02",
"telemetry": "561b329aaed3c15b91aaf2075645be3097247612",
"ui-metric": "410a8ad28e0f44b161c960ff0ce950c712b17c52",
"upgrade-assistant-ml-upgrade-operation": "d8816e5ce32649e7a3a43e2c406c632319ff84bb",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1103,15 +1103,27 @@ describe('MetricVisComponent', function () {
});

it('should do nothing if primary metric is not filterable', () => {
const event: MetricElementEvent = {
type: 'metricElementEvent',
rowIndex: 1,
columnIndex: 0,
const props = {
...defaultProps,
filterable: false,
};
const metricComponent = shallow(
<MetricVis
config={{
metric: {
progressDirection: 'vertical',
maxCols: 5,
},
dimensions: {
metric: basePriceColumnId,
},
}}
data={table}
{...props}
/>
);

fireFilter(event, false, true);

expect(fireEventSpy).not.toHaveBeenCalled();
expect(metricComponent.find(Settings).props().onElementClick).toBeUndefined();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,22 +362,27 @@ export const MetricVis = ({
]}
baseTheme={baseTheme}
onRenderChange={onRenderChange}
onElementClick={(events) => {
if (!filterable) {
return;
}
events.forEach((event) => {
if (isMetricElementEvent(event)) {
const colIdx = breakdownByColumn
? data.columns.findIndex((col) => col === breakdownByColumn)
: data.columns.findIndex((col) => col === primaryMetricColumn);
const rowLength = grid[0].length;
fireEvent(
buildFilterEvent(event.rowIndex * rowLength + event.columnIndex, colIdx, data)
);
}
});
}}
onElementClick={
filterable
? (events) => {
events.forEach((event) => {
if (isMetricElementEvent(event)) {
const colIdx = breakdownByColumn
? data.columns.findIndex((col) => col === breakdownByColumn)
: data.columns.findIndex((col) => col === primaryMetricColumn);
const rowLength = grid[0].length;
fireEvent(
buildFilterEvent(
event.rowIndex * rowLength + event.columnIndex,
colIdx,
data
)
);
}
});
}
: undefined
}
/>
<Metric id="metric" data={grid} />
</Chart>
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"@kbn/alerting-fixture-plugin/*": ["x-pack/test/functional_with_es_ssl/plugins/alerts/*"],
"@kbn/alerting-plugin": ["x-pack/plugins/alerting"],
"@kbn/alerting-plugin/*": ["x-pack/plugins/alerting/*"],
"@kbn/alerting-state-types": ["x-pack/packages/kbn-alerting-state-types"],
"@kbn/alerting-state-types/*": ["x-pack/packages/kbn-alerting-state-types/*"],
"@kbn/alerts": ["packages/kbn-alerts"],
"@kbn/alerts/*": ["packages/kbn-alerts/*"],
"@kbn/alerts-as-data-utils": ["packages/kbn-alerts-as-data-utils"],
Expand Down Expand Up @@ -916,6 +918,8 @@
"@kbn/ml-route-utils/*": ["x-pack/packages/ml/route_utils/*"],
"@kbn/ml-string-hash": ["x-pack/packages/ml/string_hash"],
"@kbn/ml-string-hash/*": ["x-pack/packages/ml/string_hash/*"],
"@kbn/ml-trained-models-utils": ["x-pack/packages/ml/trained_models_utils"],
"@kbn/ml-trained-models-utils/*": ["x-pack/packages/ml/trained_models_utils/*"],
"@kbn/ml-url-state": ["x-pack/packages/ml/url_state"],
"@kbn/ml-url-state/*": ["x-pack/packages/ml/url_state/*"],
"@kbn/monaco": ["packages/kbn-monaco"],
Expand Down
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"xpack.main": "legacy/plugins/xpack_main",
"xpack.maps": ["plugins/maps"],
"xpack.aiops": ["packages/ml/aiops_components", "plugins/aiops"],
"xpack.ml": ["packages/ml/date_picker", "plugins/ml"],
"xpack.ml": ["packages/ml/date_picker", "packages/ml/trained_models_utils", "plugins/ml"],
"xpack.monitoring": ["plugins/monitoring"],
"xpack.osquery": ["plugins/osquery"],
"xpack.painlessLab": "plugins/painless_lab",
Expand Down
42 changes: 42 additions & 0 deletions x-pack/build_chromium/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,48 @@ Here's the steps on how to test a Puppeteer upgrade, run these tests on Mac, Win
- All functional and API tests that generate PDF and PNG files should pass.
- Use a VM to run Kibana in a low-memory environment and try to generate a PNG of a dashboard that outputs as a 4MB file. Document the minimum requirements in the PR.

## Testing Chromium upgrades on a Windows Machine

Directions on creating a build of Kibana off an existing PR can be found here:
https://www.elastic.co/guide/en/kibana/current/building-kibana.html
You will need this build to install on your windows device to test the in progress PR.

The default extractor for Windows might give `Path too long errors`.
- Install the zipped file onto your C:\ directory in case the path actually is too long.
- Use 7Zip or WinZip to extract the contents of the kibana build.
Reference: This article can be helpful:
https://www.partitionwizard.com/disk-recovery/error-0x80010135-path-too-long.html

For an elasticsearch cluster to base the latest kibana build with, you can use a snapshot.sh bash script to generate the latest build. Create a file called snapshot.sh and put the following into the file:

```
runQuery() {
curl --silent -XGET https://artifacts-api.elastic.co${1}
}
BUILD_HASH=$(runQuery /v1/versions/${VERSION}-SNAPSHOT/builds | jq -r '.builds[0]')
echo "Latest build hash :: $BUILD_HASH"
KBN_DOWNLOAD=$(runQuery /v1/versions/${VERSION}-SNAPSHOT/builds/$BUILD_HASH/projects/elasticsearch/packages/elasticsearch-${VERSION}-SNAPSHOT-windows-x86_64.zip)
echo $KBN_DOWNLOAD | jq -r '.package.url'
```

In the terminal once you have the snapshot.sh file written run:
chmod a+x snapshot.sh to make the file executable
Then set the version variable within the script to what you need by typing the following (in this example 8.8.0):
VERSION=8.8.0 ./snapshot.sh

In the terminal you should see a web address that will give you a download of elasticsearch.

You may need to disable xpack security in the elasticsearch.yml
xpack.security.enabled: false

Make sure nothing is set in the kibana.yml

Run `.\bin\elasticsearch.bat` in the elasticsearch directory first and then once it's up run `.\bin\kibana.bat`

Navigate to localhost:5601 and there shouldn't be any prompts to set up security etc. To test PNG reporting, you may need to upload a license. Navigate to https://wiki.elastic.co/display/PM/Internal+License+-+X-Pack+and+Endgame and download the license.json from Internal Licenses.

Navigate to Stack Management in Kibana and you can upload the license.json from internal licenses. You won't need to restart the cluster and should be able to test the Kibana feature as needed at this point.

## Resources

The following links provide helpful context about how the Chromium build works, and its prerequisites:
Expand Down
8 changes: 8 additions & 0 deletions x-pack/packages/kbn-alerting-state-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @kbn/alerting-state-types

Contains type information for the alerting data persisted in task
manager documents as state.

Because task manager migrations sometimes need this data, it needs
to be in a package outside of alerting.

24 changes: 24 additions & 0 deletions x-pack/packages/kbn-alerting-state-types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export type {
ThrottledActions,
LastScheduledActions,
AlertInstanceMeta,
AlertInstanceState,
AlertInstanceContext,
RawAlertInstance,
} from './src/alert_instance';
export { rawAlertInstance } from './src/alert_instance';

export { DateFromString } from './src/date_from_string';

export type { TrackedLifecycleAlertState, WrappedLifecycleRuleState } from './src/lifecycle_state';
export { wrappedStateRt } from './src/lifecycle_state';

export type { RuleTaskState, RuleTaskParams } from './src/rule_task_instance';
export { ActionsCompletion, ruleStateSchema, ruleParamsSchema } from './src/rule_task_instance';
12 changes: 12 additions & 0 deletions x-pack/packages/kbn-alerting-state-types/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

module.exports = {
preset: '@kbn/test/jest_node',
rootDir: '../../..',
roots: ['<rootDir>/x-pack/packages/kbn-alerting-state-types'],
};
5 changes: 5 additions & 0 deletions x-pack/packages/kbn-alerting-state-types/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/alerting-state-types",
"owner": "@elastic/response-ops"
}
6 changes: 6 additions & 0 deletions x-pack/packages/kbn-alerting-state-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/alerting-state-types",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const metaSchema = t.partial({
// flapping flag that indicates whether the alert is flapping
flapping: t.boolean,
pendingRecoveredCount: t.number,
uuid: t.string,
});
export type AlertInstanceMeta = t.TypeOf<typeof metaSchema>;

Expand Down
48 changes: 48 additions & 0 deletions x-pack/packages/kbn-alerting-state-types/src/lifecycle_state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import * as t from 'io-ts';

const trackedAlertStateRt = t.type({
alertId: t.string,
alertUuid: t.string,
started: t.string,
// an array used to track changes in alert state, the order is based on the rule executions
// true - alert has changed from active/recovered
// false - alert is new or the status has remained either active or recovered
flappingHistory: t.array(t.boolean),
// flapping flag that indicates whether the alert is flapping
flapping: t.boolean,
pendingRecoveredCount: t.number,
});

export type TrackedLifecycleAlertState = t.TypeOf<typeof trackedAlertStateRt>;

type RuleTypeState = Record<string, unknown>;

export const alertTypeStateRt = <State extends RuleTypeState>() =>
t.record(t.string, t.unknown) as t.Type<State, State, unknown>;

export const wrappedStateRt = <State extends RuleTypeState>() =>
t.type({
wrapped: alertTypeStateRt<State>(),
// tracks the active alerts
trackedAlerts: t.record(t.string, trackedAlertStateRt),
// tracks the recovered alerts
trackedAlertsRecovered: t.record(t.string, trackedAlertStateRt),
});

/**
* This is redefined instead of derived from above `wrappedStateRt` because
* there's no easy way to instantiate generic values such as the runtime type
* factory function.
*/
export type WrappedLifecycleRuleState<State extends RuleTypeState> = RuleTypeState & {
wrapped: State;
trackedAlerts: Record<string, TrackedLifecycleAlertState>;
trackedAlertsRecovered: Record<string, TrackedLifecycleAlertState>;
};
17 changes: 17 additions & 0 deletions x-pack/packages/kbn-alerting-state-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node"
]
},
"include": [
"**/*.ts",
],
"exclude": [
"target/**/*"
],
"kbn_references": []
}
3 changes: 3 additions & 0 deletions x-pack/packages/ml/trained_models_utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/ml-trained-models-utils

Static utils for interacting with ML trained models
17 changes: 17 additions & 0 deletions x-pack/packages/ml/trained_models_utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export {
BUILT_IN_MODEL_TAG,
BUILT_IN_MODEL_TYPE,
DEPLOYMENT_STATE,
SUPPORTED_PYTORCH_TASKS,
TRAINED_MODEL_TYPE,
type DeploymentState,
type SupportedPytorchTasksType,
type TrainedModelType,
} from './src/constants/trained_models';
12 changes: 12 additions & 0 deletions x-pack/packages/ml/trained_models_utils/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/x-pack/packages/ml/trained_models_utils'],
};
5 changes: 5 additions & 0 deletions x-pack/packages/ml/trained_models_utils/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/ml-trained-models-utils",
"owner": "@elastic/ml-ui"
}
Loading

0 comments on commit 877c6a6

Please sign in to comment.