-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Infra Server Migration #53955
Closed
Closed
Infra Server Migration #53955
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5b62251
Moves server and common files from legacy to np for infra
jasonrhodes 39fe4fd
Unshims NP server plugin
jasonrhodes 4e57e2a
Fixes index patterns dependency for NP (based on APM)
jasonrhodes d850940
Removes lodash/fp dependency to avoid need for our own lodash
jasonrhodes ea99934
NP cleanup and removal of legacy server directory
jasonrhodes ca4d97d
Adds metrics plugin dep back after cherry picking needed changes
jasonrhodes 9c7aa22
Remove unused saved objects mapping -- need to replace before merge
jasonrhodes 4d944a9
Implements destructured imports for lodash methods
jasonrhodes b3f8308
Fixes lodash destructure change so methods are correctly called in code
jasonrhodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { sampleColor, MetricsExplorerColor, colorTransformer } from './color_palette'; | ||
describe('Color Palette', () => { | ||
describe('sampleColor()', () => { | ||
it('should just work', () => { | ||
const usedColors = [MetricsExplorerColor.color0]; | ||
const color = sampleColor(usedColors); | ||
expect(color).toBe(MetricsExplorerColor.color1); | ||
}); | ||
|
||
it('should return color0 when nothing is available', () => { | ||
const usedColors = [ | ||
MetricsExplorerColor.color0, | ||
MetricsExplorerColor.color1, | ||
MetricsExplorerColor.color2, | ||
MetricsExplorerColor.color3, | ||
MetricsExplorerColor.color4, | ||
MetricsExplorerColor.color5, | ||
MetricsExplorerColor.color6, | ||
MetricsExplorerColor.color7, | ||
MetricsExplorerColor.color8, | ||
MetricsExplorerColor.color9, | ||
]; | ||
const color = sampleColor(usedColors); | ||
expect(color).toBe(MetricsExplorerColor.color0); | ||
}); | ||
}); | ||
describe('colorTransformer()', () => { | ||
it('should just work', () => { | ||
expect(colorTransformer(MetricsExplorerColor.color0)).toBe('#3185FC'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { difference, first, values } from 'lodash'; | ||
|
||
export enum MetricsExplorerColor { | ||
color0 = 'color0', | ||
color1 = 'color1', | ||
color2 = 'color2', | ||
color3 = 'color3', | ||
color4 = 'color4', | ||
color5 = 'color5', | ||
color6 = 'color6', | ||
color7 = 'color7', | ||
color8 = 'color8', | ||
color9 = 'color9', | ||
} | ||
|
||
export interface MetricsExplorerPalette { | ||
[MetricsExplorerColor.color0]: string; | ||
[MetricsExplorerColor.color1]: string; | ||
[MetricsExplorerColor.color2]: string; | ||
[MetricsExplorerColor.color3]: string; | ||
[MetricsExplorerColor.color4]: string; | ||
[MetricsExplorerColor.color5]: string; | ||
[MetricsExplorerColor.color6]: string; | ||
[MetricsExplorerColor.color7]: string; | ||
[MetricsExplorerColor.color8]: string; | ||
[MetricsExplorerColor.color9]: string; | ||
} | ||
|
||
export const defaultPalette: MetricsExplorerPalette = { | ||
[MetricsExplorerColor.color0]: '#3185FC', // euiColorVis1 (blue) | ||
[MetricsExplorerColor.color1]: '#DB1374', // euiColorVis2 (red-ish) | ||
[MetricsExplorerColor.color2]: '#00B3A4', // euiColorVis0 (green-ish) | ||
[MetricsExplorerColor.color3]: '#490092', // euiColorVis3 (purple) | ||
[MetricsExplorerColor.color4]: '#FEB6DB', // euiColorVis4 (pink) | ||
[MetricsExplorerColor.color5]: '#E6C220', // euiColorVis5 (yellow) | ||
[MetricsExplorerColor.color6]: '#BFA180', // euiColorVis6 (tan) | ||
[MetricsExplorerColor.color7]: '#F98510', // euiColorVis7 (orange) | ||
[MetricsExplorerColor.color8]: '#461A0A', // euiColorVis8 (brown) | ||
[MetricsExplorerColor.color9]: '#920000', // euiColorVis9 (maroon) | ||
}; | ||
|
||
export const createPaletteTransformer = (palette: MetricsExplorerPalette) => ( | ||
color: MetricsExplorerColor | ||
) => palette[color]; | ||
|
||
export const colorTransformer = createPaletteTransformer(defaultPalette); | ||
|
||
export const sampleColor = (usedColors: MetricsExplorerColor[] = []): MetricsExplorerColor => { | ||
const available = difference(values(MetricsExplorerColor) as MetricsExplorerColor[], usedColors); | ||
return first(available) || MetricsExplorerColor.color0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
getAllowedListForPrefix, | ||
ECS_ALLOWED_LIST, | ||
K8S_ALLOWED_LIST, | ||
PROMETHEUS_ALLOWED_LIST, | ||
DOCKER_ALLOWED_LIST, | ||
} from './ecs_allowed_list'; | ||
describe('getAllowedListForPrefix()', () => { | ||
test('kubernetes', () => { | ||
expect(getAllowedListForPrefix('kubernetes.pod')).toEqual([ | ||
...ECS_ALLOWED_LIST, | ||
'kubernetes.pod', | ||
...K8S_ALLOWED_LIST, | ||
]); | ||
}); | ||
test('docker', () => { | ||
expect(getAllowedListForPrefix('docker.container')).toEqual([ | ||
...ECS_ALLOWED_LIST, | ||
'docker.container', | ||
...DOCKER_ALLOWED_LIST, | ||
]); | ||
}); | ||
test('prometheus', () => { | ||
expect(getAllowedListForPrefix('prometheus.metrics')).toEqual([ | ||
...ECS_ALLOWED_LIST, | ||
'prometheus.metrics', | ||
...PROMETHEUS_ALLOWED_LIST, | ||
]); | ||
}); | ||
test('anything.else', () => { | ||
expect(getAllowedListForPrefix('anything.else')).toEqual([ | ||
...ECS_ALLOWED_LIST, | ||
'anything.else', | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { first } from 'lodash'; | ||
|
||
export const ECS_ALLOWED_LIST = [ | ||
'host', | ||
'cloud', | ||
'event', | ||
'agent', | ||
'fields', | ||
'service', | ||
'ecs', | ||
'metricset', | ||
'tags', | ||
'message', | ||
'labels', | ||
'@timestamp', | ||
'source', | ||
'container', | ||
]; | ||
|
||
export const K8S_ALLOWED_LIST = [ | ||
'kubernetes.pod.name', | ||
'kubernetes.pod.uid', | ||
'kubernetes.namespace', | ||
'kubernetes.node.name', | ||
'kubernetes.labels', | ||
'kubernetes.annotations', | ||
'kubernetes.replicaset.name', | ||
'kubernetes.deployment.name', | ||
'kubernetes.statefulset.name', | ||
'kubernetes.container.name', | ||
'kubernetes.container.image', | ||
]; | ||
|
||
export const PROMETHEUS_ALLOWED_LIST = ['prometheus.labels', 'prometheus.metrics']; | ||
|
||
export const DOCKER_ALLOWED_LIST = [ | ||
'docker.container.id', | ||
'docker.container.image', | ||
'docker.container.name', | ||
'docker.container.labels', | ||
]; | ||
|
||
export const AWS_S3_ALLOWED_LIST = ['aws.s3']; | ||
|
||
export const getAllowedListForPrefix = (prefix: string) => { | ||
const firstPart = first(prefix.split(/\./)); | ||
const defaultAllowedList = prefix ? [...ECS_ALLOWED_LIST, prefix] : ECS_ALLOWED_LIST; | ||
switch (firstPart) { | ||
case 'docker': | ||
return [...defaultAllowedList, ...DOCKER_ALLOWED_LIST]; | ||
case 'prometheus': | ||
return [...defaultAllowedList, ...PROMETHEUS_ALLOWED_LIST]; | ||
case 'kubernetes': | ||
return [...defaultAllowedList, ...K8S_ALLOWED_LIST]; | ||
case 'aws': | ||
if (prefix === 'aws.s3_daily_storage') { | ||
return [...defaultAllowedList, ...AWS_S3_ALLOWED_LIST]; | ||
} | ||
default: | ||
return defaultAllowedList; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export * from './metrics'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export enum InfraMetricsErrorCodes { | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
invalid_node = 'METRICS_INVALID_NODE', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { rootSchema } from './schema.gql'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import gql from 'graphql-tag'; | ||
|
||
export const rootSchema = gql` | ||
schema { | ||
query: Query | ||
mutation: Mutation | ||
} | ||
|
||
type Query | ||
|
||
type Mutation | ||
`; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something may have potentially gone wrong with a merge somewhere along the line, and the migration from
legacyServer.addAppLinksToSampleDataset
toplugins.home.sampleData.addAppLinksToSampleDataset
in #52753.We can remove
legacyServer.addAppLinksToSampleDataset
(it doesn't exist inmaster
).(This file is also throwing an exception as
logsSampleDataLinkLabel
doesn't exist here).