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

[Stack Monitoring] compatibility for agent data streams #119112

Merged
merged 73 commits into from
Jan 20, 2022
Merged
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
1a1e5fa
update queries for elasticsearch package
neptunian Nov 18, 2021
eeb2c60
fix unit test
neptunian Nov 19, 2021
9424af7
add gitCcs helper function
neptunian Nov 19, 2021
94e05b2
modify rest of es queries
neptunian Nov 19, 2021
effdbb7
update logstash and kibana queries to use new createQuery
neptunian Nov 19, 2021
ed4196a
change beats and apm to use new createQuery
neptunian Nov 19, 2021
2d03cb6
update changeQuery and remove old one
neptunian Nov 19, 2021
09b8407
make getIndexPattern take request to check for ccs
neptunian Nov 19, 2021
2b9c104
fix unit test
neptunian Nov 20, 2021
f07710e
fix unit tests
neptunian Nov 20, 2021
2038d27
update queries and createQuery
neptunian Nov 22, 2021
d35a61a
don't add metric constant without dataset in query
neptunian Nov 23, 2021
ee8aa93
fix types
neptunian Nov 23, 2021
d41ea30
fix type
neptunian Nov 23, 2021
ea13b9f
comment out mb tests
neptunian Nov 23, 2021
a909d83
fix unit test
neptunian Nov 23, 2021
ecfee7e
fix unit test
neptunian Nov 23, 2021
88f84ba
fix
neptunian Nov 23, 2021
8894e22
fix function param
neptunian Nov 23, 2021
7b5f8e5
change to getMetrics name
neptunian Nov 23, 2021
513007d
change to node_stats
neptunian Nov 24, 2021
bf67c72
comment out metricbeat tests
neptunian Nov 24, 2021
f686e94
fix types
neptunian Nov 24, 2021
6298e2d
improve types and readability for test
neptunian Nov 29, 2021
42dd489
remove passing of data stream type for now
neptunian Nov 29, 2021
2d7698e
add tests for createQuery changes
neptunian Nov 29, 2021
7e7c8ca
update getNewIndexPatterns to take one dataset
neptunian Nov 30, 2021
55ee366
add unit test for getNewIndexPatterns
neptunian Nov 30, 2021
d850af2
fix types
neptunian Nov 30, 2021
501ca58
remove metrics from filter, update tests
neptunian Dec 1, 2021
805a2cb
update createNewIndexPatterns to accept new config instead of legacy
neptunian Dec 2, 2021
4e74a18
update alert queries to include datas stream index patterns
neptunian Dec 3, 2021
820fe52
update comment
neptunian Dec 3, 2021
e35453b
fix merge conflicts
neptunian Dec 13, 2021
8eeda28
fix defaulting ccs to * for non cluster requests
neptunian Dec 13, 2021
1670e92
update elasticsearch enterprise module
neptunian Dec 14, 2021
7774f07
update unit test
neptunian Dec 14, 2021
0b92576
remove data_stream.type from queries
neptunian Dec 14, 2021
d6f18ec
change entsearch to metricbeat module name enterprisesearch
neptunian Dec 14, 2021
191b4b0
undo ccs cluster stats change
neptunian Dec 14, 2021
b500886
fix import
neptunian Dec 14, 2021
8ef66e5
update alert queries
neptunian Dec 14, 2021
2a34e48
fix unit test
neptunian Dec 14, 2021
f4c011a
update unit test
neptunian Dec 14, 2021
ace5003
change shard size query to use filter
neptunian Dec 15, 2021
a16f212
change must to filter fix
neptunian Dec 15, 2021
e6dab77
Merge branch 'main' into 119109-es-integration-queries
neptunian Dec 15, 2021
81acb8b
update findSupportedBasicLicenseCluster index pattern
neptunian Dec 15, 2021
d0c95bf
add ccs param to cluster request functions
neptunian Dec 15, 2021
ff01aa8
update queries for ccs in get_clusters_from_request
neptunian Dec 15, 2021
0e852de
update getBeatsForClusters query
neptunian Dec 15, 2021
6c07737
update clusters apm query
neptunian Dec 15, 2021
9992708
update enterprisesearch query
neptunian Dec 15, 2021
c49698b
move index pattern to query in fetch for alerts, fix ccs
neptunian Dec 17, 2021
e4deebf
remove metricbeat config from alert tests
neptunian Dec 17, 2021
0d19914
Merge branch 'main' into 119109-es-integration-queries
neptunian Dec 17, 2021
4d170f2
fix ts
neptunian Dec 17, 2021
755e3f0
Merge branch 'main' into 119109-es-integration-queries
neptunian Dec 20, 2021
7f4989b
fix conflicts and update tests, add ecsLegacyOnly param
neptunian Jan 4, 2022
5dc264b
add metricset.name back to queries
neptunian Jan 5, 2022
a88fd55
comment tests back in
neptunian Jan 5, 2022
596b4c0
fix conflicts from logstash changes
neptunian Jan 5, 2022
e5c539f
remove enterprise search checking for standalone cluster to fix test
neptunian Jan 6, 2022
3213b43
update es index metricset name from index_stats to index for mb data
neptunian Jan 6, 2022
0996399
fix type
neptunian Jan 6, 2022
2b841e4
Merge branch 'main' into 119109-es-integration-queries
neptunian Jan 18, 2022
6878713
fetchClusters creates index pattern
neptunian Jan 18, 2022
dee9ac0
fix type
neptunian Jan 18, 2022
dfe3dd6
Merge branch 'main' into 119109-es-integration-queries
kibanamachine Jan 20, 2022
17b6b2a
Merge branch 'main' into 119109-es-integration-queries
kibanamachine Jan 20, 2022
ca549e4
remove monitoring.ui.metricbeat.index from config and usage in getCol…
neptunian Jan 20, 2022
648d582
Merge branch '119109-es-integration-queries' of github.com:neptunian/…
neptunian Jan 20, 2022
2379e9e
fix type
neptunian Jan 20, 2022
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
Prev Previous commit
Next Next commit
improve types and readability for test
neptunian committed Dec 2, 2021
commit 6298e2d267328a9211fbe7880469301073a4c69e
136 changes: 136 additions & 0 deletions x-pack/plugins/monitoring/server/lib/create_query.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { MissingRequiredError } from './error_missing_required';
import { ElasticsearchMetric } from './metrics';
import { createQuery } from './create_query';

interface Metric {
uuidField?: string;
timestampField: string;
}
let metric: Metric;

describe('Create Query', () => {
beforeEach(() => {
metric = ElasticsearchMetric.getMetricFields();
});

it('Allows UUID to not be passed', () => {
const options = { metric, clusterUuid: 'cuid123' };
expect(createQuery(options)).toEqual({
bool: { filter: [{ term: { cluster_uuid: 'cuid123' } }] },
});
});

it('Uses Elasticsearch timestamp field for start and end time range by default', () => {
const options = {
clusterUuid: 'cuid123',
uuid: 'abc123',
start: 1456826400000,
end: 14568264010000,
metric,
};
expect(createQuery(options)).toEqual({
bool: {
filter: [
{ term: { cluster_uuid: 'cuid123' } },
{ term: { 'source_node.uuid': 'abc123' } },
{
range: {
timestamp: { format: 'epoch_millis', gte: 1456826400000, lte: 14568264010000 },
},
},
],
},
});
});

it('Injects uuid and timestamp fields dynamically, based on metric', () => {
const options = {
clusterUuid: 'cuid123',
uuid: 'abc123',
start: 1456826400000,
end: 14568264010000,
metric: {
uuidField: 'testUuidField',
timestampField: 'testTimestampField',
},
};
expect(createQuery(options)).toEqual({
bool: {
filter: [
{ term: { cluster_uuid: 'cuid123' } },
{ term: { testUuidField: 'abc123' } },
{
range: {
testTimestampField: {
format: 'epoch_millis',
gte: 1456826400000,
lte: 14568264010000,
},
},
},
],
},
});
});

it('Throws if missing metric.timestampField', () => {
function callCreateQuery() {
const options = { clusterUuid: 'cuid123' }; // missing metric object
return createQuery(options);
}
expect(callCreateQuery).toThrowError(MissingRequiredError);
});

it('Throws if given uuid but missing metric.uuidField', () => {
function callCreateQuery() {
const options = { uuid: 'abc123', clusterUuid: 'cuid123', metric };
delete options.metric.uuidField;
return createQuery(options);
}
expect(callCreateQuery).toThrowError(MissingRequiredError);
});

it('Uses `type` option to add type filter with minimal fields', () => {
const options = { type: 'cluster_stats', clusterUuid: 'cuid123', metric };
expect(createQuery(options)).toEqual({
bool: {
filter: [
{ bool: { should: [{ term: { type: 'cluster_stats' } }] } },
{ term: { cluster_uuid: 'cuid123' } },
],
},
});
});

it('Uses `type` option to add type filter with all other option fields', () => {
const options = {
type: 'cluster_stats',
clusterUuid: 'cuid123',
uuid: 'abc123',
start: 1456826400000,
end: 14568264000000,
metric,
};
expect(createQuery(options)).toEqual({
bool: {
filter: [
{ bool: { should: [{ term: { type: 'cluster_stats' } }] } },
{ term: { cluster_uuid: 'cuid123' } },
{ term: { 'source_node.uuid': 'abc123' } },
{
range: {
timestamp: { format: 'epoch_millis', gte: 1456826400000, lte: 14568264000000 },
},
},
],
},
});
});
});