diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.test.ts index 23de6bd101673..fe02fc0a20f0e 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.test.ts @@ -38,7 +38,7 @@ describe('fetchCCReadExceptions', () => { await fetchCCRReadExceptions(esClient, 1643306331418, 1643309869056, 10000); expect(esClient.search).toHaveBeenCalledWith({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.ccr-*,metrics-elasticsearch.ccr-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.ccr-*,metrics-elasticsearch.stack_monitoring.ccr-*', filter_path: ['aggregations.remote_clusters.buckets'], body: { size: 0, @@ -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, }, @@ -137,6 +137,6 @@ describe('fetchCCReadExceptions', () => { await fetchCCRReadExceptions(esClient, 1643306331418, 1643309869056, 10000); // @ts-ignore - expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.ccr-*'); + expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.stack_monitoring.ccr-*'); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.ts index b39c1f744f0e1..118f2475b2e08 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.ts @@ -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'; @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.test.ts index d87792f347eb0..6035a99839207 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.test.ts @@ -61,7 +61,7 @@ describe('fetchClusterHealth', () => { ]); expect(esClient.search).toHaveBeenCalledWith({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.cluster_stats-*,metrics-elasticsearch.cluster_stats-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.cluster_stats-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*', filter_path: [ 'hits.hits._source.cluster_state.status', 'hits.hits._source.elasticsearch.cluster.stats.status', @@ -81,7 +81,11 @@ 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, }, @@ -108,6 +112,8 @@ describe('fetchClusterHealth', () => { await fetchClusterHealth(esClient, [{ clusterUuid: '1', clusterName: 'foo1' }]); // @ts-ignore - expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.cluster_stats-*'); + expect(params.index).toBe( + '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*' + ); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.ts index 94ead894b8dac..5a6b3f781a942 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.ts @@ -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( @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.test.ts index 0de2e5df531c8..2e6f2c1daf959 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.test.ts @@ -83,7 +83,7 @@ describe('fetchClusters', () => { await fetchClusters(esClient); expect(esClient.search).toHaveBeenCalledWith({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.cluster_stats-*,metrics-elasticsearch.cluster_stats-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.cluster_stats-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*', filter_path: [ 'hits.hits._source.cluster_settings.cluster.metadata.display_name', 'hits.hits._source.cluster_uuid', @@ -101,7 +101,11 @@ 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, }, @@ -125,6 +129,8 @@ describe('fetchClusters', () => { }); await fetchClusters(esClient); // @ts-ignore - expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.cluster_stats-*'); + expect(params.index).toBe( + '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*' + ); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.ts index 75af4906499e0..7cb8694adc0a6 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.ts @@ -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'; @@ -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, }, diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.test.ts index 5d7505c492da4..77c96e8b6138a 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.test.ts @@ -214,7 +214,7 @@ describe('fetchCpuUsageNodeStats', () => { await fetchCpuUsageNodeStats(esClient, clusters, startMs, endMs, size, filterQuery); expect(params).toStrictEqual({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.node_stats-*,metrics-elasticsearch.node_stats-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.node_stats-*,metrics-elasticsearch.stack_monitoring.node_stats-*', filter_path: ['aggregations'], body: { size: 0, @@ -227,7 +227,9 @@ 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, }, diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.ts index 090521a9714b5..1eb25510d8ba0 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.ts @@ -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'; @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_disk_usage_node_stats.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_disk_usage_node_stats.test.ts index 3437298e1957e..a292abf3720fd 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_disk_usage_node_stats.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_disk_usage_node_stats.test.ts @@ -89,7 +89,7 @@ describe('fetchDiskUsageNodeStats', () => { await fetchDiskUsageNodeStats(esClient, clusters, duration, size); expect(esClient.search).toHaveBeenCalledWith({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.node_stats-*,metrics-elasticsearch.node_stats-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.node_stats-*,metrics-elasticsearch.stack_monitoring.node_stats-*', filter_path: ['aggregations'], body: { size: 0, @@ -102,7 +102,9 @@ 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, }, @@ -150,6 +152,8 @@ describe('fetchDiskUsageNodeStats', () => { }); await fetchDiskUsageNodeStats(esClient, clusters, duration, size); // @ts-ignore - expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.node_stats-*'); + expect(params.index).toBe( + '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.node_stats-*' + ); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_disk_usage_node_stats.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_disk_usage_node_stats.ts index 8004a71b60efc..d19a70afd4781 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_disk_usage_node_stats.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_disk_usage_node_stats.ts @@ -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, @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.test.ts index 84bbfa54d0318..ff41b38c130ea 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.test.ts @@ -67,7 +67,7 @@ describe('fetchElasticsearchVersions', () => { await fetchElasticsearchVersions(esClient, clusters, size); expect(esClient.search).toHaveBeenCalledWith({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.cluster_stats-*,metrics-elasticsearch.cluster_stats-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.cluster_stats-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*', filter_path: [ 'hits.hits._source.cluster_stats.nodes.versions', 'hits.hits._source.elasticsearch.cluster.stats.nodes.versions', @@ -87,7 +87,11 @@ 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, }, @@ -110,6 +114,8 @@ describe('fetchElasticsearchVersions', () => { }); await fetchElasticsearchVersions(esClient, clusters, size); // @ts-ignore - expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.cluster_stats-*'); + expect(params.index).toBe( + '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*' + ); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.ts index 1146f0a91ae46..b310fb8d403a9 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.ts @@ -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, @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_index_shard_size.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_index_shard_size.test.ts index 19557dbec944d..7fac9550996d2 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_index_shard_size.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_index_shard_size.test.ts @@ -150,7 +150,7 @@ describe('fetchIndexShardSize', () => { await fetchIndexShardSize(esClient, clusters, threshold, shardIndexPatterns, size); expect(esClient.search).toHaveBeenCalledWith({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.index-*,metrics-elasticsearch.index-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.index-*,metrics-elasticsearch.stack_monitoring.index-*', filter_path: ['aggregations.clusters.buckets'], body: { size: 0, @@ -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, }, @@ -211,6 +211,6 @@ describe('fetchIndexShardSize', () => { }); await fetchIndexShardSize(esClient, clusters, threshold, shardIndexPatterns, size); // @ts-ignore - expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.index-*'); + expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.stack_monitoring.index-*'); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_index_shard_size.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_index_shard_size.ts index f3840f6f2c13b..b398cd386f733 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_index_shard_size.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_index_shard_size.ts @@ -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 }; @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_kibana_versions.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_kibana_versions.test.ts index 014441565a8fb..59a6453102d46 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_kibana_versions.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_kibana_versions.test.ts @@ -90,7 +90,7 @@ describe('fetchKibanaVersions', () => { await fetchKibanaVersions(esClient, clusters, size); expect(esClient.search).toHaveBeenCalledWith({ index: - '*:.monitoring-kibana-*,.monitoring-kibana-*,*:metrics-kibana.stats-*,metrics-kibana.stats-*', + '*:.monitoring-kibana-*,.monitoring-kibana-*,*:metrics-kibana.stack_monitoring.stats-*,metrics-kibana.stack_monitoring.stats-*', filter_path: ['aggregations'], body: { size: 0, @@ -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, }, @@ -146,6 +146,6 @@ describe('fetchKibanaVersions', () => { }); await fetchKibanaVersions(esClient, clusters, size); // @ts-ignore - expect(params.index).toBe('.monitoring-kibana-*,metrics-kibana.stats-*'); + expect(params.index).toBe('.monitoring-kibana-*,metrics-kibana.stack_monitoring.stats-*'); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_kibana_versions.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_kibana_versions.ts index 9f9431a3b4bfe..6aca1395916f2 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_kibana_versions.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_kibana_versions.ts @@ -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; @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.test.ts index 7434ffdcb79ce..7e5a8c1b4f920 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.test.ts @@ -81,7 +81,7 @@ describe('fetchLicenses', () => { await fetchLicenses(esClient, clusters); expect(params).toStrictEqual({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.cluster_stats-*,metrics-elasticsearch.cluster_stats-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.cluster_stats-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*', filter_path: [ 'hits.hits._source.license.*', 'hits.hits._source.elasticsearch.cluster.stats.license.*', @@ -101,7 +101,11 @@ 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, }, @@ -126,6 +130,8 @@ describe('fetchLicenses', () => { const clusters = [{ clusterUuid, clusterName }]; await fetchLicenses(esClient, clusters); // @ts-ignore - expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.cluster_stats-*'); + expect(params.index).toBe( + '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*' + ); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.ts index ea57536cd82bc..b5e0d0ce6d5ba 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.ts @@ -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, @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_logstash_versions.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_logstash_versions.test.ts index 523a18fc64f49..fbdd305547a16 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_logstash_versions.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_logstash_versions.test.ts @@ -95,7 +95,7 @@ describe('fetchLogstashVersions', () => { await fetchLogstashVersions(esClient, clusters, size); expect(params).toStrictEqual({ index: - '*:.monitoring-logstash-*,.monitoring-logstash-*,*:metrics-logstash.node_stats-*,metrics-logstash.node_stats-*', + '*:.monitoring-logstash-*,.monitoring-logstash-*,*:metrics-logstash.stack_monitoring.node_stats-*,metrics-logstash.stack_monitoring.node_stats-*', filter_path: ['aggregations'], body: { size: 0, @@ -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, }, @@ -151,6 +151,8 @@ describe('fetchLogstashVersions', () => { }); await fetchLogstashVersions(esClient, clusters, size); // @ts-ignore - expect(params.index).toBe('.monitoring-logstash-*,metrics-logstash.node_stats-*'); + expect(params.index).toBe( + '.monitoring-logstash-*,metrics-logstash.stack_monitoring.node_stats-*' + ); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_logstash_versions.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_logstash_versions.ts index 9b2a4efb6584e..02c5c810b2bc9 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_logstash_versions.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_logstash_versions.ts @@ -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; @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_memory_usage_node_stats.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_memory_usage_node_stats.test.ts index 06227c53b25fa..cf295c5fec3eb 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_memory_usage_node_stats.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_memory_usage_node_stats.test.ts @@ -117,7 +117,7 @@ describe('fetchMemoryUsageNodeStats', () => { await fetchMemoryUsageNodeStats(esClient, clusters, startMs, endMs, size); expect(params).toStrictEqual({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.node_stats-*,metrics-elasticsearch.node_stats-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.node_stats-*,metrics-elasticsearch.stack_monitoring.node_stats-*', filter_path: ['aggregations'], body: { size: 0, @@ -130,7 +130,9 @@ 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, }, @@ -168,6 +170,8 @@ describe('fetchMemoryUsageNodeStats', () => { }); await fetchMemoryUsageNodeStats(esClient, clusters, startMs, endMs, size); // @ts-ignore - expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.node_stats-*'); + expect(params.index).toBe( + '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.node_stats-*' + ); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_memory_usage_node_stats.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_memory_usage_node_stats.ts index da5d5c60815d2..f59b28d4f8ae8 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_memory_usage_node_stats.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_memory_usage_node_stats.ts @@ -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, @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_missing_monitoring_data.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_missing_monitoring_data.test.ts index a0c5e1b247243..0e6fea87904e5 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_missing_monitoring_data.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_missing_monitoring_data.test.ts @@ -176,7 +176,7 @@ describe('fetchMissingMonitoringData', () => { await fetchMissingMonitoringData(esClient, clusters, size, now, startMs); expect(params).toStrictEqual({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.node_stats-*,metrics-elasticsearch.node_stats-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.node_stats-*,metrics-elasticsearch.stack_monitoring.node_stats-*', filter_path: ['aggregations.clusters.buckets'], body: { size: 0, @@ -189,7 +189,9 @@ 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, }, @@ -240,6 +242,8 @@ describe('fetchMissingMonitoringData', () => { }); await fetchMissingMonitoringData(esClient, clusters, size, now, startMs); // @ts-ignore - expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.node_stats-*'); + expect(params.index).toBe( + '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.node_stats-*' + ); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_missing_monitoring_data.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_missing_monitoring_data.ts index 68a547580df08..2dd7e63617160 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_missing_monitoring_data.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_missing_monitoring_data.ts @@ -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 { @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_nodes_from_cluster_stats.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_nodes_from_cluster_stats.test.ts index fe03ffec6d137..33d18368f05c9 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_nodes_from_cluster_stats.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_nodes_from_cluster_stats.test.ts @@ -159,7 +159,7 @@ describe('fetchNodesFromClusterStats', () => { await fetchNodesFromClusterStats(esClient, clusters); expect(params).toStrictEqual({ index: - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.cluster_stats-*,metrics-elasticsearch.cluster_stats-*', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.cluster_stats-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*', filter_path: ['aggregations.clusters.buckets'], body: { size: 0, @@ -172,7 +172,11 @@ 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, }, @@ -210,6 +214,8 @@ describe('fetchNodesFromClusterStats', () => { }); await fetchNodesFromClusterStats(esClient, clusters); // @ts-ignore - expect(params.index).toBe('.monitoring-es-*,metrics-elasticsearch.cluster_stats-*'); + expect(params.index).toBe( + '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*' + ); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_nodes_from_cluster_stats.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_nodes_from_cluster_stats.ts index e84cf87cd3fbf..9c6ed778542c0 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_nodes_from_cluster_stats.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_nodes_from_cluster_stats.ts @@ -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['nodes']> | undefined @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_thread_pool_rejections_stats.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_thread_pool_rejections_stats.ts index 07cfa20c5ed4f..3ddad3f712571 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_thread_pool_rejections_stats.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_thread_pool_rejections_stats.ts @@ -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; @@ -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: { diff --git a/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.ts b/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.ts index f93c3f8ad7590..1cf073752754e 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.ts +++ b/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.ts @@ -10,7 +10,7 @@ import { TimeRange } from '../../../common/http_api/shared'; import { ElasticsearchResponse } from '../../../common/types/es'; import { Globals } from '../../static_globals'; import { Cluster, LegacyRequest } from '../../types'; -import { getNewIndexPatterns } from './get_index_patterns'; +import { getNewIndexPatterns, getKibanaDataset } from './get_index_patterns'; export interface FindSupportClusterRequestPayload { timeRange: TimeRange; @@ -53,7 +53,7 @@ async function findSupportedBasicLicenseCluster( bool: { should: [ { term: { type: 'kibana_stats' } }, - { term: { 'data_stream.dataset': 'kibana.stats' } }, + { term: { 'data_stream.dataset': getKibanaDataset(dataset) } }, ], }, }, diff --git a/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_license.ts b/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_license.ts index f785c85476254..d80cdd524973d 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_license.ts +++ b/x-pack/plugins/monitoring/server/lib/cluster/get_cluster_license.ts @@ -11,7 +11,7 @@ import { createQuery } from '../create_query'; import { ElasticsearchMetric } from '../metrics'; import { ElasticsearchResponse } from '../../../common/types/es'; import { LegacyRequest } from '../../types'; -import { getNewIndexPatterns } from './get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from './get_index_patterns'; import { Globals } from '../../static_globals'; // is this being used anywhere? not called within the app @@ -34,7 +34,7 @@ export function getClusterLicense(req: LegacyRequest, clusterUuid: string) { sort: { timestamp: { order: 'desc', unmapped_type: 'long' } }, query: createQuery({ type: dataset, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, clusterUuid, metric: ElasticsearchMetric.getMetricFields(), diff --git a/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_stats.ts b/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_stats.ts index 4ee5a5f8cffb4..eac8da778380e 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_stats.ts +++ b/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_stats.ts @@ -14,7 +14,7 @@ import { parseCrossClusterPrefix } from '../../../common/ccs_utils'; import { getClustersState } from './get_clusters_state'; import { ElasticsearchResponse, ElasticsearchModifiedSource } from '../../../common/types/es'; import { LegacyRequest } from '../../types'; -import { getNewIndexPatterns } from './get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from './get_index_patterns'; import { Globals } from '../../static_globals'; /** @@ -88,7 +88,7 @@ function fetchClusterStats(req: LegacyRequest, clusterUuid?: string, ccs?: strin body: { query: createQuery({ type: dataset, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/cluster/get_index_patterns.test.ts b/x-pack/plugins/monitoring/server/lib/cluster/get_index_patterns.test.ts index 60a03b3f3bcbd..188af22045650 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/get_index_patterns.test.ts +++ b/x-pack/plugins/monitoring/server/lib/cluster/get_index_patterns.test.ts @@ -7,7 +7,12 @@ import { DS_INDEX_PATTERN_TYPES } from '../../../common/constants'; import { MonitoringConfig } from '../..'; -import { getNewIndexPatterns } from './get_index_patterns'; +import { + getElasticsearchDataset, + getKibanaDataset, + getLogstashDataset, + getNewIndexPatterns, +} from './get_index_patterns'; const getConfigWithCcs = (ccsEnabled: boolean) => { return { @@ -23,174 +28,198 @@ const getConfigWithCcs = (ccsEnabled: boolean) => { }; type TestTuple = [DS_INDEX_PATTERN_TYPES | undefined, string]; -describe('getNewIndexPatterns', () => { - beforeEach(() => { - jest.resetModules(); - }); - it.each([ - [undefined, '.monitoring-es-*,metrics-elasticsearch.*-*'], - ['metrics', '.monitoring-es-*,metrics-elasticsearch.*-*'], - ['logs', 'filebeat-*,logs-elasticsearch.*-*'], - ])( - 'returns local elasticsearch index patterns when ccs is enabled (default true) and no ccs payload and type %s', - (type, expected) => { - const indexPatterns = getNewIndexPatterns({ - type, - config: getConfigWithCcs(true), - moduleType: 'elasticsearch', - }); - expect(indexPatterns).toBe(expected); - } - ); - it.each([ - [undefined, '.monitoring-es-8-*,metrics-elasticsearch.*-*'], - ['metrics', '.monitoring-es-8-*,metrics-elasticsearch.*-*'], - ['logs', 'filebeat-*,logs-elasticsearch.*-*'], - ])( - 'returns ecs only elasticsearch index patterns when specifying ecsLegacyOnly: true and type %s', - (type, expected) => { + +describe('getIndexPattern', () => { + describe('getNewIndexPatterns', () => { + beforeEach(() => { + jest.resetModules(); + }); + it.each([ + [undefined, '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.*-*'], + ['metrics', '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.*-*'], + ['logs', 'filebeat-*,logs-elasticsearch.*-*'], + ])( + 'returns local elasticsearch index patterns when ccs is enabled (default true) and no ccs payload and type %s', + (type, expected) => { + const indexPatterns = getNewIndexPatterns({ + type, + config: getConfigWithCcs(true), + moduleType: 'elasticsearch', + }); + expect(indexPatterns).toBe(expected); + } + ); + it.each([ + [undefined, '.monitoring-es-8-*,metrics-elasticsearch.stack_monitoring.*-*'], + ['metrics', '.monitoring-es-8-*,metrics-elasticsearch.stack_monitoring.*-*'], + ['logs', 'filebeat-*,logs-elasticsearch.*-*'], + ])( + 'returns ecs only elasticsearch index patterns when specifying ecsLegacyOnly: true and type %s', + (type, expected) => { + const indexPatterns = getNewIndexPatterns({ + type, + config: getConfigWithCcs(true), + moduleType: 'elasticsearch', + ecsLegacyOnly: true, + }); + expect(indexPatterns).toBe(expected); + } + ); + it.each([ + [undefined, '.monitoring-kibana-*,metrics-kibana.stack_monitoring.*-*'], + ['metrics', '.monitoring-kibana-*,metrics-kibana.stack_monitoring.*-*'], + ['logs', 'filebeat-*,logs-kibana.*-*'], + ])( + 'returns local kibana index patterns when ccs is enabled with no ccs payload and type %s', + (type, expected) => { + const indexPatterns = getNewIndexPatterns({ + type, + config: getConfigWithCcs(true), + moduleType: 'kibana', + }); + expect(indexPatterns).toBe(expected); + } + ); + it.each([ + [undefined, '.monitoring-logstash-*,metrics-logstash.stack_monitoring.*-*'], + ['metrics', '.monitoring-logstash-*,metrics-logstash.stack_monitoring.*-*'], + ['logs', 'filebeat-*,logs-logstash.*-*'], + ])( + 'returns logstash index patterns when ccs is enabled and no ccs payload and type %s', + (type, expected) => { + const indexPatterns = getNewIndexPatterns({ + type, + config: getConfigWithCcs(true), + moduleType: 'logstash', + }); + expect(indexPatterns).toBe(expected); + } + ); + it.each([ + [undefined, '.monitoring-beats-*,metrics-beats.stack_monitoring.*-*'], + ['metrics', '.monitoring-beats-*,metrics-beats.stack_monitoring.*-*'], + ['logs', 'filebeat-*,logs-beats.*-*'], + ])( + 'returns beats index patterns when ccs is enabled and no ccs payload and type %s', + (type, expected) => { + const indexPatterns = getNewIndexPatterns({ + type, + config: getConfigWithCcs(true), + moduleType: 'beats', + }); + expect(indexPatterns).toBe(expected); + } + ); + it.each([ + [undefined, '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*'], + ['metrics', '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.cluster_stats-*'], + ['logs', 'filebeat-*,logs-elasticsearch.cluster_stats-*'], + ])('returns elasticsearch index patterns with dataset and type %s', (type, expected) => { const indexPatterns = getNewIndexPatterns({ type, config: getConfigWithCcs(true), moduleType: 'elasticsearch', - ecsLegacyOnly: true, - }); - expect(indexPatterns).toBe(expected); - } - ); - it.each([ - [undefined, '.monitoring-kibana-*,metrics-kibana.*-*'], - ['metrics', '.monitoring-kibana-*,metrics-kibana.*-*'], - ['logs', 'filebeat-*,logs-kibana.*-*'], - ])( - 'returns local kibana index patterns when ccs is enabled with no ccs payload and type %s', - (type, expected) => { - const indexPatterns = getNewIndexPatterns({ - type, - config: getConfigWithCcs(true), - moduleType: 'kibana', + dataset: 'cluster_stats', }); expect(indexPatterns).toBe(expected); - } - ); - it.each([ - [undefined, '.monitoring-logstash-*,metrics-logstash.*-*'], - ['metrics', '.monitoring-logstash-*,metrics-logstash.*-*'], - ['logs', 'filebeat-*,logs-logstash.*-*'], - ])( - 'returns logstash index patterns when ccs is enabled and no ccs payload and type %s', - (type, expected) => { - const indexPatterns = getNewIndexPatterns({ - type, - config: getConfigWithCcs(true), - moduleType: 'logstash', - }); - expect(indexPatterns).toBe(expected); - } - ); - it.each([ - [undefined, '.monitoring-beats-*,metrics-beats.*-*'], - ['metrics', '.monitoring-beats-*,metrics-beats.*-*'], - ['logs', 'filebeat-*,logs-beats.*-*'], - ])( - 'returns beats index patterns when ccs is enabled and no ccs payload and type %s', - (type, expected) => { - const indexPatterns = getNewIndexPatterns({ - type, - config: getConfigWithCcs(true), - moduleType: 'beats', - }); - expect(indexPatterns).toBe(expected); - } - ); - it.each([ - [undefined, '.monitoring-es-*,metrics-elasticsearch.cluster_stats-*'], - ['metrics', '.monitoring-es-*,metrics-elasticsearch.cluster_stats-*'], - ['logs', 'filebeat-*,logs-elasticsearch.cluster_stats-*'], - ])('returns elasticsearch index patterns with dataset and type %s', (type, expected) => { - const indexPatterns = getNewIndexPatterns({ - type, - config: getConfigWithCcs(true), - moduleType: 'elasticsearch', - dataset: 'cluster_stats', }); - expect(indexPatterns).toBe(expected); - }); - it.each([ - [undefined, '.monitoring-es-*,metrics-elasticsearch.*-*'], - ['metrics', '.monitoring-es-*,metrics-elasticsearch.*-*'], - ['logs', 'filebeat-*,logs-elasticsearch.*-*'], - ])( - 'returns elasticsearch index patterns without ccs prefixes when ccs is disabled and type %s', - (type, expected) => { - const indexPatterns = getNewIndexPatterns({ - type, - config: getConfigWithCcs(false), - moduleType: 'elasticsearch', - }); - expect(indexPatterns).toBe(expected); - } - ); - it.each([ - [undefined, '.monitoring-es-*,metrics-elasticsearch.*-*'], - ['metrics', '.monitoring-es-*,metrics-elasticsearch.*-*'], - ['logs', 'filebeat-*,logs-elasticsearch.*-*'], - ])( - 'returns elasticsearch index patterns without ccs prefixes when ccs is disabled but ccs request payload has a value and type %s', - (type, expected) => { + it.each([ + [undefined, '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.*-*'], + ['metrics', '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.*-*'], + ['logs', 'filebeat-*,logs-elasticsearch.*-*'], + ])( + 'returns elasticsearch index patterns without ccs prefixes when ccs is disabled and type %s', + (type, expected) => { + const indexPatterns = getNewIndexPatterns({ + type, + config: getConfigWithCcs(false), + moduleType: 'elasticsearch', + }); + expect(indexPatterns).toBe(expected); + } + ); + it.each([ + [undefined, '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.*-*'], + ['metrics', '.monitoring-es-*,metrics-elasticsearch.stack_monitoring.*-*'], + ['logs', 'filebeat-*,logs-elasticsearch.*-*'], + ])( + 'returns elasticsearch index patterns without ccs prefixes when ccs is disabled but ccs request payload has a value and type %s', + (type, expected) => { + const indexPatterns = getNewIndexPatterns({ + type, + config: getConfigWithCcs(false), + ccs: 'myccs', + moduleType: 'elasticsearch', + }); + expect(indexPatterns).toBe(expected); + } + ); + it.each([ + [undefined, 'myccs:.monitoring-es-*,myccs:metrics-elasticsearch.stack_monitoring.*-*'], + ['metrics', 'myccs:.monitoring-es-*,myccs:metrics-elasticsearch.stack_monitoring.*-*'], + ['logs', 'myccs:filebeat-*,myccs:logs-elasticsearch.*-*'], + ])( + 'returns elasticsearch index patterns with custom ccs prefixes when ccs is enabled and ccs request payload has a value and type %s', + (type, expected) => { + const indexPatterns = getNewIndexPatterns({ + type, + config: getConfigWithCcs(true), + ccs: 'myccs', + moduleType: 'elasticsearch', + }); + expect(indexPatterns).toBe(expected); + } + ); + it.each([ + [ + undefined, + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.*-*,metrics-elasticsearch.stack_monitoring.*-*', + ], + [ + 'metrics', + '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.stack_monitoring.*-*,metrics-elasticsearch.stack_monitoring.*-*', + ], + ['logs', '*:filebeat-*,filebeat-*,*:logs-elasticsearch.*-*,logs-elasticsearch.*-*'], + ])( + 'returns elasticsearch index patterns with ccs prefixes and local index patterns when ccs is enabled and ccs request payload value is * and type %s', + (type, expected) => { + const indexPatterns = getNewIndexPatterns({ + type, + config: getConfigWithCcs(true), + ccs: '*', + moduleType: 'elasticsearch', + }); + expect(indexPatterns).toBe(expected); + } + ); + + it('returns logs-* index patterns without dataset and namespace', () => { const indexPatterns = getNewIndexPatterns({ - type, + type: 'logs', config: getConfigWithCcs(false), - ccs: 'myccs', - moduleType: 'elasticsearch', - }); - expect(indexPatterns).toBe(expected); - } - ); - it.each([ - [undefined, 'myccs:.monitoring-es-*,myccs:metrics-elasticsearch.*-*'], - ['metrics', 'myccs:.monitoring-es-*,myccs:metrics-elasticsearch.*-*'], - ['logs', 'myccs:filebeat-*,myccs:logs-elasticsearch.*-*'], - ])( - 'returns elasticsearch index patterns with custom ccs prefixes when ccs is enabled and ccs request payload has a value and type %s', - (type, expected) => { - const indexPatterns = getNewIndexPatterns({ - type, - config: getConfigWithCcs(true), - ccs: 'myccs', - moduleType: 'elasticsearch', }); - expect(indexPatterns).toBe(expected); - } - ); - it.each([ - [ - undefined, - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.*-*,metrics-elasticsearch.*-*', - ], - [ - 'metrics', - '*:.monitoring-es-*,.monitoring-es-*,*:metrics-elasticsearch.*-*,metrics-elasticsearch.*-*', - ], - ['logs', '*:filebeat-*,filebeat-*,*:logs-elasticsearch.*-*,logs-elasticsearch.*-*'], - ])( - 'returns elasticsearch index patterns with ccs prefixes and local index patterns when ccs is enabled and ccs request payload value is * and type %s', - (type, expected) => { - const indexPatterns = getNewIndexPatterns({ - type, - config: getConfigWithCcs(true), - ccs: '*', - moduleType: 'elasticsearch', - }); - expect(indexPatterns).toBe(expected); - } - ); + expect(indexPatterns).toBe('filebeat-*,logs-*.*-*'); + }); + }); + + describe('getElasticsearchDataset', () => { + it('returns elasticsearch metrics dataset', () => { + const indexPatterns = getElasticsearchDataset('cluster_stats'); + expect(indexPatterns).toBe('elasticsearch.stack_monitoring.cluster_stats'); + }); + }); + + describe('getKibanaDataset', () => { + it('returns kibana metrics dataset', () => { + const indexPatterns = getKibanaDataset('stats'); + expect(indexPatterns).toBe('kibana.stack_monitoring.stats'); + }); + }); - it('returns logs-* index patterns without dataset and namespace', () => { - const indexPatterns = getNewIndexPatterns({ - type: 'logs', - config: getConfigWithCcs(false), + describe('getLogstashDataset', () => { + it('returns logstash metrics dataset', () => { + const indexPatterns = getLogstashDataset('node_stats'); + expect(indexPatterns).toBe('logstash.stack_monitoring.node_stats'); }); - expect(indexPatterns).toBe('filebeat-*,logs-*.*-*'); }); }); diff --git a/x-pack/plugins/monitoring/server/lib/cluster/get_index_patterns.ts b/x-pack/plugins/monitoring/server/lib/cluster/get_index_patterns.ts index 1b7668c585089..5d55031ec8d04 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/get_index_patterns.ts +++ b/x-pack/plugins/monitoring/server/lib/cluster/get_index_patterns.ts @@ -123,7 +123,11 @@ export function getDsIndexPattern({ config, ccs, }: CommonIndexPatternArgs & { type?: string }): string { - const datasetsPattern = `${moduleType ?? '*'}.${dataset ?? '*'}`; + const datasetsPattern = + type === DS_INDEX_PATTERN_METRICS + ? getMetricsDatasetPattern(moduleType, dataset) + : getLogsDatasetPattern(moduleType, dataset); + return prefixIndexPatternWithCcs(config, `${type}-${datasetsPattern}-${namespace ?? '*'}`, ccs); } @@ -150,6 +154,29 @@ export function getNewIndexPatterns(indexPattern: IndexPatternArgs): string { return `${legacyIndexPattern},${dsIndexPattern}`; } +const getDataset = (moduleType: INDEX_PATTERN_TYPES) => (dataset: string) => + getMetricsDatasetPattern(moduleType, dataset); + +export const getElasticsearchDataset = getDataset('elasticsearch'); +export const getKibanaDataset = getDataset('kibana'); +export const getLogstashDataset = getDataset('logstash'); + +function buildDatasetPattern( + moduleType?: INDEX_PATTERN_TYPES, + dataset?: string, + prefix?: 'stack_monitoring' +) { + return `${moduleType ?? '*'}.${prefix ? `${prefix}.` : ''}${dataset ?? '*'}`; +} + +function getMetricsDatasetPattern(moduleType?: INDEX_PATTERN_TYPES, dataset?: string) { + return buildDatasetPattern(moduleType, dataset, 'stack_monitoring'); +} + +function getLogsDatasetPattern(moduleType?: INDEX_PATTERN_TYPES, dataset?: string) { + return buildDatasetPattern(moduleType, dataset); +} + const isLogIndexPattern = (args: IndexPatternArgs): args is LogsIndexPatternArgs => { return (args as LogsIndexPatternArgs).type === 'logs'; }; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/ccr.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/ccr.ts index 7cad6a66416ca..ba27521cfe1de 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/ccr.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/ccr.ts @@ -12,7 +12,7 @@ import { ElasticsearchMetric } from '../metrics'; import { createQuery } from '../create_query'; import { ElasticsearchResponse } from '../../../common/types/es'; import { LegacyRequest } from '../../types'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns'; import { Globals } from '../../static_globals'; export async function checkCcrEnabled(req: LegacyRequest, ccs: string) { @@ -38,7 +38,7 @@ export async function checkCcrEnabled(req: LegacyRequest, ccs: string) { body: { query: createQuery({ type: dataset, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts index 2364e71ab1094..ecb7fb877f2f9 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts @@ -17,7 +17,7 @@ import { ElasticsearchResponseHit, } from '../../../common/types/es'; import { LegacyRequest } from '../../types'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns'; import { Globals } from '../../static_globals'; /** @@ -136,7 +136,7 @@ export async function getLastRecovery(req: LegacyRequest, size: number) { sort: { timestamp: { order: 'desc', unmapped_type: 'long' } }, query: createQuery({ type: dataset, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.ts index d2fdba54e1d60..05d1390545f87 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/get_ml_jobs.ts @@ -13,7 +13,7 @@ import { ElasticsearchMetric } from '../metrics'; import { ML_SUPPORTED_LICENSES } from '../../../common/constants'; import { ElasticsearchResponse } from '../../../common/types/es'; import { LegacyRequest, Cluster } from '../../types'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../cluster/get_index_patterns'; import { Globals } from '../../static_globals'; /* @@ -80,7 +80,7 @@ export function getMlJobs(req: LegacyRequest) { collapse: { field: 'job_stats.job_id' }, query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, start, end, @@ -126,7 +126,7 @@ export function getMlJobsForCluster(req: LegacyRequest, cluster: Cluster, ccs: s body: { query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.ts index 9602b99b3377b..c5ad0ed9d4c64 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_index_summary.ts @@ -13,7 +13,7 @@ import { createQuery } from '../../create_query'; import { ElasticsearchMetric } from '../../metrics'; import { ElasticsearchResponse } from '../../../../common/types/es'; import { LegacyRequest } from '../../../types'; -import { getNewIndexPatterns } from '../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../../cluster/get_index_patterns'; import { Globals } from '../../../static_globals'; export function handleResponse(shardStats: any, indexUuid: string) { @@ -101,7 +101,7 @@ export function getIndexSummary( sort: { timestamp: { order: 'desc', unmapped_type: 'long' } }, query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.ts index 1ec6fb476b6ce..b8703053306c7 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/indices/get_indices.ts @@ -17,7 +17,7 @@ import { calculateRate } from '../../calculate_rate'; import { getUnassignedShards } from '../shards'; import { ElasticsearchResponse } from '../../../../common/types/es'; import { LegacyRequest } from '../../../types'; -import { getNewIndexPatterns } from '../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../../cluster/get_index_patterns'; import { Globals } from '../../../static_globals'; export function handleResponse( @@ -155,7 +155,7 @@ export function buildGetIndicesQuery( body: { query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.ts index ba9573d3fe956..23b958b7a1053 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.ts @@ -22,7 +22,7 @@ import { ElasticsearchLegacySource, } from '../../../../common/types/es'; import { LegacyRequest } from '../../../types'; -import { getNewIndexPatterns } from '../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../../cluster/get_index_patterns'; import { Globals } from '../../../static_globals'; export function handleResponse( @@ -133,7 +133,7 @@ export function getNodeSummary( sort: { timestamp: { order: 'desc', unmapped_type: 'long' } }, query: createQuery({ type: dataset, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_node_ids.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_node_ids.ts index 58f4a0b8aca56..374705c591906 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_node_ids.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_node_ids.ts @@ -10,7 +10,7 @@ import { get } from 'lodash'; import { ElasticsearchMetric } from '../../../metrics'; import { createQuery } from '../../../create_query'; import { LegacyRequest, Bucket } from '../../../../types'; -import { getNewIndexPatterns } from '../../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../../../cluster/get_index_patterns'; import { Globals } from '../../../../static_globals'; export async function getNodeIds( @@ -38,7 +38,7 @@ export async function getNodeIds( body: { query: createQuery({ type: dataset, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.ts index 2793fe9317d71..1ab078870eb70 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_nodes.ts @@ -14,7 +14,7 @@ import { handleResponse } from './handle_response'; import { LISTING_METRICS_NAMES, LISTING_METRICS_PATHS } from './nodes_listing_metrics'; import { LegacyRequest } from '../../../../types'; import { ElasticsearchModifiedSource } from '../../../../../common/types/es'; -import { getNewIndexPatterns } from '../../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../../../cluster/get_index_patterns'; import { Globals } from '../../../../static_globals'; /* Run an aggregation on node_stats to get stat data for the selected time @@ -83,7 +83,7 @@ export async function getNodes( body: { query: createQuery({ type: dataset, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.ts index 68d68dba2f83e..fb9b16aa64fc0 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_indices_unassigned_shard_stats.ts @@ -14,7 +14,7 @@ import { ElasticsearchMetric } from '../../metrics'; import { calculateIndicesTotals } from './calculate_shard_stat_indices_totals'; import { LegacyRequest } from '../../../types'; import { ElasticsearchModifiedSource } from '../../../../common/types/es'; -import { getNewIndexPatterns } from '../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../../cluster/get_index_patterns'; import { Globals } from '../../../static_globals'; async function getUnassignedShardData(req: LegacyRequest, cluster: ElasticsearchModifiedSource) { @@ -52,7 +52,7 @@ async function getUnassignedShardData(req: LegacyRequest, cluster: Elasticsearch sort: { timestamp: { order: 'desc', unmapped_type: 'long' } }, query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, clusterUuid: cluster.cluster_uuid ?? cluster.elasticsearch?.cluster?.id, metric, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.ts index 0c77cd92d3a07..99e4f2df61418 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_nodes_shard_count.ts @@ -12,7 +12,7 @@ import { createQuery } from '../../create_query'; import { ElasticsearchMetric } from '../../metrics'; import { LegacyRequest } from '../../../types'; import { ElasticsearchModifiedSource } from '../../../../common/types/es'; -import { getNewIndexPatterns } from '../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../../cluster/get_index_patterns'; import { Globals } from '../../../static_globals'; async function getShardCountPerNode(req: LegacyRequest, cluster: ElasticsearchModifiedSource) { @@ -49,7 +49,7 @@ async function getShardCountPerNode(req: LegacyRequest, cluster: ElasticsearchMo sort: { timestamp: { order: 'desc', unmapped_type: 'long' } }, query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, clusterUuid: cluster.cluster_uuid ?? cluster.elasticsearch?.cluster?.id, metric, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.ts index 16189b0983aca..4ce2ae97a5556 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_allocation.ts @@ -11,7 +11,7 @@ import { createQuery } from '../../create_query'; import { ElasticsearchMetric } from '../../metrics'; import { ElasticsearchResponse, ElasticsearchLegacySource } from '../../../../common/types/es'; import { LegacyRequest } from '../../../types'; -import { getNewIndexPatterns } from '../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../../cluster/get_index_patterns'; import { Globals } from '../../../static_globals'; export function handleResponse(response: ElasticsearchResponse) { @@ -116,7 +116,7 @@ export function getShardAllocation( body: { query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, clusterUuid, metric, diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stats.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stats.ts index df60ce3ffecef..6a78ddb6edb1f 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stats.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/shards/get_shard_stats.ts @@ -9,7 +9,7 @@ import { get } from 'lodash'; import { ElasticsearchModifiedSource, ElasticsearchResponse } from '../../../../common/types/es'; import { Globals } from '../../../static_globals'; import { LegacyRequest } from '../../../types'; -import { getNewIndexPatterns } from '../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getElasticsearchDataset } from '../../cluster/get_index_patterns'; import { createQuery } from '../../create_query'; import { ElasticsearchMetric } from '../../metrics'; import { calculateIndicesTotals } from './calculate_shard_stat_indices_totals'; @@ -114,7 +114,7 @@ export function getShardStats( sort: { timestamp: { order: 'desc', unmapped_type: 'long' } }, query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getElasticsearchDataset(dataset), metricset: dataset, clusterUuid: cluster.cluster_uuid ?? cluster.elasticsearch?.cluster?.id, metric, diff --git a/x-pack/plugins/monitoring/server/lib/kibana/get_kibana_info.ts b/x-pack/plugins/monitoring/server/lib/kibana/get_kibana_info.ts index e587c7ba5a015..db83fe017dfb8 100644 --- a/x-pack/plugins/monitoring/server/lib/kibana/get_kibana_info.ts +++ b/x-pack/plugins/monitoring/server/lib/kibana/get_kibana_info.ts @@ -9,7 +9,7 @@ import { merge } from 'lodash'; import { ElasticsearchResponse } from '../../../common/types/es'; import { Globals } from '../../static_globals'; import { LegacyRequest } from '../../types'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getKibanaDataset } from '../cluster/get_index_patterns'; import { MissingRequiredError } from '../error_missing_required'; import { buildKibanaInfo } from './build_kibana_info'; import { isKibanaStatusStale } from './is_kibana_status_stale'; @@ -65,7 +65,7 @@ export function getKibanaInfo( body: { query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getKibanaDataset(dataset), metricset: dataset, clusterUuid, uuid: kibanaUuid, diff --git a/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas.ts b/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas.ts index 69cda62ae852c..84c3952e32f82 100644 --- a/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas.ts +++ b/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas.ts @@ -9,7 +9,7 @@ import moment from 'moment'; import { ElasticsearchResponse, ElasticsearchResponseHit } from '../../../common/types/es'; import { Globals } from '../../static_globals'; import { LegacyRequest } from '../../types'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getKibanaDataset } from '../cluster/get_index_patterns'; import { createQuery } from '../create_query'; import { KibanaMetric } from '../metrics'; import { buildKibanaInfo, KibanaInfo } from './build_kibana_info'; @@ -70,7 +70,7 @@ export async function getKibanas(req: LegacyRequest, { clusterUuid }: { clusterU body: { query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getKibanaDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.ts b/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.ts index 17ccff4a9ea7d..8d8e4539923d6 100644 --- a/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.ts +++ b/x-pack/plugins/monitoring/server/lib/kibana/get_kibanas_for_clusters.ts @@ -8,7 +8,7 @@ import { chain, find } from 'lodash'; import { Globals } from '../../static_globals'; import { Bucket, Cluster, LegacyRequest } from '../../types'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getKibanaDataset } from '../cluster/get_index_patterns'; import { createQuery } from '../create_query'; import { KibanaClusterMetric } from '../metrics'; import { isKibanaStatusStale } from './is_kibana_status_stale'; @@ -52,7 +52,7 @@ export function getKibanasForClusters(req: LegacyRequest, clusters: Cluster[], c body: { query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getKibanaDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/kibana/rules/get_cluster_rule_data_for_clusters.ts b/x-pack/plugins/monitoring/server/lib/kibana/rules/get_cluster_rule_data_for_clusters.ts index 2a2b39259beeb..8293e70a6b157 100644 --- a/x-pack/plugins/monitoring/server/lib/kibana/rules/get_cluster_rule_data_for_clusters.ts +++ b/x-pack/plugins/monitoring/server/lib/kibana/rules/get_cluster_rule_data_for_clusters.ts @@ -5,7 +5,7 @@ * 2.0. */ import { Cluster, LegacyRequest } from '../../../types'; -import { getNewIndexPatterns } from '../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getKibanaDataset } from '../../cluster/get_index_patterns'; import { Globals } from '../../../static_globals'; import { createQuery } from '../../create_query'; import { KibanaClusterRuleMetric } from '../../metrics'; @@ -39,7 +39,7 @@ export async function getClusterRuleDataForClusters( body: { query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getKibanaDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/kibana/rules/get_instance_rule_data_for_clusters.ts b/x-pack/plugins/monitoring/server/lib/kibana/rules/get_instance_rule_data_for_clusters.ts index c2c420952151e..dc2adedbd6e9d 100644 --- a/x-pack/plugins/monitoring/server/lib/kibana/rules/get_instance_rule_data_for_clusters.ts +++ b/x-pack/plugins/monitoring/server/lib/kibana/rules/get_instance_rule_data_for_clusters.ts @@ -5,7 +5,7 @@ * 2.0. */ import { Cluster, LegacyRequest } from '../../../types'; -import { getNewIndexPatterns } from '../../cluster/get_index_patterns'; +import { getNewIndexPatterns, getKibanaDataset } from '../../cluster/get_index_patterns'; import { Globals } from '../../../static_globals'; import { createQuery } from '../../create_query'; import { KibanaClusterRuleMetric } from '../../metrics'; @@ -39,7 +39,7 @@ export async function getInstanceRuleDataForClusters( body: { query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getKibanaDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.ts b/x-pack/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.ts index 8e4c45b81f7a9..d3b6cee1e4769 100644 --- a/x-pack/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.ts +++ b/x-pack/plugins/monitoring/server/lib/logstash/get_logstash_for_clusters.ts @@ -10,7 +10,7 @@ import { LegacyRequest, Cluster, Bucket } from '../../types'; import { LOGSTASH } from '../../../common/constants'; import { createQuery } from '../create_query'; import { LogstashClusterMetric } from '../metrics'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getLogstashDataset } from '../cluster/get_index_patterns'; import { Globals } from '../../static_globals'; const { MEMORY, PERSISTED } = LOGSTASH.QUEUE_TYPES; @@ -67,7 +67,7 @@ export function getLogstashForClusters( body: { query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getLogstashDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/logstash/get_nodes.ts b/x-pack/plugins/monitoring/server/lib/logstash/get_nodes.ts index 584a82b6828de..69c37edf33299 100644 --- a/x-pack/plugins/monitoring/server/lib/logstash/get_nodes.ts +++ b/x-pack/plugins/monitoring/server/lib/logstash/get_nodes.ts @@ -11,7 +11,7 @@ import { calculateAvailability } from '../calculate_availability'; import { LogstashMetric } from '../metrics'; import { LegacyRequest } from '../../types'; import { ElasticsearchResponse } from '../../../common/types/es'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getLogstashDataset } from '../cluster/get_index_patterns'; import { Globals } from '../../static_globals'; interface Logstash { @@ -90,7 +90,7 @@ export async function getNodes(req: LegacyRequest, { clusterUuid }: { clusterUui body: { query: createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getLogstashDataset(dataset), metricset: dataset, filters, start, diff --git a/x-pack/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.ts b/x-pack/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.ts index 517d71de25d6b..38f716cb35867 100644 --- a/x-pack/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.ts +++ b/x-pack/plugins/monitoring/server/lib/logstash/get_paginated_pipelines.ts @@ -11,6 +11,7 @@ import { getLogstashPipelineIds } from './get_pipeline_ids'; import { sortPipelines } from './sort_pipelines'; import { paginate } from '../pagination/paginate'; import { getMetrics } from '../details/get_metrics'; +import { getLogstashDataset } from '../cluster/get_index_patterns'; import { LegacyRequest, Pipeline, @@ -143,7 +144,7 @@ async function getPaginatedThroughputData( { bool: { should: [ - { term: { 'data_stream.dataset': `${moduleType}.${dataset}` } }, + { term: { 'data_stream.dataset': getLogstashDataset(dataset) } }, { term: { 'metricset.name': dataset } }, { term: { @@ -203,7 +204,7 @@ async function getPaginatedNodesData( { bool: { should: [ - { term: { 'data_stream.dataset': `${moduleType}.${dataset}` } }, + { term: { 'data_stream.dataset': getLogstashDataset(dataset) } }, { term: { 'metricset.name': dataset } }, { term: { type: 'logstash_stats' } }, ], @@ -276,7 +277,7 @@ async function getThroughputPipelines( { bool: { should: [ - { term: { 'data_stream.dataset': `${moduleType}.${dataset}` } }, + { term: { 'data_stream.dataset': getLogstashDataset(dataset) } }, { term: { 'metricset.name': dataset } }, { term: { @@ -316,7 +317,7 @@ async function getNodePipelines( { bool: { should: [ - { term: { 'data_stream.dataset': `${moduleType}.${dataset}` } }, + { term: { 'data_stream.dataset': getLogstashDataset(dataset) } }, { term: { 'metricset.name': dataset } }, { term: { type: 'logstash_stats' } }, ], diff --git a/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_state_document.ts b/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_state_document.ts index 6c2504efe29ff..657e30061e2f2 100644 --- a/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_state_document.ts +++ b/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_state_document.ts @@ -9,7 +9,7 @@ import { createQuery } from '../create_query'; import { LogstashMetric } from '../metrics'; import { LegacyRequest, PipelineVersion } from '../../types'; import { ElasticsearchResponse } from '../../../common/types/es'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getLogstashDataset } from '../cluster/get_index_patterns'; import { Globals } from '../../static_globals'; export async function getPipelineStateDocument({ @@ -45,7 +45,7 @@ export async function getPipelineStateDocument({ // that could result in us being unable to render the graph // Use the logstash_stats documents to determine whether the instance is up/down type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getLogstashDataset(dataset), metricset: dataset, metric: LogstashMetric.getMetricFields(), clusterUuid, diff --git a/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.ts b/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.ts index 0165f84e48d6e..6def399767d48 100644 --- a/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.ts +++ b/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_stats_aggregation.ts @@ -6,7 +6,7 @@ */ import { LegacyRequest, PipelineVersion } from '../../types'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getLogstashDataset } from '../cluster/get_index_patterns'; import { createQuery } from '../create_query'; import { LogstashMetric } from '../metrics'; import { Globals } from '../../static_globals'; @@ -206,11 +206,10 @@ export function getPipelineStatsAggregation({ const dataset = 'node_stats'; const type = 'logstash_stats'; - const moduleType = 'logstash'; const query = createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getLogstashDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_versions.ts b/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_versions.ts index 6a9f6824e9943..e201d6bd346dc 100644 --- a/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_versions.ts +++ b/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_versions.ts @@ -8,7 +8,7 @@ import { get, orderBy } from 'lodash'; import { createQuery } from '../create_query'; import { LogstashMetric } from '../metrics'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getLogstashDataset } from '../cluster/get_index_patterns'; import { Globals } from '../../static_globals'; import { LegacyRequest, PipelineVersion } from '../../types'; import { mergePipelineVersions } from './merge_pipeline_versions'; @@ -119,7 +119,7 @@ function fetchPipelineVersions({ ]; const query = createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getLogstashDataset(dataset), metricset: dataset, metric: LogstashMetric.getMetricFields(), clusterUuid, diff --git a/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.ts b/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.ts index a13f9abbcb728..719cdd0f17232 100644 --- a/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.ts +++ b/x-pack/plugins/monitoring/server/lib/logstash/get_pipeline_vertex_stats_aggregation.ts @@ -6,7 +6,7 @@ */ import { LegacyRequest, PipelineVersion } from '../../types'; -import { getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { getNewIndexPatterns, getLogstashDataset } from '../cluster/get_index_patterns'; import { createQuery } from '../create_query'; import { LogstashMetric } from '../metrics'; import { Globals } from '../../static_globals'; @@ -256,13 +256,12 @@ export function getPipelineVertexStatsAggregation({ const start = version.firstSeen; const end = version.lastSeen; - const moduleType = 'logstash'; const dataset = 'node_stats'; const type = 'logstash_stats'; const query = createQuery({ type, - dsDataset: `${moduleType}.${dataset}`, + dsDataset: getLogstashDataset(dataset), metricset: dataset, start, end, diff --git a/x-pack/plugins/monitoring/server/lib/standalone_clusters/has_standalone_clusters.ts b/x-pack/plugins/monitoring/server/lib/standalone_clusters/has_standalone_clusters.ts index 195c74ce20f7e..0b156f34d0670 100644 --- a/x-pack/plugins/monitoring/server/lib/standalone_clusters/has_standalone_clusters.ts +++ b/x-pack/plugins/monitoring/server/lib/standalone_clusters/has_standalone_clusters.ts @@ -10,7 +10,11 @@ import { get } from 'lodash'; import { LegacyRequest } from '../../types'; import { standaloneClusterFilter } from '.'; import { Globals } from '../../static_globals'; -import { getLegacyIndexPattern, getNewIndexPatterns } from '../cluster/get_index_patterns'; +import { + getLegacyIndexPattern, + getNewIndexPatterns, + getLogstashDataset, +} from '../cluster/get_index_patterns'; export async function hasStandaloneClusters(req: LegacyRequest, ccs: string) { const lsIndexPatterns = getNewIndexPatterns({ @@ -47,7 +51,7 @@ export async function hasStandaloneClusters(req: LegacyRequest, ccs: string) { }, { terms: { - 'data_stream.dataset': ['logstash.node', 'logstash.node_stats'], + 'data_stream.dataset': [getLogstashDataset('node'), getLogstashDataset('node_stats')], }, }, ], diff --git a/x-pack/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr_shard.ts b/x-pack/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr_shard.ts index 797b8addd02cf..a456fefb39ff7 100644 --- a/x-pack/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr_shard.ts +++ b/x-pack/plugins/monitoring/server/routes/api/v1/elasticsearch/ccr_shard.ts @@ -12,7 +12,10 @@ import { } from '../../../../../common/http_api/elasticsearch'; import { TimeRange } from '../../../../../common/http_api/shared'; import { ElasticsearchResponse } from '../../../../../common/types/es'; -import { getNewIndexPatterns } from '../../../../lib/cluster/get_index_patterns'; +import { + getNewIndexPatterns, + getElasticsearchDataset, +} from '../../../../lib/cluster/get_index_patterns'; import { createValidationFunction } from '../../../../lib/create_route_validation_function'; import { getMetrics } from '../../../../lib/details/get_metrics'; import { handleError } from '../../../../lib/errors/handle_error'; @@ -108,7 +111,7 @@ export function ccrShardRoute(server: MonitoringCore) { { bool: { should: [ - { term: { 'data_stream.dataset': { value: `${moduleType}.${dataset}` } } }, + { term: { 'data_stream.dataset': { value: getElasticsearchDataset(dataset) } } }, { term: { 'metricset.name': { diff --git a/x-pack/plugins/monitoring/server/routes/api/v1/kibana/overview.ts b/x-pack/plugins/monitoring/server/routes/api/v1/kibana/overview.ts index 7330ccd27d51a..936dbd95c1727 100644 --- a/x-pack/plugins/monitoring/server/routes/api/v1/kibana/overview.ts +++ b/x-pack/plugins/monitoring/server/routes/api/v1/kibana/overview.ts @@ -16,6 +16,7 @@ import { } from '../../../../../common/http_api/kibana'; import { createValidationFunction } from '../../../../lib/create_route_validation_function'; import { MonitoringCore } from '../../../../types'; +import { getKibanaDataset } from '../../../../lib/cluster/get_index_patterns'; export function kibanaOverviewRoute(server: MonitoringCore) { const validateParams = createValidationFunction(postKibanaOverviewRequestParamsRT); @@ -38,7 +39,7 @@ export function kibanaOverviewRoute(server: MonitoringCore) { (accum: Array<{ term: { [key: string]: string } }>, dsDataset) => { accum.push( ...[ - { term: { 'data_stream.dataset': `${moduleType}.${dsDataset}` } }, + { term: { 'data_stream.dataset': getKibanaDataset(dsDataset) } }, { term: { 'metricset.name': dsDataset } }, { term: { type: `kibana_${dsDataset}` } }, ] diff --git a/x-pack/plugins/monitoring/server/routes/api/v1/logstash/node.ts b/x-pack/plugins/monitoring/server/routes/api/v1/logstash/node.ts index 7f5fea6dc78e3..4c0088b4112e6 100644 --- a/x-pack/plugins/monitoring/server/routes/api/v1/logstash/node.ts +++ b/x-pack/plugins/monitoring/server/routes/api/v1/logstash/node.ts @@ -19,6 +19,7 @@ import { import { metricSets } from './metric_set_node'; import { MonitoringCore } from '../../../../types'; import { createValidationFunction } from '../../../../lib/create_route_validation_function'; +import { getLogstashDataset } from '../../../../lib/cluster/get_index_patterns'; const { advanced: metricSetAdvanced, overview: metricSetOverview } = metricSets; @@ -60,14 +61,13 @@ export function logstashNodeRoute(server: MonitoringCore) { } try { - const moduleType = 'logstash'; const dsDataset = 'node_stats'; const [metrics, nodeSummary] = await Promise.all([ getMetrics(req, 'logstash', metricSet, [ { bool: { should: [ - { term: { 'data_stream.dataset': `${moduleType}.${dsDataset}` } }, + { term: { 'data_stream.dataset': getLogstashDataset(dsDataset) } }, { term: { 'metricset.name': dsDataset } }, { term: { type: 'logstash_stats' } }, ], diff --git a/x-pack/plugins/monitoring/server/routes/api/v1/logstash/overview.ts b/x-pack/plugins/monitoring/server/routes/api/v1/logstash/overview.ts index 73cff6ad35ac8..8937c1dc7a9ad 100644 --- a/x-pack/plugins/monitoring/server/routes/api/v1/logstash/overview.ts +++ b/x-pack/plugins/monitoring/server/routes/api/v1/logstash/overview.ts @@ -15,6 +15,7 @@ import { handleError } from '../../../../lib/errors'; import { metricSet } from './metric_set_overview'; import { MonitoringCore } from '../../../../types'; import { createValidationFunction } from '../../../../lib/create_route_validation_function'; +import { getLogstashDataset } from '../../../../lib/cluster/get_index_patterns'; export function logstashOverviewRoute(server: MonitoringCore) { const validateParams = createValidationFunction(postLogstashOverviewRequestParamsRT); @@ -38,7 +39,7 @@ export function logstashOverviewRoute(server: MonitoringCore) { { bool: { should: [ - { term: { 'data_stream.dataset': `${moduleType}.${dsDataset}` } }, + { term: { 'data_stream.dataset': getLogstashDataset(dsDataset) } }, { term: { 'metricset.name': dsDataset } }, { term: { type: 'logstash_stats' } }, ],