diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aa2ca6aca..c0c9deca84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ All notable changes to the Wazuh app project will be documented in this file. ### Changed -- Removed embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120) [#6235](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6235) [#6254](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6254) [#6285](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6285) [#6288](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6288) [#6290](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6290) [#6289](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6289) [#6286](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6286) [#6275](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6275) [#6287](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6297](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6297) [#6291](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6459](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6459) [#6434](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6434) [#6504](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6504) [#6649](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6649) [#6506](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6506) [#6537](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6537) [#6528](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6528) [#6675](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6675) [#6674](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6674) [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558) [#6685](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6685) [#6691](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6691) [#6712](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6712) [#6734](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6734) +- Removed embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120) [#6235](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6235) [#6254](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6254) [#6285](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6285) [#6288](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6288) [#6290](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6290) [#6289](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6289) [#6286](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6286) [#6275](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6275) [#6287](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6297](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6297) [#6291](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6459](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6459) [#6434](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6434) [#6504](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6504) [#6649](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6649) [#6506](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6506) [#6537](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6537) [#6528](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6528) [#6675](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6675) [#6674](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6674) [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558) [#6685](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6685) [#6691](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6691) [#6712](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6712) [#6734](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6734) [#6746](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6746) - Allow editing groups for an agent from Endpoints Summary [#6250](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6250) - Change how the configuration is managed in the backend side [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337) [#6519](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6519) [#6573](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6573) - Change the view of API is down and check connection to Server APIs application [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337) diff --git a/plugins/main/public/components/common/data-source/pattern/alerts/alerts-data-source.ts b/plugins/main/public/components/common/data-source/pattern/alerts/alerts-data-source.ts index a94d3fd696..46fcd659bb 100644 --- a/plugins/main/public/components/common/data-source/pattern/alerts/alerts-data-source.ts +++ b/plugins/main/public/components/common/data-source/pattern/alerts/alerts-data-source.ts @@ -49,7 +49,7 @@ export class AlertsDataSource extends PatternDataSource { getClusterManagerFilters() { return PatternDataSourceFilterManager.getClusterManagerFilters( - this.title, + this.id, DATA_SOURCE_FILTER_CONTROLLED_CLUSTER_MANAGER, ); } diff --git a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts index e764201c14..d7a5b8ef8e 100644 --- a/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts +++ b/plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts @@ -19,10 +19,10 @@ const AGENT_ID_KEY = 'agent.id'; /** * Get the filter that excludes the data related to Wazuh servers - * @param indexPatternTitle Index pattern title + * @param indexPatternId Index pattern id * @returns */ -export function getFilterExcludeManager(indexPatternTitle: string) { +export function getFilterExcludeManager(indexPatternId: string) { return { meta: { alias: null, @@ -31,7 +31,7 @@ export function getFilterExcludeManager(indexPatternTitle: string) { negate: true, params: { query: MANAGER_AGENT_ID }, type: 'phrase', - index: indexPatternTitle, + index: indexPatternId, controlledBy: DATA_SOURCE_FILTER_CONTROLLED_EXCLUDE_SERVER, }, query: { match_phrase: { [AGENT_ID_KEY]: MANAGER_AGENT_ID } }, @@ -42,17 +42,17 @@ export function getFilterExcludeManager(indexPatternTitle: string) { /** * Get the filter that restrict the search to the allowed agents * @param agentsIds - * @param indexPatternTitle + * @param indexPatternId * @returns */ export function getFilterAllowedAgents( agentsIds: string[], - indexPatternTitle: string, + indexPatternId: string, ) { const field = AGENT_ID_KEY; return { meta: { - index: indexPatternTitle, + index: indexPatternId, type: 'phrases', key: field, value: agentsIds.toString(), @@ -297,7 +297,7 @@ export class PatternDataSourceFilterManager * Return the filter when the cluster or manager are enabled */ static getClusterManagerFilters( - indexPatternTitle: string, + indexPatternId: string, controlledByValue: string, key?: string, ): tFilter[] { @@ -313,7 +313,7 @@ export class PatternDataSourceFilterManager managerFilter.meta = { ...managerFilter.meta, controlledBy: controlledByValue, - index: indexPatternTitle, + index: indexPatternId, }; //@ts-ignore managerFilter.$state = { @@ -326,7 +326,7 @@ export class PatternDataSourceFilterManager /** * Returns the filter when the an agent is pinned (saved in the session storage or redux store) */ - static getPinnedAgentFilter(indexPatternTitle: string): tFilter[] { + static getPinnedAgentFilter(indexPatternId: string): tFilter[] { const pinnedAgentManager = new PinnedAgentManager(); const isPinnedAgent = pinnedAgentManager.isPinnedAgent(); if (!isPinnedAgent) { @@ -342,7 +342,7 @@ export class PatternDataSourceFilterManager negate: false, params: { query: currentPinnedAgent.id }, type: 'phrase', - index: indexPatternTitle, + index: indexPatternId, controlledBy: PinnedAgentManager.FILTER_CONTROLLED_PINNED_AGENT_KEY, }, query: { @@ -363,10 +363,10 @@ export class PatternDataSourceFilterManager /** * Return the filter to exclude the data related to servers (managers) due to the setting hideManagerAlerts is enabled */ - static getExcludeManagerFilter(indexPatternTitle: string): tFilter[] { + static getExcludeManagerFilter(indexPatternId: string): tFilter[] { if (store.getState().appConfig?.data?.hideManagerAlerts) { let excludeManagerFilter = getFilterExcludeManager( - indexPatternTitle, + indexPatternId, ) as tFilter; return [excludeManagerFilter]; } @@ -377,13 +377,13 @@ export class PatternDataSourceFilterManager * Return the allowed agents related to the user permissions to read data from agents in the API server */ - static getAllowAgentsFilter(indexPatternTitle: string): tFilter[] { + static getAllowAgentsFilter(indexPatternId: string): tFilter[] { const allowedAgents = store.getState().appStateReducers?.allowedAgents || []; if (allowedAgents.length > 0) { const allowAgentsFilter = getFilterAllowedAgents( allowedAgents, - indexPatternTitle, + indexPatternId, ) as tFilter; return [allowAgentsFilter]; } @@ -529,12 +529,12 @@ export class PatternDataSourceFilterManager * * @param field * @param value - * @param indexPatternTitle + * @param indexPatternId */ private generateFilter( field: string, value: string | string[], - indexPatternTitle: string, + indexPatternId: string, query: tFilter['query'] | tFilter['exists'], controlledBy?: string, negate: boolean = false, @@ -548,7 +548,7 @@ export class PatternDataSourceFilterManager params: value, negate, type: 'phrases', - index: indexPatternTitle, + index: indexPatternId, controlledBy, }, ...query, diff --git a/plugins/main/public/components/common/data-source/pattern/pattern-data-source.ts b/plugins/main/public/components/common/data-source/pattern/pattern-data-source.ts index 3217fc870f..0672d7a15e 100644 --- a/plugins/main/public/components/common/data-source/pattern/pattern-data-source.ts +++ b/plugins/main/public/components/common/data-source/pattern/pattern-data-source.ts @@ -1,125 +1,133 @@ -import { tDataSource, tSearchParams, tFilter, tParsedIndexPattern } from "../index"; +import { + tDataSource, + tSearchParams, + tFilter, + tParsedIndexPattern, +} from '../index'; import { getDataPlugin } from '../../../../kibana-services'; -import { IndexPatternsContract, IndexPattern } from "../../../../../../../src/plugins/data/public"; +import { + IndexPatternsContract, + IndexPattern, +} from '../../../../../../../src/plugins/data/public'; import { search } from '../../search-bar/search-bar-service'; import { PatternDataSourceFilterManager } from '../index'; -export class PatternDataSource implements tDataSource { - id: string; - title: string; - fields: any[]; - patternService: IndexPatternsContract; - indexPattern: IndexPattern; +export class PatternDataSource implements tDataSource { + id: string; + title: string; + fields: any[]; + patternService: IndexPatternsContract; + indexPattern: IndexPattern; - constructor(id: string, title: string) { - this.id = id; - this.title = title; - } - /** - * Initialize the data source - */ - async init(){ - this.patternService = await getDataPlugin().indexPatterns; - this.indexPattern = await this.patternService.get(this.id); - } + constructor(id: string, title: string) { + this.id = id; + this.title = title; + } + /** + * Initialize the data source + */ + async init() { + this.patternService = await getDataPlugin().indexPatterns; + this.indexPattern = await this.patternService.get(this.id); + } - getFields(){ - return this.fields; - } + getFields() { + return this.fields; + } - getFixedFilters(): tFilter[]{ - // return all filters - return [ - ...this.getPinnedAgentFilter(), - ]; - } + getFixedFilters(): tFilter[] { + // return all filters + return [...this.getPinnedAgentFilter()]; + } - getFetchFilters(): tFilter[]{ - return [ - ...this.getAllowAgentsFilter(), - ...this.getExcludeManagerFilter() - ]; - } + getFetchFilters(): tFilter[] { + return [...this.getAllowAgentsFilter(), ...this.getExcludeManagerFilter()]; + } - async select(){ - try { - const pattern = await this.patternService.get(this.id); - if(pattern){ - const fields = await this.patternService.getFieldsForIndexPattern( - pattern, - ); - const scripted = pattern.getScriptedFields().map(field => field.spec); - pattern.fields.replaceAll([...fields, ...scripted]); - await this.patternService.updateSavedObject(pattern); - }else{ - throw new Error('Error selecting index pattern: pattern not found'); - } - }catch(error){ - throw new Error(`Error selecting index pattern: ${error}`); - } + async select() { + try { + const pattern = await this.patternService.get(this.id); + if (pattern) { + const fields = await this.patternService.getFieldsForIndexPattern( + pattern, + ); + const scripted = pattern.getScriptedFields().map(field => field.spec); + pattern.fields.replaceAll([...fields, ...scripted]); + await this.patternService.updateSavedObject(pattern); + } else { + throw new Error('Error selecting index pattern: pattern not found'); + } + } catch (error) { + throw new Error(`Error selecting index pattern: ${error}`); } + } - async fetch(params: tSearchParams){ - const indexPattern = await this.patternService.get(this.id); - const { filters: defaultFilters = [], query, pagination, sorting, fields, dateRange, aggs } = params; - if(!indexPattern){ - return; - } - - try { - const results = await search({ - indexPattern, - filters: defaultFilters, - query, - pagination, - sorting, - fields: fields, - dateRange, - aggs - } - ); - - return results; - }catch(error){ - throw new Error(`Error fetching data: ${error}`); - } - + async fetch(params: tSearchParams) { + const indexPattern = await this.patternService.get(this.id); + const { + filters: defaultFilters = [], + query, + pagination, + sorting, + fields, + dateRange, + aggs, + } = params; + if (!indexPattern) { + return; } - toJSON(): tParsedIndexPattern { - return { - attributes: { - fields: JSON.stringify(this.fields), - title: this.title - }, - title: this.title, - id: this.id, - migrationVersion: { - 'index-pattern': '7.10.0' - }, - namespace: [], - references: [], - score: 0, - type: 'index-pattern', - updated_at: new Date().toISOString(), - version: 'WzPatternDataSource', - _fields: this.fields - } - } + try { + const results = await search({ + indexPattern, + filters: defaultFilters, + query, + pagination, + sorting, + fields: fields, + dateRange, + aggs, + }); - /** - * Returns the filter when the an agent is pinned (saved in the session storage or redux store) - */ - getPinnedAgentFilter(): tFilter[] { - return PatternDataSourceFilterManager.getPinnedAgentFilter(this.title); + return results; + } catch (error) { + throw new Error(`Error fetching data: ${error}`); } + } - getAllowAgentsFilter(): tFilter[] { - return PatternDataSourceFilterManager.getAllowAgentsFilter(this.title); - } + toJSON(): tParsedIndexPattern { + return { + attributes: { + fields: JSON.stringify(this.fields), + title: this.title, + }, + title: this.title, + id: this.id, + migrationVersion: { + 'index-pattern': '7.10.0', + }, + namespace: [], + references: [], + score: 0, + type: 'index-pattern', + updated_at: new Date().toISOString(), + version: 'WzPatternDataSource', + _fields: this.fields, + }; + } - getExcludeManagerFilter(): tFilter[] { - return PatternDataSourceFilterManager.getExcludeManagerFilter(this.title); - } + /** + * Returns the filter when the an agent is pinned (saved in the session storage or redux store) + */ + getPinnedAgentFilter(): tFilter[] { + return PatternDataSourceFilterManager.getPinnedAgentFilter(this.id); + } + + getAllowAgentsFilter(): tFilter[] { + return PatternDataSourceFilterManager.getAllowAgentsFilter(this.id); + } -} \ No newline at end of file + getExcludeManagerFilter(): tFilter[] { + return PatternDataSourceFilterManager.getExcludeManagerFilter(this.id); + } +} diff --git a/plugins/main/public/components/common/data-source/pattern/vulnerabilities/vulnerabilities-data-source.ts b/plugins/main/public/components/common/data-source/pattern/vulnerabilities/vulnerabilities-data-source.ts index dfa44ddf39..092a9dfd69 100644 --- a/plugins/main/public/components/common/data-source/pattern/vulnerabilities/vulnerabilities-data-source.ts +++ b/plugins/main/public/components/common/data-source/pattern/vulnerabilities/vulnerabilities-data-source.ts @@ -16,7 +16,7 @@ export class VulnerabilitiesDataSource extends PatternDataSource { getClusterManagerFilters() { return PatternDataSourceFilterManager.getClusterManagerFilters( - this.title, + this.id, DATA_SOURCE_FILTER_CONTROLLED_CLUSTER_MANAGER, VULNERABILITY_IMPLICIT_CLUSTER_MODE_FILTER, ); diff --git a/plugins/main/public/components/common/wazuh-discover/config/histogram-chart.ts b/plugins/main/public/components/common/wazuh-discover/config/histogram-chart.ts index 726936da0c..5c7966dfbd 100644 --- a/plugins/main/public/components/common/wazuh-discover/config/histogram-chart.ts +++ b/plugins/main/public/components/common/wazuh-discover/config/histogram-chart.ts @@ -1,152 +1,157 @@ -import { DashboardPanelState } from "../../../../../../../src/plugins/dashboard/public/application"; -import { EmbeddableInput } from "../../../../../../../src/plugins/embeddable/public"; +import { DashboardPanelState } from '../../../../../../../src/plugins/dashboard/public/application'; +import { EmbeddableInput } from '../../../../../../../src/plugins/embeddable/public'; import { ViewMode } from '../../../../../../../src/plugins/embeddable/public'; const hitsHistogram = (indexPatternId: string) => { - return { - id: 'events_histogram', - title: 'Events histogram', - type: 'horizontal_bar', - params: { - type: 'histogram', - grid: { - categoryLines: false, - }, - categoryAxes: [ - { - id: 'CategoryAxis-1', - type: 'category', - position: 'bottom', - show: true, - style: {}, - scale: { type: 'linear' }, - labels: { show: true, filter: true, truncate: 100 }, - title: {}, - }, - ], - valueAxes: [ - { - id: 'ValueAxis-1', - name: 'LeftAxis-1', - type: 'value', - position: 'left', - show: true, - style: {}, - scale: { type: 'linear', mode: 'normal' }, - labels: { show: true, rotate: 0, filter: false, truncate: 100 }, - title: { text: 'Count' }, - }, - ], - seriesParams: [ - { - show: true, - type: 'histogram', - mode: 'stacked', - data: { - label: 'Count', - id: '1', - }, - valueAxis: 'ValueAxis-1', - drawLinesBetweenPoints: true, - lineWidth: 2, - showCircles: true, - }, - ], - addTooltip: true, - addLegend: false, - legendPosition: 'right', - times: [], - addTimeMarker: false, - labels: {}, - thresholdLine: { - show: false, - value: 10, - width: 1, - style: 'full', - color: '#E7664C', - }, + return { + id: 'events_histogram', + title: 'Events histogram', + type: 'horizontal_bar', + params: { + type: 'histogram', + grid: { + categoryLines: false, + }, + categoryAxes: [ + { + id: 'CategoryAxis-1', + type: 'category', + position: 'bottom', + show: true, + style: {}, + scale: { type: 'linear' }, + labels: { show: true, filter: true, truncate: 100 }, + title: {}, }, - data: { - searchSource: { - query: { - language: 'kuery', - query: '', - }, - filter: [], - index: indexPatternId, - }, - references: [ - { - name: 'kibanaSavedObjectMeta.searchSourceJSON.index', - type: 'index-pattern', - id: indexPatternId, - }, - ], - aggs: [ - { id: '1', enabled: true, type: 'count', schema: 'metric', params: {} }, - { - id: '2', - enabled: true, - type: 'date_histogram', - schema: 'segment', - params: { - field: 'timestamp', - useNormalizedEsInterval: true, - scaleMetricValues: false, - interval: 'auto', - drop_partials: false, - min_doc_count: 1, - extended_bounds: {}, - }, - }, - ], + ], + valueAxes: [ + { + id: 'ValueAxis-1', + name: 'LeftAxis-1', + type: 'value', + position: 'left', + show: true, + style: {}, + scale: { type: 'linear', mode: 'normal' }, + labels: { show: true, rotate: 0, filter: false, truncate: 100 }, + title: { text: 'Count' }, }, - }; + ], + seriesParams: [ + { + show: true, + type: 'histogram', + mode: 'stacked', + data: { + label: 'Count', + id: '1', + }, + valueAxis: 'ValueAxis-1', + drawLinesBetweenPoints: true, + lineWidth: 2, + showCircles: true, + }, + ], + addTooltip: true, + addLegend: false, + legendPosition: 'right', + times: [], + addTimeMarker: false, + labels: {}, + thresholdLine: { + show: false, + value: 10, + width: 1, + style: 'full', + color: '#E7664C', + }, + }, + data: { + searchSource: { + query: { + language: 'kuery', + query: '', + }, + filter: [], + index: indexPatternId, + }, + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: indexPatternId, + }, + ], + aggs: [ + { id: '1', enabled: true, type: 'count', schema: 'metric', params: {} }, + { + id: '2', + enabled: true, + type: 'date_histogram', + schema: 'segment', + params: { + field: 'timestamp', + useNormalizedEsInterval: true, + scaleMetricValues: false, + interval: 'auto', + drop_partials: false, + min_doc_count: 1, + extended_bounds: {}, + }, + }, + ], + }, + }; }; - export const getDiscoverPanels = ( - indexPatternId: string, + indexPatternId: string, ): { - [panelId: string]: DashboardPanelState< - EmbeddableInput & { [k: string]: unknown } - >; + [panelId: string]: DashboardPanelState< + EmbeddableInput & { [k: string]: unknown } + >; } => { - return { - '1': { - gridData: { - w: 100, - h: 10, - x: 0, - y: 0, - i: '1', - }, - type: 'visualization', - explicitInput: { - id: '1', - savedVis: hitsHistogram(indexPatternId), - }, - } - }; -} - -export const histogramChartInput = (indexPatternName: string, filters, query, dateRangeFrom, dateRangeTo) => ({ - viewMode: ViewMode.VIEW, - panels: getDiscoverPanels(indexPatternName), - isFullScreenMode: false, - filters: filters ?? [], - useMargins: false, - id: 'wz-discover-events-histogram', - timeRange: { - from: dateRangeFrom, - to: dateRangeTo, - }, - title: 'Discover Events Histogram', - description: 'Histogram of events by date', - query: query, - refreshConfig: { - pause: false, - value: 15, + return { + '1': { + gridData: { + w: 100, + h: 10, + x: 0, + y: 0, + i: '1', + }, + type: 'visualization', + explicitInput: { + id: '1', + savedVis: hitsHistogram(indexPatternId), + }, }, - hidePanelTitles: true, - }) \ No newline at end of file + }; +}; + +export const histogramChartInput = ( + indexPatternId: string, + filters, + query, + dateRangeFrom, + dateRangeTo, +) => ({ + viewMode: ViewMode.VIEW, + panels: getDiscoverPanels(indexPatternId), + isFullScreenMode: false, + filters: filters ?? [], + useMargins: false, + id: 'wz-discover-events-histogram', + timeRange: { + from: dateRangeFrom, + to: dateRangeTo, + }, + title: 'Discover Events Histogram', + description: 'Histogram of events by date', + query: query, + refreshConfig: { + pause: false, + value: 15, + }, + hidePanelTitles: true, +}); diff --git a/plugins/main/public/components/common/wazuh-discover/wz-discover.tsx b/plugins/main/public/components/common/wazuh-discover/wz-discover.tsx index 9fc73e4748..21fc49d68f 100644 --- a/plugins/main/public/components/common/wazuh-discover/wz-discover.tsx +++ b/plugins/main/public/components/common/wazuh-discover/wz-discover.tsx @@ -224,7 +224,7 @@ const WazuhDiscoverComponent = (props: WazuhDiscoverProps) => { void; @@ -28,7 +28,7 @@ interface OverviewCardsProps { agentsCount: number; searchBarProps: any; results: any; - indexPatternId: string; + indexPattern: tParsedIndexPattern; clusterName?: string; filters: tFilter[]; } @@ -49,7 +49,7 @@ export const OverviewCards = ({ agentsCount, searchBarProps, results, - indexPatternId, + indexPattern, clusterName, filters, }: OverviewCardsProps) => { @@ -206,7 +206,7 @@ export const OverviewCards = ({ = ({ statusRunning }) => { ) : null} {!isDataSourceLoading && - dataSource && - !state.showConfig && - !state.showNodes ? ( + dataSource && + !state.showConfig && + !state.showNodes ? ( = ({ statusRunning }) => { agentsCount={state?.agentsCount} searchBarProps={searchBarProps} results={results} - indexPatternId={dataSource?.id} + indexPattern={dataSource?.indexPattern} filters={fetchFilters ?? []} /> ) : null} diff --git a/plugins/main/public/components/management/cluster/dashboard/dashboard_panels.ts b/plugins/main/public/components/management/cluster/dashboard/dashboard_panels.ts index c4871aca44..14e06a8399 100644 --- a/plugins/main/public/components/management/cluster/dashboard/dashboard_panels.ts +++ b/plugins/main/public/components/management/cluster/dashboard/dashboard_panels.ts @@ -1,15 +1,16 @@ import { DashboardPanelState } from '../../../../../../../../src/plugins/dashboard/public/application'; import { EmbeddableInput } from '../../../../../../../../src/plugins/embeddable/public'; +import { tParsedIndexPattern } from '../../../common/data-source'; /* WARNING: The panel id must be unique including general and agents visualizations. Otherwise, the visualizations will not refresh when we pin an agent, because they are cached by id */ /* Overview visualizations */ const getVisStateClusterAlertsSummary = ( - indexPatternId: string, + indexPattern: tParsedIndexPattern, clusterName?: string, ) => { - let expression = `.es(index=${indexPatternId},q="cluster.name: ${clusterName}").label("${clusterName} cluster")`; + let expression = `.es(index=${indexPattern.title},q="cluster.name: ${clusterName}").label("${clusterName} cluster")`; expression = expression.replace(/'/g, '"'); return { id: 'Wazuh-App-Cluster-monitoring-Overview-Manager', @@ -23,13 +24,13 @@ const getVisStateClusterAlertsSummary = ( query: '', }, filter: [], - index: indexPatternId, + index: indexPattern.id, }, references: [ { name: 'kibanaSavedObjectMeta.searchSourceJSON.index', type: 'index-pattern', - id: indexPatternId, + id: indexPattern.id, }, ], aggs: [], @@ -38,13 +39,13 @@ const getVisStateClusterAlertsSummary = ( }; const getVisStateAlertsByNodeSummary = ( - indexPatternId: string, + indexPattern: tParsedIndexPattern, nodeList: any[], clusterName?: string, ) => { let expression = ''; for (const node of nodeList) { - expression += `.es(index=${indexPatternId},q="cluster.name: ${clusterName} AND cluster.node: ${node.name}").label("${node.name}"),`; + expression += `.es(index=${indexPattern.title},q="cluster.name: ${clusterName} AND cluster.node: ${node.name}").label("${node.name}"),`; } expression = expression.substring(0, expression.length - 1); expression = expression.replace(/'/g, '"'); @@ -60,13 +61,13 @@ const getVisStateAlertsByNodeSummary = ( query: '', }, filter: [], - index: indexPatternId, + index: indexPattern.id, }, references: [ { name: 'kibanaSavedObjectMeta.searchSourceJSON.index', type: 'index-pattern', - id: indexPatternId, + id: indexPattern.id, }, ], aggs: [], @@ -77,7 +78,7 @@ const getVisStateAlertsByNodeSummary = ( /* Definition of panels */ export const getDashboardPanels = ( - indexPatternId: string, + indexPattern: tParsedIndexPattern, nodeList: any[], clusterName?: string, ): { @@ -97,7 +98,7 @@ export const getDashboardPanels = ( type: 'visualization', explicitInput: { id: '1', - savedVis: getVisStateClusterAlertsSummary(indexPatternId, clusterName), + savedVis: getVisStateClusterAlertsSummary(indexPattern, clusterName), }, }, '2': { @@ -112,7 +113,7 @@ export const getDashboardPanels = ( explicitInput: { id: '2', savedVis: getVisStateAlertsByNodeSummary( - indexPatternId, + indexPattern, nodeList, clusterName, ), diff --git a/plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx b/plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx index c021ace475..b1ad586b7c 100644 --- a/plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/common/hocs/validate-vulnerabilities-states-index-pattern.tsx @@ -25,9 +25,9 @@ async function checkExistenceIndexPattern(indexPatternID: string) { return response?.error?.statusCode !== 404; } -async function checkExistenceIndices(indexPatternTitle: string) { +async function checkExistenceIndices(indexPatternId: string) { try { - const fields = await SavedObject.getIndicesFields(indexPatternTitle); + const fields = await SavedObject.getIndicesFields(indexPatternId); return { exist: true, fields }; } catch (error) { return { exist: false }; diff --git a/plugins/main/public/react-services/data-sources/types.ts b/plugins/main/public/react-services/data-sources/types.ts index e5c1b13c2b..af117e6c70 100644 --- a/plugins/main/public/react-services/data-sources/types.ts +++ b/plugins/main/public/react-services/data-sources/types.ts @@ -1,3 +1,3 @@ export interface IDataSourcesFilterManager { - getFilters(searchBarFilters: any[], indexPatternTitle: string): any[]; + getFilters(searchBarFilters: any[], indexPatternId: string): any[]; } diff --git a/plugins/main/public/react-services/data-sources/vulnerabilities-states.ts b/plugins/main/public/react-services/data-sources/vulnerabilities-states.ts index 77f841fa8a..3257952310 100644 --- a/plugins/main/public/react-services/data-sources/vulnerabilities-states.ts +++ b/plugins/main/public/react-services/data-sources/vulnerabilities-states.ts @@ -7,10 +7,10 @@ import { IDataSourcesFilterManager } from './types'; /** * Get the filter that excludes the data related to Wazuh servers - * @param indexPatternTitle Index pattern title + * @param indexPatternId Index pattern title * @returns */ -export function getFilterExcludeManager(indexPatternTitle: string) { +export function getFilterExcludeManager(indexPatternId: string) { return { meta: { alias: null, @@ -19,7 +19,7 @@ export function getFilterExcludeManager(indexPatternTitle: string) { negate: true, params: { query: '000' }, type: 'phrase', - index: indexPatternTitle, + index: indexPatternId, controlledBy: DATA_SOURCE_FILTER_CONTROLLED_EXCLUDE_SERVER, }, query: { match_phrase: { 'agent.id': '000' } }, @@ -30,17 +30,17 @@ export function getFilterExcludeManager(indexPatternTitle: string) { /** * Get the filter that restrict the search to the allowed agents * @param agentsIds - * @param indexPatternTitle + * @param indexPatternId * @returns */ export function getFilterAllowedAgents( agentsIds: string[], - indexPatternTitle: string, + indexPatternId: string, ) { const field = 'agent.id'; return { meta: { - index: indexPatternTitle, + index: indexPatternId, type: 'phrases', key: field, value: agentsIds.toString(), @@ -70,23 +70,23 @@ export function getFilterAllowedAgents( export const DataSourceFilterManagerVulnerabilitiesStates: IDataSourcesFilterManager = { - getFilters(searchBarFilters: any[], indexPatternTitle: string) { + getFilters(searchBarFilters: any[], indexPatternId: string) { return [ ...searchBarFilters, /* Add the filter to exclude the data related to servers (managers) due to the setting hideManagerAlerts is enabled */ ...(store.getState().appConfig?.data?.hideManagerAlerts && - indexPatternTitle - ? [getFilterExcludeManager(indexPatternTitle)] + indexPatternId + ? [getFilterExcludeManager(indexPatternId)] : []), /* Add the allowed agents related to the user permissions to read data from agents in the API server */ ...(store.getState().appStateReducers?.allowedAgents?.length > 0 && - indexPatternTitle + indexPatternId ? [ getFilterAllowedAgents( store.getState().appStateReducers?.allowedAgents, - indexPatternTitle, + indexPatternId, ), ] : []), diff --git a/plugins/main/public/react-services/reporting.js b/plugins/main/public/react-services/reporting.js index 79fcdd755d..b0d78d6b4e 100644 --- a/plugins/main/public/react-services/reporting.js +++ b/plugins/main/public/react-services/reporting.js @@ -155,13 +155,13 @@ export class ReportingService { const timeFilter = dataSourceContext.time && dataSourceContext.indexPattern.timeFieldName ? buildRangeFilter( - { - name: dataSourceContext.indexPattern.timeFieldName, - type: 'date', - }, - dataSourceContext.time, - dataSourceContext.indexPattern, - ) + { + name: dataSourceContext.indexPattern.timeFieldName, + type: 'date', + }, + dataSourceContext.time, + dataSourceContext.indexPattern, + ) : null; // Build the filters to use in the server side // Based on https://github.com/opensearch-project/OpenSearch-Dashboards/blob/2.13.0/src/plugins/data/public/query/query_service.ts#L103-L113 @@ -181,12 +181,12 @@ export class ReportingService { tab === 'syscollector' ? { to: dataSourceContext.time.to, from: dataSourceContext.time.from } : { - to: dateMath.parse(dataSourceContext.time.to, { - roundUp: true, - forceNow: getForceNow(), - }), - from: dateMath.parse(dataSourceContext.time.from), - }; + to: dateMath.parse(dataSourceContext.time.to, { + roundUp: true, + forceNow: getForceNow(), + }), + from: dateMath.parse(dataSourceContext.time.from), + }; const data = { array: visualizations,