Skip to content

Commit f49ca9c

Browse files
Merge branch 'master' into filebeat_notice
2 parents 57f9c11 + 1010f28 commit f49ca9c

63 files changed

Lines changed: 1475 additions & 1191 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/plugins/data/public/search/es_search/es_search_strategy.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,25 @@
2020
import { Observable } from 'rxjs';
2121
import { ES_SEARCH_STRATEGY, IEsSearchResponse } from '../../../common/search';
2222
import { SYNC_SEARCH_STRATEGY } from '../sync_search_strategy';
23+
import { getEsPreference } from './get_es_preference';
2324
import { TSearchStrategyProvider, ISearchStrategy, ISearchGeneric, ISearchContext } from '..';
2425

2526
export const esSearchStrategyProvider: TSearchStrategyProvider<typeof ES_SEARCH_STRATEGY> = (
2627
context: ISearchContext,
2728
search: ISearchGeneric
2829
): ISearchStrategy<typeof ES_SEARCH_STRATEGY> => {
2930
return {
30-
search: (request, options) =>
31-
search(
31+
search: (request, options) => {
32+
if (typeof request.params.preference === 'undefined') {
33+
const setPreference = context.core.uiSettings.get('courier:setRequestPreference');
34+
const customPreference = context.core.uiSettings.get('courier:customRequestPreference');
35+
request.params.preference = getEsPreference(setPreference, customPreference);
36+
}
37+
return search(
3238
{ ...request, serverStrategy: ES_SEARCH_STRATEGY },
3339
options,
3440
SYNC_SEARCH_STRATEGY
35-
) as Observable<IEsSearchResponse>,
41+
) as Observable<IEsSearchResponse>;
42+
},
3643
};
3744
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { getEsPreference } from './get_es_preference';
21+
22+
jest.useFakeTimers();
23+
24+
describe('Get ES preference', () => {
25+
test('returns the session ID if set to sessionId', () => {
26+
const setPreference = 'sessionId';
27+
const customPreference = 'foobar';
28+
const sessionId = 'my_session_id';
29+
const preference = getEsPreference(setPreference, customPreference, sessionId);
30+
expect(preference).toBe(sessionId);
31+
});
32+
33+
test('returns the custom preference if set to custom', () => {
34+
const setPreference = 'custom';
35+
const customPreference = 'foobar';
36+
const preference = getEsPreference(setPreference, customPreference);
37+
expect(preference).toBe(customPreference);
38+
});
39+
40+
test('returns undefined if set to none', () => {
41+
const setPreference = 'none';
42+
const customPreference = 'foobar';
43+
const preference = getEsPreference(setPreference, customPreference);
44+
expect(preference).toBe(undefined);
45+
});
46+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
const defaultSessionId = `${Date.now()}`;
21+
22+
export function getEsPreference(
23+
setRequestPreference: string,
24+
customRequestPreference?: string,
25+
sessionId: string = defaultSessionId
26+
) {
27+
if (setRequestPreference === 'sessionId') return `${sessionId}`;
28+
return setRequestPreference === 'custom' ? customRequestPreference : undefined;
29+
}

src/plugins/newsfeed/public/lib/api.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,7 @@ describe('getApi', () => {
631631
.mockImplementationOnce(getHttpMockWithItems(successItems));
632632

633633
getApi(httpMock, configMock.newsfeed, '6.8.2')
634-
.pipe(
635-
take(4),
636-
toArray()
637-
)
634+
.pipe(take(4), toArray())
638635
.subscribe(result => {
639636
expect(result).toMatchInlineSnapshot(`
640637
Array [

x-pack/legacy/plugins/infra/common/inventory_models/container/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { layout } from './layout';
87
import { metrics } from './metrics';
98
import { InventoryModel } from '../types';
109

1110
export const container: InventoryModel = {
1211
id: 'container',
1312
requiredModules: ['docker'],
14-
layout,
1513
metrics,
14+
requiredMetrics: [
15+
'containerOverview',
16+
'containerCpuUsage',
17+
'containerMemory',
18+
'containerNetworkTraffic',
19+
'containerDiskIOBytes',
20+
'containerDiskIOOps',
21+
],
1622
};

x-pack/legacy/plugins/infra/common/inventory_models/container/layout.ts renamed to x-pack/legacy/plugins/infra/common/inventory_models/container/layout.tsx

Lines changed: 95 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,32 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
6+
import React from 'react';
77
import { i18n } from '@kbn/i18n';
8-
import { InventoryDetailLayoutCreator } from '../types';
9-
import { nginxLayoutCreator } from '../shared/layouts/nginx';
8+
import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types';
9+
import { Section } from '../../../public/pages/metrics/components/section';
10+
import { SubSection } from '../../../public/pages/metrics/components/sub_section';
11+
import { GaugesSectionVis } from '../../../public/pages/metrics/components/gauges_section_vis';
12+
import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis';
13+
import { withTheme } from '../../../../../common/eui_styled_components';
1014

11-
export const layout: InventoryDetailLayoutCreator = theme => [
12-
{
13-
id: 'containerOverview',
14-
label: i18n.translate('xpack.infra.metricDetailPage.containerMetricsLayout.layoutLabel', {
15-
defaultMessage: 'Container',
16-
}),
17-
sections: [
18-
{
19-
id: 'containerOverview',
20-
label: i18n.translate(
21-
'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.sectionLabel',
22-
{
23-
defaultMessage: 'Overview',
24-
}
25-
),
26-
requires: ['docker.cpu', 'docker.memory', 'docker.network'],
27-
type: 'gauges',
28-
visConfig: {
29-
seriesOverrides: {
15+
export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => (
16+
<React.Fragment>
17+
<Section
18+
navLabel={i18n.translate('xpack.infra.metricDetailPage.containerMetricsLayout.layoutLabel', {
19+
defaultMessage: 'Container',
20+
})}
21+
sectionLabel={i18n.translate(
22+
'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.sectionLabel',
23+
{
24+
defaultMessage: 'Container Overview',
25+
}
26+
)}
27+
metrics={metrics}
28+
>
29+
<SubSection id="containerOverview">
30+
<GaugesSectionVis
31+
seriesOverrides={{
3032
cpu: {
3133
name: i18n.translate(
3234
'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.cpuUsageSeriesLabel',
@@ -71,62 +73,59 @@ export const layout: InventoryDetailLayoutCreator = theme => [
7173
formatter: 'bits',
7274
formatterTemplate: '{{value}}/s',
7375
},
74-
},
75-
},
76-
},
77-
{
78-
id: 'containerCpuUsage',
79-
label: i18n.translate(
76+
}}
77+
/>
78+
</SubSection>
79+
<SubSection
80+
id="containerCpuUsage"
81+
label={i18n.translate(
8082
'xpack.infra.metricDetailPage.containerMetricsLayout.cpuUsageSection.sectionLabel',
8183
{
8284
defaultMessage: 'CPU Usage',
8385
}
84-
),
85-
requires: ['docker.cpu'],
86-
type: 'chart',
87-
visConfig: {
88-
stacked: true,
89-
type: 'area',
90-
formatter: 'percent',
91-
seriesOverrides: {
86+
)}
87+
>
88+
<ChartSectionVis
89+
stacked={true}
90+
type="area"
91+
formatter="percent"
92+
seriesOverrides={{
9293
cpu: { color: theme.eui.euiColorVis1 },
93-
},
94-
},
95-
},
96-
{
97-
id: 'containerMemory',
98-
label: i18n.translate(
94+
}}
95+
/>
96+
</SubSection>
97+
<SubSection
98+
id="containerMemory"
99+
label={i18n.translate(
99100
'xpack.infra.metricDetailPage.containerMetricsLayout.memoryUsageSection.sectionLabel',
100101
{
101102
defaultMessage: 'Memory Usage',
102103
}
103-
),
104-
requires: ['docker.memory'],
105-
type: 'chart',
106-
visConfig: {
107-
stacked: true,
108-
type: 'area',
109-
formatter: 'percent',
110-
seriesOverrides: {
104+
)}
105+
>
106+
<ChartSectionVis
107+
stacked={true}
108+
type="area"
109+
formatter="percent"
110+
seriesOverrides={{
111111
memory: { color: theme.eui.euiColorVis1 },
112-
},
113-
},
114-
},
115-
{
116-
id: 'containerNetworkTraffic',
117-
label: i18n.translate(
112+
}}
113+
/>
114+
</SubSection>
115+
<SubSection
116+
id="containerNetworkTraffic"
117+
label={i18n.translate(
118118
'xpack.infra.metricDetailPage.containerMetricsLayout.networkTrafficSection.sectionLabel',
119119
{
120120
defaultMessage: 'Network Traffic',
121121
}
122-
),
123-
requires: ['docker.network'],
124-
type: 'chart',
125-
visConfig: {
126-
formatter: 'bits',
127-
formatterTemplate: '{{value}}/s',
128-
type: 'area',
129-
seriesOverrides: {
122+
)}
123+
>
124+
<ChartSectionVis
125+
formatter="bits"
126+
formatterTemplate="{{value}}/s"
127+
type="area"
128+
seriesOverrides={{
130129
rx: {
131130
color: theme.eui.euiColorVis1,
132131
name: i18n.translate(
@@ -145,24 +144,23 @@ export const layout: InventoryDetailLayoutCreator = theme => [
145144
}
146145
),
147146
},
148-
},
149-
},
150-
},
151-
{
152-
id: 'containerDiskIOOps',
153-
label: i18n.translate(
147+
}}
148+
/>
149+
</SubSection>
150+
<SubSection
151+
id="containerDiskIOOps"
152+
label={i18n.translate(
154153
'xpack.infra.metricDetailPage.containerMetricsLayout.diskIoOpsSection.sectionLabel',
155154
{
156155
defaultMessage: 'Disk IO (Ops)',
157156
}
158-
),
159-
requires: ['docker.diskio'],
160-
type: 'chart',
161-
visConfig: {
162-
formatter: 'number',
163-
formatterTemplate: '{{value}}/s',
164-
type: 'area',
165-
seriesOverrides: {
157+
)}
158+
>
159+
<ChartSectionVis
160+
type="area"
161+
formatterTemplate="{{value}}/s"
162+
formatter="number"
163+
seriesOverrides={{
166164
read: {
167165
color: theme.eui.euiColorVis1,
168166
name: i18n.translate(
@@ -181,24 +179,23 @@ export const layout: InventoryDetailLayoutCreator = theme => [
181179
}
182180
),
183181
},
184-
},
185-
},
186-
},
187-
{
188-
id: 'containerDiskIOBytes',
189-
label: i18n.translate(
182+
}}
183+
/>
184+
</SubSection>
185+
<SubSection
186+
id="containerDiskIOBytes"
187+
label={i18n.translate(
190188
'xpack.infra.metricDetailPage.containerMetricsLayout.diskIoBytesSection.sectionLabel',
191189
{
192190
defaultMessage: 'Disk IO (Bytes)',
193191
}
194-
),
195-
requires: ['docker.diskio'],
196-
type: 'chart',
197-
visConfig: {
198-
formatter: 'bytes',
199-
formatterTemplate: '{{value}}/s',
200-
type: 'area',
201-
seriesOverrides: {
192+
)}
193+
>
194+
<ChartSectionVis
195+
type="area"
196+
formatter="bytes"
197+
formatterTemplate="{{value}}/s"
198+
seriesOverrides={{
202199
read: {
203200
color: theme.eui.euiColorVis1,
204201
name: i18n.translate(
@@ -217,10 +214,9 @@ export const layout: InventoryDetailLayoutCreator = theme => [
217214
}
218215
),
219216
},
220-
},
221-
},
222-
},
223-
],
224-
},
225-
...nginxLayoutCreator(theme),
226-
];
217+
}}
218+
/>
219+
</SubSection>
220+
</Section>
221+
</React.Fragment>
222+
));

x-pack/legacy/plugins/infra/common/inventory_models/container/metrics/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ export const metrics: InventoryMetrics = {
2929
containerMemory,
3030
},
3131
snapshot: { cpu, memory, rx, tx },
32+
defaultSnapshot: 'cpu',
3233
};

0 commit comments

Comments
 (0)