[Enterprise Search][Behavioural Analytics] Introduce events tab for Analytics View Page (#140710)

* Introduce events tab

* Add events section to the analytics colleciton view
This commit is contained in:
Klim Markelov 2022-09-15 18:45:49 +02:00 committed by GitHub
parent 2c2c0c0d61
commit c4ed8ae919
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 106 additions and 0 deletions

View file

@ -109,6 +109,7 @@ export const ENTERPRISE_SEARCH_KIBANA_COOKIE = '_enterprise_search';
export const ENTERPRISE_SEARCH_RELEVANCE_LOGS_SOURCE_ID = 'ent-search-logs';
export const ENTERPRISE_SEARCH_AUDIT_LOGS_SOURCE_ID = 'ent-search-audit-logs';
export const ENTERPRISE_SEARCH_ANALYTICS_LOGS_SOURCE_ID = 'ent-search-analytics-logs';
export const APP_SEARCH_URL = '/app/enterprise_search/app_search';
export const ENTERPRISE_SEARCH_ELASTICSEARCH_URL = '/app/enterprise_search/elasticsearch';

View file

@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import '../../../__mocks__/shallow_useeffect.mock';
import React from 'react';
import { shallow } from 'enzyme';
import { AnalyticsCollection } from '../../../../../common/types/analytics';
import { EntSearchLogStream } from '../../../shared/log_stream';
import { AnalyticsCollectionEvents } from './analytics_collection_events';
describe('AnalyticsCollectionEvents', () => {
const analyticsCollections: AnalyticsCollection = {
event_retention_day_length: 180,
id: '1',
name: 'example',
};
beforeEach(() => {
jest.clearAllMocks();
});
it('renders', () => {
const expectedQuery = '_index: logs-elastic_analytics.events-example*';
const wrapper = shallow(<AnalyticsCollectionEvents collection={analyticsCollections} />);
expect(wrapper.find(EntSearchLogStream).prop('query')).toEqual(expectedQuery);
});
});

View file

@ -0,0 +1,58 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { ENTERPRISE_SEARCH_ANALYTICS_LOGS_SOURCE_ID } from '../../../../../common/constants';
import { AnalyticsCollection } from '../../../../../common/types/analytics';
import { EntSearchLogStream } from '../../../shared/log_stream';
interface AnalyticsCollectionEventsProps {
collection: AnalyticsCollection;
}
export const AnalyticsCollectionEvents: React.FC<AnalyticsCollectionEventsProps> = ({
collection,
}) => {
return (
<EntSearchLogStream
logView={{
type: 'log-view-reference',
logViewId: ENTERPRISE_SEARCH_ANALYTICS_LOGS_SOURCE_ID,
}}
columns={[
{
type: 'timestamp',
},
{
type: 'field',
header: i18n.translate(
'xpack.enterpriseSearch.analytics.collections.collectionsView.eventsTab.columns.eventName',
{
defaultMessage: 'Event name',
}
),
field: 'event.action',
},
{
type: 'field',
header: i18n.translate(
'xpack.enterpriseSearch.analytics.collections.collectionsView.eventsTab.columns.userUuid',
{
defaultMessage: 'User UUID',
}
),
field: 'labels.user_uuid',
},
]}
query={`_index: logs-elastic_analytics.events-${collection.name}*`}
/>
);
};

View file

@ -27,6 +27,7 @@ import { COLLECTION_CREATION_PATH, COLLECTION_VIEW_PATH } from '../../routes';
import { EnterpriseSearchAnalyticsPageTemplate } from '../layout/page_template';
import { AnalyticsCollectionEvents } from './analytics_collection_events';
import { AnalyticsCollectionIntegrate } from './analytics_collection_integrate';
import { AnalyticsCollectionSettings } from './analytics_collection_settings';
@ -147,6 +148,7 @@ export const AnalyticsCollectionView: React.FC = () => {
{section === 'integrate' && (
<AnalyticsCollectionIntegrate collection={analyticsCollection} />
)}
{section === 'events' && <AnalyticsCollectionEvents collection={analyticsCollection} />}
</>
) : (
<EuiEmptyPrompt

View file

@ -31,6 +31,7 @@ import {
WORKPLACE_SEARCH_PLUGIN,
ENTERPRISE_SEARCH_RELEVANCE_LOGS_SOURCE_ID,
ENTERPRISE_SEARCH_AUDIT_LOGS_SOURCE_ID,
ENTERPRISE_SEARCH_ANALYTICS_LOGS_SOURCE_ID,
} from '../common/constants';
import { registerTelemetryUsageCollector as registerASTelemetryUsageCollector } from './collectors/app_search/telemetry';
@ -224,6 +225,14 @@ export class EnterpriseSearchPlugin implements Plugin {
indexName: 'logs-enterprise_search*',
},
});
infra.defineInternalSourceConfiguration(ENTERPRISE_SEARCH_ANALYTICS_LOGS_SOURCE_ID, {
name: 'Enterprise Search Behaviorial Analytics Logs',
logIndices: {
type: 'index_name',
indexName: 'logs-elastic_analytics.events-*',
},
});
}
public start() {}