Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EPM] Install Lens assets from packages if present. #88189

Merged
merged 2 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('Fleet - packageToPackagePolicy', () => {
search: [],
index_pattern: [],
map: [],
lens: [],
},
elasticsearch: {
ingest_pipeline: [],
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/common/types/models/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export enum KibanaAssetType {
search = 'search',
indexPattern = 'index_pattern',
map = 'map',
lens = 'lens',
}

/*
Expand All @@ -57,6 +58,7 @@ export enum KibanaSavedObjectType {
search = 'search',
indexPattern = 'index-pattern',
map = 'map',
lens = 'lens',
}

export enum ElasticsearchAssetType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const AssetTitleMap: Record<AssetType, string> = {
input: 'Agent input',
map: 'Map',
data_stream_ilm_policy: 'Data Stream ILM Policy',
lens: 'Lens',
};

export const ServiceTitleMap: Record<ServiceName, string> = {
Expand All @@ -41,6 +42,7 @@ export const AssetIcons: Record<KibanaAssetType, IconType> = {
search: 'searchProfilerApp',
visualization: 'visualizeApp',
map: 'emsApp',
lens: 'lensApp',
};

export const ServiceIcons: Record<ServiceName, IconType> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const KibanaSavedObjectTypeMapping: Record<KibanaAssetType, KibanaSavedObjectTyp
[KibanaAssetType.map]: KibanaSavedObjectType.map,
[KibanaAssetType.search]: KibanaSavedObjectType.search,
[KibanaAssetType.visualization]: KibanaSavedObjectType.visualization,
[KibanaAssetType.lens]: KibanaSavedObjectType.lens,
};

// Define how each asset type will be installed
Expand All @@ -54,6 +55,7 @@ const AssetInstallers: Record<
[KibanaAssetType.map]: installKibanaSavedObjects,
[KibanaAssetType.search]: installKibanaSavedObjects,
[KibanaAssetType.visualization]: installKibanaSavedObjects,
[KibanaAssetType.lens]: installKibanaSavedObjects,
};

export async function getKibanaAsset(key: string): Promise<ArchiveAsset> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ const expectAssetsInstalled = ({
id: 'sample_search',
});
expect(resSearch.id).equal('sample_search');
const resLens = await kibanaServer.savedObjects.get({
type: 'lens',
id: 'sample_lens',
});
expect(resLens.id).equal('sample_lens');
const resIndexPattern = await kibanaServer.savedObjects.get({
type: 'index-pattern',
id: 'test-*',
Expand Down Expand Up @@ -449,6 +454,10 @@ const expectAssetsInstalled = ({
id: 'test-*',
type: 'index-pattern',
},
{
id: 'sample_lens',
type: 'lens',
},
{
id: 'sample_search',
type: 'search',
Expand Down Expand Up @@ -515,6 +524,7 @@ const expectAssetsInstalled = ({
{ id: '60d6d054-57e4-590f-a580-52bf3f5e7cca', type: 'epm-packages-assets' },
{ id: '47758dc2-979d-5fbe-a2bd-9eded68a5a43', type: 'epm-packages-assets' },
{ id: '318959c9-997b-5a14-b328-9fc7355b4b74', type: 'epm-packages-assets' },
{ id: 'e21b59b5-eb76-5ab0-bef2-1c8e379e6197', type: 'epm-packages-assets' },
{ id: 'e786cbd9-0f3b-5a0b-82a6-db25145ebf58', type: 'epm-packages-assets' },
{ id: '53c94591-aa33-591d-8200-cd524c2a0561', type: 'epm-packages-assets' },
{ id: 'b658d2d4-752e-54b8-afc2-4c76155c1466', type: 'epm-packages-assets' },
Expand Down
5 changes: 5 additions & 0 deletions x-pack/test/fleet_api_integration/apis/epm/update_assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ export default function (providerContext: FtrProviderContext) {
id: 'sample_search2',
type: 'search',
},
{
id: 'sample_lens',
type: 'lens',
},
],
installed_es: [
{
Expand Down Expand Up @@ -338,6 +342,7 @@ export default function (providerContext: FtrProviderContext) {
{ id: '5c3aa147-089c-5084-beca-53c00e72ac80', type: 'epm-packages-assets' },
{ id: '48e582df-b1d2-5f88-b6ea-ba1fafd3a569', type: 'epm-packages-assets' },
{ id: 'bf3b0b65-9fdc-53c6-a9ca-e76140e56490', type: 'epm-packages-assets' },
{ id: '7f4c5aca-b4f5-5f0a-95af-051da37513fc', type: 'epm-packages-assets' },
{ id: '2e56f08b-1d06-55ed-abee-4708e1ccf0aa', type: 'epm-packages-assets' },
{ id: 'c7bf1a39-e057-58a0-afde-fb4b48751d8c', type: 'epm-packages-assets' },
{ id: '8c665f28-a439-5f43-b5fd-8fda7b576735', type: 'epm-packages-assets' },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"type": "lens",
"id": "sample_lens",
"attributes": {
"title": "sample-lens",
"description": "",
"visualizationType": "lnsXY",
"state": {
"datasourceStates": {
"indexpattern": {
"layers": {
"91b37ed1-ec9f-401d-8ba5-990c2fc65cd0": {
"columns": {
"2c9a6ea8-f3c1-4178-b6af-9e1a5811888a": {
"label": "Top values of HostDetails.agent.name",
"dataType": "string",
"operationType": "terms",
"scale": "ordinal",
"sourceField": "HostDetails.agent.name",
"isBucketed": true,
"params": {
"size": 5,
"orderBy": {
"type": "column",
"columnId": "64b26756-2616-4835-bf77-e0e3807cf827"
},
"orderDirection": "desc",
"otherBucket": true,
"missingBucket": false
}
},
"64b26756-2616-4835-bf77-e0e3807cf827": {
"label": "Count of records",
"dataType": "number",
"operationType": "count",
"isBucketed": false,
"scale": "ratio",
"sourceField": "Records"
}
},
"columnOrder": [
"2c9a6ea8-f3c1-4178-b6af-9e1a5811888a",
"64b26756-2616-4835-bf77-e0e3807cf827"
],
"incompleteColumns": {}
}
}
}
},
"visualization": {
"legend": {
"isVisible": true,
"position": "right"
},
"valueLabels": "hide",
"fittingFunction": "None",
"axisTitlesVisibilitySettings": {
"x": true,
"yLeft": true,
"yRight": true
},
"tickLabelsVisibilitySettings": {
"x": true,
"yLeft": true,
"yRight": true
},
"gridlinesVisibilitySettings": {
"x": true,
"yLeft": true,
"yRight": true
},
"preferredSeriesType": "bar_stacked",
"layers": [
{
"layerId": "91b37ed1-ec9f-401d-8ba5-990c2fc65cd0",
"accessors": [
"64b26756-2616-4835-bf77-e0e3807cf827"
],
"position": "top",
"seriesType": "bar_stacked",
"showGridlines": false,
"xAccessor": "2c9a6ea8-f3c1-4178-b6af-9e1a5811888a"
}
]
},
"query": {
"query": "",
"language": "kuery"
},
"filters": []
}
},
"references": [
{
"type": "index-pattern",
"id": "metrics-*",
"name": "indexpattern-datasource-current-indexpattern"
},
{
"type": "index-pattern",
"id": "metrics-*",
"name": "indexpattern-datasource-layer-91b37ed1-ec9f-401d-8ba5-990c2fc65cd0"
}
],
"migrationVersion": {
"lens": "7.11.0"
},
"updated_at": "2021-01-13T15:16:10.075Z",
"version": "WzI5NCwxXQ==",
"namespaces": [
"default"
],
"score": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"type": "lens",
"id": "sample_lens",
"attributes": {
"title": "sample-lens",
"description": "",
"visualizationType": "lnsXY",
"state": {
"datasourceStates": {
"indexpattern": {
"layers": {
"91b37ed1-ec9f-401d-8ba5-990c2fc65cd0": {
"columns": {
"2c9a6ea8-f3c1-4178-b6af-9e1a5811888a": {
"label": "Top values of HostDetails.agent.name",
"dataType": "string",
"operationType": "terms",
"scale": "ordinal",
"sourceField": "HostDetails.agent.name",
"isBucketed": true,
"params": {
"size": 5,
"orderBy": {
"type": "column",
"columnId": "64b26756-2616-4835-bf77-e0e3807cf827"
},
"orderDirection": "desc",
"otherBucket": true,
"missingBucket": false
}
},
"64b26756-2616-4835-bf77-e0e3807cf827": {
"label": "Count of records",
"dataType": "number",
"operationType": "count",
"isBucketed": false,
"scale": "ratio",
"sourceField": "Records"
}
},
"columnOrder": [
"2c9a6ea8-f3c1-4178-b6af-9e1a5811888a",
"64b26756-2616-4835-bf77-e0e3807cf827"
],
"incompleteColumns": {}
}
}
}
},
"visualization": {
"legend": {
"isVisible": true,
"position": "right"
},
"valueLabels": "hide",
"fittingFunction": "None",
"axisTitlesVisibilitySettings": {
"x": true,
"yLeft": true,
"yRight": true
},
"tickLabelsVisibilitySettings": {
"x": true,
"yLeft": true,
"yRight": true
},
"gridlinesVisibilitySettings": {
"x": true,
"yLeft": true,
"yRight": true
},
"preferredSeriesType": "bar_stacked",
"layers": [
{
"layerId": "91b37ed1-ec9f-401d-8ba5-990c2fc65cd0",
"accessors": [
"64b26756-2616-4835-bf77-e0e3807cf827"
],
"position": "top",
"seriesType": "bar_stacked",
"showGridlines": false,
"xAccessor": "2c9a6ea8-f3c1-4178-b6af-9e1a5811888a"
}
]
},
"query": {
"query": "",
"language": "kuery"
},
"filters": []
}
},
"references": [
{
"type": "index-pattern",
"id": "metrics-*",
"name": "indexpattern-datasource-current-indexpattern"
},
{
"type": "index-pattern",
"id": "metrics-*",
"name": "indexpattern-datasource-layer-91b37ed1-ec9f-401d-8ba5-990c2fc65cd0"
}
],
"migrationVersion": {
"lens": "7.11.0"
},
"updated_at": "2021-01-13T15:16:10.075Z",
"version": "WzI5NCwxXQ==",
"namespaces": [
"default"
],
"score": 0
}