Skip to content

Commit ba5861e

Browse files
author
John Schulz
committed
Merge branch 'feature-ingest' of github.com:elastic/kibana into jen-huang-feature-ingest
2 parents a38b2d3 + 189d375 commit ba5861e

File tree

6 files changed

+19
-46
lines changed

6 files changed

+19
-46
lines changed

x-pack/legacy/plugins/epm/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export interface Dataset {
122122
ingeset_pipeline: string;
123123
vars: object[];
124124
type: string;
125+
// This is for convenience and not in the output from the registry. When creating a dataset, this info should be added.
125126
package: string;
126127
}
127128

x-pack/legacy/plugins/epm/server/config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ export const getConfigSchema = (Joi: typeof JoiNamespace) => {
3434

3535
const DEFAULT_CONFIG = {
3636
enabled: true,
37-
registryUrl: 'http://package-registry.app.elstc.co',
37+
// This is the staging url and should be later switched to https://epr.elastic.co for production
38+
// Both are behind a CDN with caching, so upgrading the registry will not immidiately invalidate
39+
// all the cached information.
40+
registryUrl: 'https://epr.ea-web.elastic.dev',
3841
};
3942

4043
// As of 2019, this is a Singleton because of the way JavaScript modules are specified.

x-pack/legacy/plugins/epm/server/lib/elasticsearch/ilm/install.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,11 @@ export async function policyExists(
2525
name: string,
2626
callCluster: CallESAsCurrentUser
2727
): Promise<boolean> {
28-
try {
29-
// TODO: Figure out if there is a better way to check for an ILM policy to exist that
30-
// does not throw an exception.
31-
await callCluster('transport.request', {
32-
method: 'GET',
33-
path: '/_ilm/policy/' + name,
34-
});
35-
return true;
36-
} catch (e) {
37-
return false;
38-
}
28+
const response = await callCluster('transport.request', {
29+
method: 'GET',
30+
path: '/_ilm/policy/?filter_path=' + name,
31+
});
3932

40-
return false;
33+
// If the response contains a key, it means the policy exists
34+
return Object.keys(response).length > 0;
4135
}

x-pack/legacy/plugins/epm/server/lib/elasticsearch/template/__snapshots__/template.test.ts.snap

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

x-pack/legacy/plugins/epm/server/lib/elasticsearch/template/install.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ const isFields = (path: string) => {
2323
* The template is currently loaded with the pkgey-package-dataset
2424
*/
2525
export async function installTemplates(pkg: RegistryPackage, callCluster: CallESAsCurrentUser) {
26+
// If no datasets exist in this package, no templates have to be installed.
2627
if (!pkg.datasets) return;
2728

28-
const promises = pkg.datasets.map(async dataset => {
29+
return pkg.datasets.map(async dataset => {
2930
// Fetch all assset entries for this dataset
3031
const assetEntries = await getAssetsData(pkg, isFields, dataset.name);
3132

@@ -38,25 +39,21 @@ export async function installTemplates(pkg: RegistryPackage, callCluster: CallES
3839
}
3940
}
4041

41-
return installTemplate({ callCluster, fields, pkg, dataset });
42+
return installTemplate({ callCluster, fields, dataset });
4243
});
43-
44-
return Promise.all(promises);
4544
}
4645

4746
async function installTemplate({
4847
callCluster,
4948
fields,
50-
pkg,
5149
dataset,
5250
}: {
5351
callCluster: CallESAsCurrentUser;
5452
fields: Field[];
55-
pkg: RegistryPackage;
5653
dataset: Dataset;
5754
}): Promise<AssetReference> {
5855
const mappings = generateMappings(fields);
59-
const templateName = generateTemplateName(pkg.name, dataset.name, dataset.type);
56+
const templateName = generateTemplateName(dataset);
6057
const template = getTemplate(templateName + '-*', mappings);
6158
// TODO: Check return values for errors
6259
await callCluster('indices.putTemplate', {

x-pack/legacy/plugins/epm/server/lib/elasticsearch/template/template.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66

77
import { Field } from '../../fields/field';
8+
import { Dataset } from '../../../../common/types';
9+
import { getDatasetAssetBaseName } from '../index';
810

911
export interface Template {
1012
order: number;
@@ -58,13 +60,8 @@ export function generateMappings(fields: Field[]): Mappings {
5860
/**
5961
* Generates the template name out of the given information
6062
*/
61-
export function generateTemplateName(
62-
packageName: string,
63-
datasetName: string,
64-
type: string
65-
): string {
66-
// TODO: This is only a temporary name. More info like dataset type is needed to create full name
67-
return type + '-' + packageName + '-' + datasetName;
63+
export function generateTemplateName(dataset: Dataset): string {
64+
return getDatasetAssetBaseName(dataset);
6865
}
6966

7067
function getBaseTemplate(mappings: Mappings): Template {
@@ -118,16 +115,6 @@ function getBaseTemplate(mappings: Mappings): Template {
118115
match_mapping_type: 'string',
119116
},
120117
},
121-
// Example of a dynamic template
122-
{
123-
labels: {
124-
path_match: 'labels.*',
125-
mapping: {
126-
type: 'keyword',
127-
},
128-
match_mapping_type: 'string',
129-
},
130-
},
131118
],
132119
// As we define fields ahead, we don't need any automatic field detection
133120
// This makes sure all the fields are mapped to keyword by default to prevent mapping conflicts

0 commit comments

Comments
 (0)