Skip to content

Commit

Permalink
update query filter datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
klacabane committed Aug 17, 2022
1 parent 397f206 commit ac818d4
Show file tree
Hide file tree
Showing 60 changed files with 138 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('fetchCCReadExceptions', () => {
should: [
{ term: { type: 'ccr_stats' } },
{ term: { 'metricset.name': 'ccr' } },
{ term: { 'data_stream.dataset': 'elasticsearch.ccr' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.ccr' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ElasticsearchClient } from '@kbn/core/server';
import { get } from 'lodash';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { CCRReadExceptionsStats } from '../../../common/types/alerts';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';

Expand Down Expand Up @@ -63,7 +63,7 @@ export async function fetchCCRReadExceptions(
minimum_should_match: 1,
},
},
createDatasetFilter('ccr_stats', 'ccr', 'elasticsearch.ccr'),
createDatasetFilter('ccr_stats', 'ccr', getElasticsearchDataset('ccr')),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('fetchClusterHealth', () => {
should: [
{ term: { type: 'cluster_stats' } },
{ term: { 'metricset.name': 'cluster_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.cluster_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.cluster_stats' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AlertCluster, AlertClusterHealth } from '../../../common/types/alerts';
import { ElasticsearchSource } from '../../../common/types/es';
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';

export async function fetchClusterHealth(
Expand Down Expand Up @@ -50,7 +50,11 @@ export async function fetchClusterHealth(
cluster_uuid: clusters.map((cluster) => cluster.clusterUuid),
},
},
createDatasetFilter('cluster_stats', 'cluster_stats', 'elasticsearch.cluster_stats'),
createDatasetFilter(
'cluster_stats',
'cluster_stats',
getElasticsearchDataset('cluster_stats')
),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('fetchClusters', () => {
should: [
{ term: { type: 'cluster_stats' } },
{ term: { 'metricset.name': 'cluster_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.cluster_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.cluster_stats' } },
],
minimum_should_match: 1,
},
Expand Down
8 changes: 6 additions & 2 deletions x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { ElasticsearchClient } from '@kbn/core/server';
import { get } from 'lodash';
import { AlertCluster } from '../../../common/types/alerts';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
Expand Down Expand Up @@ -44,7 +44,11 @@ export async function fetchClusters(
query: {
bool: {
filter: [
createDatasetFilter('cluster_stats', 'cluster_stats', 'elasticsearch.cluster_stats'),
createDatasetFilter(
'cluster_stats',
'cluster_stats',
getElasticsearchDataset('cluster_stats')
),
{
range: rangeFilter,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe('fetchCpuUsageNodeStats', () => {
should: [
{ term: { type: 'node_stats' } },
{ term: { 'metricset.name': 'node_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.node_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.node_stats' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import moment from 'moment';
import { NORMALIZED_DERIVATIVE_UNIT } from '../../../common/constants';
import { AlertCluster, AlertCpuUsageNodeStats } from '../../../common/types/alerts';
import { createDatasetFilter } from './create_dataset_query_filter';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';

Expand Down Expand Up @@ -58,7 +58,7 @@ export async function fetchCpuUsageNodeStats(
cluster_uuid: clusters.map((cluster) => cluster.clusterUuid),
},
},
createDatasetFilter('node_stats', 'node_stats', 'elasticsearch.node_stats'),
createDatasetFilter('node_stats', 'node_stats', getElasticsearchDataset('node_stats')),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('fetchDiskUsageNodeStats', () => {
should: [
{ term: { type: 'node_stats' } },
{ term: { 'metricset.name': 'node_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.node_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.node_stats' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AlertCluster, AlertDiskUsageNodeStats } from '../../../common/types/ale
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';

export async function fetchDiskUsageNodeStats(
esClient: ElasticsearchClient,
Expand Down Expand Up @@ -40,7 +40,7 @@ export async function fetchDiskUsageNodeStats(
cluster_uuid: clustersIds,
},
},
createDatasetFilter('node_stats', 'node_stats', 'elasticsearch.node_stats'),
createDatasetFilter('node_stats', 'node_stats', getElasticsearchDataset('node_stats')),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('fetchElasticsearchVersions', () => {
should: [
{ term: { type: 'cluster_stats' } },
{ term: { 'metricset.name': 'cluster_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.cluster_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.cluster_stats' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ElasticsearchSource } from '../../../common/types/es';
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';

export async function fetchElasticsearchVersions(
esClient: ElasticsearchClient,
Expand Down Expand Up @@ -51,7 +51,11 @@ export async function fetchElasticsearchVersions(
cluster_uuid: clusters.map((cluster) => cluster.clusterUuid),
},
},
createDatasetFilter('cluster_stats', 'cluster_stats', 'elasticsearch.cluster_stats'),
createDatasetFilter(
'cluster_stats',
'cluster_stats',
getElasticsearchDataset('cluster_stats')
),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('fetchIndexShardSize', () => {
should: [
{ term: { type: 'index_stats' } },
{ term: { 'metricset.name': 'index' } },
{ term: { 'data_stream.dataset': 'elasticsearch.index' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.index' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ESGlobPatterns, RegExPatterns } from '../../../common/es_glob_patterns'
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';

type TopHitType = ElasticsearchResponseHit & {
_source: { index_stats?: Partial<ElasticsearchIndexStats> };
Expand Down Expand Up @@ -50,7 +50,7 @@ export async function fetchIndexShardSize(
query: {
bool: {
filter: [
createDatasetFilter('index_stats', 'index', 'elasticsearch.index'),
createDatasetFilter('index_stats', 'index', getElasticsearchDataset('index')),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('fetchKibanaVersions', () => {
should: [
{ term: { type: 'kibana_stats' } },
{ term: { 'metricset.name': 'stats' } },
{ term: { 'data_stream.dataset': 'kibana.stats' } },
{ term: { 'data_stream.dataset': 'kibana.stack_monitoring.stats' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { AlertCluster, AlertVersions } from '../../../common/types/alerts';
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getKibanaDataset } from '../cluster/get_index_patterns';

interface ESAggResponse {
key: string;
Expand Down Expand Up @@ -41,7 +41,7 @@ export async function fetchKibanaVersions(
cluster_uuid: clusters.map((cluster) => cluster.clusterUuid),
},
},
createDatasetFilter('kibana_stats', 'stats', 'kibana.stats'),
createDatasetFilter('kibana_stats', 'stats', getKibanaDataset('stats')),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('fetchLicenses', () => {
should: [
{ term: { type: 'cluster_stats' } },
{ term: { 'metricset.name': 'cluster_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.cluster_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.cluster_stats' } },
],
minimum_should_match: 1,
},
Expand Down
8 changes: 6 additions & 2 deletions x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ElasticsearchSource } from '../../../common/types/es';
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';

export async function fetchLicenses(
esClient: ElasticsearchClient,
Expand Down Expand Up @@ -50,7 +50,11 @@ export async function fetchLicenses(
cluster_uuid: clusters.map((cluster) => cluster.clusterUuid),
},
},
createDatasetFilter('cluster_stats', 'cluster_stats', 'elasticsearch.cluster_stats'),
createDatasetFilter(
'cluster_stats',
'cluster_stats',
getElasticsearchDataset('cluster_stats')
),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('fetchLogstashVersions', () => {
should: [
{ term: { type: 'logstash_stats' } },
{ term: { 'metricset.name': 'node_stats' } },
{ term: { 'data_stream.dataset': 'logstash.node_stats' } },
{ term: { 'data_stream.dataset': 'logstash.stack_monitoring.node_stats' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { AlertCluster, AlertVersions } from '../../../common/types/alerts';
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getLogstashDataset } from '../cluster/get_index_patterns';

interface ESAggResponse {
key: string;
Expand Down Expand Up @@ -41,7 +41,7 @@ export async function fetchLogstashVersions(
cluster_uuid: clusters.map((cluster) => cluster.clusterUuid),
},
},
createDatasetFilter('logstash_stats', 'node_stats', 'logstash.node_stats'),
createDatasetFilter('logstash_stats', 'node_stats', getLogstashDataset('node_stats')),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('fetchMemoryUsageNodeStats', () => {
should: [
{ term: { type: 'node_stats' } },
{ term: { 'metricset.name': 'node_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.node_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.node_stats' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AlertCluster, AlertMemoryUsageNodeStats } from '../../../common/types/a
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';

export async function fetchMemoryUsageNodeStats(
esClient: ElasticsearchClient,
Expand Down Expand Up @@ -41,7 +41,7 @@ export async function fetchMemoryUsageNodeStats(
cluster_uuid: clustersIds,
},
},
createDatasetFilter('node_stats', 'node_stats', 'elasticsearch.node_stats'),
createDatasetFilter('node_stats', 'node_stats', getElasticsearchDataset('node_stats')),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe('fetchMissingMonitoringData', () => {
should: [
{ term: { type: 'node_stats' } },
{ term: { 'metricset.name': 'node_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.node_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.node_stats' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { get } from 'lodash';
import { AlertCluster, AlertMissingData } from '../../../common/types/alerts';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';
import { createDatasetFilter } from './create_dataset_query_filter';

interface ClusterBucketESResponse {
Expand Down Expand Up @@ -74,7 +74,7 @@ export async function fetchMissingMonitoringData(
cluster_uuid: clusters.map((cluster) => cluster.clusterUuid),
},
},
createDatasetFilter('node_stats', 'node_stats', 'elasticsearch.node_stats'),
createDatasetFilter('node_stats', 'node_stats', getElasticsearchDataset('node_stats')),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('fetchNodesFromClusterStats', () => {
should: [
{ term: { type: 'cluster_stats' } },
{ term: { 'metricset.name': 'cluster_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.cluster_stats' } },
{ term: { 'data_stream.dataset': 'elasticsearch.stack_monitoring.cluster_stats' } },
],
minimum_should_match: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ElasticsearchSource } from '../../../common/types/es';
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';

function formatNode(
nodes: NonNullable<NonNullable<ElasticsearchSource['cluster_state']>['nodes']> | undefined
Expand Down Expand Up @@ -54,7 +54,11 @@ export async function fetchNodesFromClusterStats(
query: {
bool: {
filter: [
createDatasetFilter('cluster_stats', 'cluster_stats', 'elasticsearch.cluster_stats'),
createDatasetFilter(
'cluster_stats',
'cluster_stats',
getElasticsearchDataset('cluster_stats')
),
{
range: {
timestamp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AlertCluster, AlertThreadPoolRejectionsStats } from '../../../common/ty
import { createDatasetFilter } from './create_dataset_query_filter';
import { Globals } from '../../static_globals';
import { CCS_REMOTE_PATTERN } from '../../../common/constants';
import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns';

const invalidNumberValue = (value: number) => {
return isNaN(value) || value === undefined || value === null;
Expand Down Expand Up @@ -67,7 +67,7 @@ export async function fetchThreadPoolRejectionStats(
cluster_uuid: clustersIds,
},
},
createDatasetFilter('node_stats', 'node_stats', 'elasticsearch.node_stats'),
createDatasetFilter('node_stats', 'node_stats', getElasticsearchDataset('node_stats')),
{
range: {
timestamp: {
Expand Down
Loading

0 comments on commit ac818d4

Please sign in to comment.