Skip to content

Commit

Permalink
Merge branch 'master' into bug/ccr-watcher-license-messages
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Apr 14, 2021
2 parents efd968e + 39e4ea8 commit 066a69f
Show file tree
Hide file tree
Showing 87 changed files with 2,802 additions and 774 deletions.
4 changes: 2 additions & 2 deletions docs/user/monitoring/kibana-alerts.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ by running checks on a schedule time of 1 minute with a re-notify interval of 6
[[kibana-alerts-large-shard-size]]
== Large shard size

This alert is triggered if a large (primary) shard size is found on any of the
specified index patterns. The trigger condition is met if an index's shard size is
This alert is triggered if a large average shard size (across associated primaries) is found on any of the
specified index patterns. The trigger condition is met if an index's average shard size is
55gb or higher in the last 5 minutes. The alert is grouped across all indices that match
the default pattern of `*` by running checks on a schedule time of 1 minute with a re-notify
interval of 12 hours.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
IIndexPatternsApiClient,
GetFieldsOptionsTimePattern,
} from '../../common/index_patterns/types';
import { IndexPatternMissingIndices } from '../../common/index_patterns/lib';
import { IndexPatternsFetcher } from './fetcher';

export class IndexPatternsApiServer implements IIndexPatternsApiClient {
Expand All @@ -27,12 +28,23 @@ export class IndexPatternsApiServer implements IIndexPatternsApiClient {
allowNoIndex,
}: GetFieldsOptions) {
const indexPatterns = new IndexPatternsFetcher(this.esClient, allowNoIndex);
return await indexPatterns.getFieldsForWildcard({
pattern,
metaFields,
type,
rollupIndex,
});
return await indexPatterns
.getFieldsForWildcard({
pattern,
metaFields,
type,
rollupIndex,
})
.catch((err) => {
if (
err.output.payload.statusCode === 404 &&
err.output.payload.code === 'no_matching_indices'
) {
throw new IndexPatternMissingIndices(pattern);
} else {
throw err;
}
});
}
async getFieldsForTimePattern(options: GetFieldsOptionsTimePattern) {
const indexPatterns = new IndexPatternsFetcher(this.esClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const indexPatternsServiceFactory = ({
logger.error(error);
},
onNotification: ({ title, text }) => {
logger.warn(`${title} : ${text}`);
logger.warn(`${title}${text ? ` : ${text}` : ''}`);
},
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ describe('<FieldEditor />', () => {
expect(form.getErrorsMessages()).toEqual(['Awwww! Painless syntax error']);

// We change the type and expect the form error to not be there anymore
await changeFieldType('long');
await changeFieldType('keyword');
expect(form.getErrorsMessages()).toEqual([]);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
EuiSpacer,
EuiComboBoxOptionOption,
EuiCode,
EuiCallOut,
} from '@elastic/eui';
import type { CoreStart } from 'src/core/public';

Expand Down Expand Up @@ -138,6 +139,11 @@ const geti18nTexts = (): {
},
});

const changeWarning = i18n.translate('indexPatternFieldEditor.editor.form.changeWarning', {
defaultMessage:
'Changing name or type can break searches and visualizations that rely on this field.',
});

const formDeserializer = (field: Field): FieldFormInternal => {
let fieldType: Array<EuiComboBoxOptionOption<RuntimeType>>;
if (!field.type) {
Expand Down Expand Up @@ -204,6 +210,11 @@ const FieldEditorComponent = ({
clearSyntaxError();
}, [type, clearSyntaxError]);

const [{ name: updatedName, type: updatedType }] = useFormData({ form });
const nameHasChanged = Boolean(field?.name) && field?.name !== updatedName;
const typeHasChanged =
Boolean(field?.type) && field?.type !== (updatedType && updatedType[0].value);

return (
<Form form={form} className="indexPatternFieldEditor__form">
<EuiFlexGroup>
Expand Down Expand Up @@ -231,6 +242,18 @@ const FieldEditorComponent = ({
</EuiFlexItem>
</EuiFlexGroup>

{(nameHasChanged || typeHasChanged) && (
<>
<EuiSpacer size="xs" />
<EuiCallOut
color="warning"
title={changeWarning}
iconType="alert"
size="s"
data-test-subj="changeWarning"
/>
</>
)}
<EuiSpacer size="xl" />

{/* Set custom label */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ export default function ({ getService }: FtrProviderContext) {
});

it('can set field "format" on an existing field', async () => {
const title = `foo-${Date.now()}-${Math.random()}*`;
const title = indexPattern.title;
await supertest.delete(`/api/index_patterns/index_pattern/${indexPattern.id}`);
const response1 = await supertest.post('/api/index_patterns/index_pattern').send({
index_pattern: {
title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ import { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

describe('main', () => {
before(async () => {
await esArchiver.load('index_patterns/basic_index');
});

after(async () => {
await esArchiver.unload('index_patterns/basic_index');
});

it('can create a new scripted field', async () => {
const title = `foo-${Date.now()}-${Math.random()}*`;
const response1 = await supertest.post('/api/index_patterns/index_pattern').send({
Expand Down Expand Up @@ -40,7 +49,7 @@ export default function ({ getService }: FtrProviderContext) {
});

it('newly created scripted field is materialized in the index_pattern object', async () => {
const title = `foo-${Date.now()}-${Math.random()}*`;
const title = `basic_index`;
const response1 = await supertest.post('/api/index_patterns/index_pattern').send({
index_pattern: {
title,
Expand All @@ -51,7 +60,7 @@ export default function ({ getService }: FtrProviderContext) {
.post(`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/scripted_field`)
.send({
field: {
name: 'bar',
name: 'bar2',
type: 'number',
scripted: true,
script: "doc['field_name'].value",
Expand All @@ -64,12 +73,15 @@ export default function ({ getService }: FtrProviderContext) {

expect(response2.status).to.be(200);

const field = response2.body.index_pattern.fields.bar;
const field = response2.body.index_pattern.fields.bar2;

expect(field.name).to.be('bar');
expect(field.name).to.be('bar2');
expect(field.type).to.be('number');
expect(field.scripted).to.be(true);
expect(field.script).to.be("doc['field_name'].value");
await supertest.delete(
'/api/index_patterns/index_pattern/' + response1.body.index_pattern.id
);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,25 @@ import { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

describe('main', () => {
before(async () => {
await esArchiver.load('index_patterns/basic_index');
});

after(async () => {
await esArchiver.unload('index_patterns/basic_index');
});

it('can remove a scripted field', async () => {
const title = `foo-${Date.now()}-${Math.random()}*`;
const title = `basic_index`;
const response1 = await supertest.post('/api/index_patterns/index_pattern').send({
index_pattern: {
title,
fields: {
bar: {
name: 'bar',
name: 'bar2',
type: 'number',
scripted: true,
script: "doc['field_name'].value",
Expand All @@ -33,10 +42,10 @@ export default function ({ getService }: FtrProviderContext) {
'/api/index_patterns/index_pattern/' + response1.body.index_pattern.id
);

expect(typeof response2.body.index_pattern.fields.bar).to.be('object');
expect(typeof response2.body.index_pattern.fields.bar2).to.be('object');

const response3 = await supertest.delete(
`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/scripted_field/bar`
`/api/index_patterns/index_pattern/${response1.body.index_pattern.id}/scripted_field/bar2`
);

expect(response3.status).to.be(200);
Expand All @@ -45,7 +54,10 @@ export default function ({ getService }: FtrProviderContext) {
'/api/index_patterns/index_pattern/' + response1.body.index_pattern.id
);

expect(typeof response4.body.index_pattern.fields.bar).to.be('undefined');
expect(typeof response4.body.index_pattern.fields.bar2).to.be('undefined');
await supertest.delete(
'/api/index_patterns/index_pattern/' + response1.body.index_pattern.id
);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ import { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

describe('main', () => {
before(async () => {
await esArchiver.load('index_patterns/basic_index');
});

after(async () => {
await esArchiver.unload('index_patterns/basic_index');
});

it('can fetch a scripted field', async () => {
const title = `foo-${Date.now()}-${Math.random()}*`;
const title = `basic_index`;
const response1 = await supertest.post('/api/index_patterns/index_pattern').send({
index_pattern: {
title,
Expand Down Expand Up @@ -47,6 +56,9 @@ export default function ({ getService }: FtrProviderContext) {
expect(response2.body.field.type).to.be('number');
expect(response2.body.field.scripted).to.be(true);
expect(response2.body.field.script).to.be("doc['field_name'].value");
await supertest.delete(
'/api/index_patterns/index_pattern/' + response1.body.index_pattern.id
);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ import { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

describe('main', () => {
before(async () => {
await esArchiver.load('index_patterns/basic_index');
});

after(async () => {
await esArchiver.unload('index_patterns/basic_index');
});

it('can overwrite an existing field', async () => {
const title = `foo-${Date.now()}-${Math.random()}*`;
const title = `basic_index`;
const response1 = await supertest.post('/api/index_patterns/index_pattern').send({
index_pattern: {
title,
Expand Down Expand Up @@ -63,10 +72,13 @@ export default function ({ getService }: FtrProviderContext) {

expect(response3.status).to.be(200);
expect(response3.body.field.type).to.be('string');
await supertest.delete(
'/api/index_patterns/index_pattern/' + response1.body.index_pattern.id
);
});

it('can add a new scripted field', async () => {
const title = `foo-${Date.now()}-${Math.random()}*`;
const title = `basic_index`;
const response1 = await supertest.post('/api/index_patterns/index_pattern').send({
index_pattern: {
title,
Expand Down Expand Up @@ -100,6 +112,9 @@ export default function ({ getService }: FtrProviderContext) {

expect(response2.status).to.be(200);
expect(response2.body.field.script).to.be("doc['bar'].value");
await supertest.delete(
'/api/index_patterns/index_pattern/' + response1.body.index_pattern.id
);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ import { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

describe('main', () => {
before(async () => {
await esArchiver.load('index_patterns/basic_index');
});

after(async () => {
await esArchiver.unload('index_patterns/basic_index');
});

it('can update an existing field', async () => {
const title = `foo-${Date.now()}-${Math.random()}*`;
const title = `basic_index`;
const response1 = await supertest.post('/api/index_patterns/index_pattern').send({
index_pattern: {
title,
Expand Down Expand Up @@ -56,6 +65,9 @@ export default function ({ getService }: FtrProviderContext) {
expect(response3.status).to.be(200);
expect(response3.body.field.type).to.be('string');
expect(response3.body.field.script).to.be("doc['bar'].value");
await supertest.delete(
'/api/index_patterns/index_pattern/' + response1.body.index_pattern.id
);
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/management/_runtime_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function ({ getService, getPageObjects }) {
await testSubjects.click('editFieldFormat');
await PageObjects.settings.setFieldType('Long');
await PageObjects.settings.changeFieldScript('emit(6);');
await testSubjects.find('changeWarning');
await PageObjects.settings.clickSaveField();
await PageObjects.settings.confirmSave();
});
Expand Down
7 changes: 0 additions & 7 deletions x-pack/plugins/apm/common/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,3 @@ export const NOT_AVAILABLE_LABEL = i18n.translate(
defaultMessage: 'N/A',
}
);

export const UNIDENTIFIED_SERVICE_NODES_LABEL = i18n.translate(
'xpack.apm.serviceNodeNameMissing',
{
defaultMessage: '(Empty)',
}
);
15 changes: 15 additions & 0 deletions x-pack/plugins/apm/common/service_nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,19 @@
* 2.0.
*/

import { i18n } from '@kbn/i18n';

export const SERVICE_NODE_NAME_MISSING = '_service_node_name_missing_';

const UNIDENTIFIED_SERVICE_NODES_LABEL = i18n.translate(
'xpack.apm.serviceNodeNameMissing',
{
defaultMessage: '(Empty)',
}
);

export function getServiceNodeName(serviceNodeName?: string) {
return serviceNodeName === SERVICE_NODE_NAME_MISSING || !serviceNodeName
? UNIDENTIFIED_SERVICE_NODES_LABEL
: serviceNodeName;
}
Loading

0 comments on commit 066a69f

Please sign in to comment.