[SIEM] Adds telemetry for ML functionality (#43926)
## Summary As outlined in https://github.com/elastic/siem-team/issues/447, this PR adds the following telemetry events for ML functionality: ``` ts SIEM_JOB_ENABLED = 'siem_job_enabled', SIEM_JOB_DISABLED = 'siem_job_disabled', CUSTOM_JOB_ENABLED = 'custom_job_enabled', CUSTOM_JOB_DISABLED = 'custom_job_disabled', JOB_ENABLE_FAILURE = 'job_enable_failure', JOB_DISABLE_FAILURE = 'job_disable_failure', ``` ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. - [ ] ~This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~ - [ ] ~Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~ - [ ] ~[Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~ - [ ] ~[Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios~ - [ ] ~This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~ ### For maintainers - [ ] ~This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~ - [x] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)
This commit is contained in:
parent
d8a0226492
commit
7995b7edc3
|
@ -17,7 +17,7 @@ import { FlyoutButton } from './button';
|
|||
import { Pane } from './pane';
|
||||
import { timelineActions } from '../../store/actions';
|
||||
import { DEFAULT_TIMELINE_WIDTH } from '../timeline/body/helpers';
|
||||
import { trackUiAction as track, METRIC_TYPE } from '../../lib/track_usage';
|
||||
import { trackUiAction as track, METRIC_TYPE, TELEMETRY_EVENT } from '../../lib/track_usage';
|
||||
|
||||
/** The height in pixels of the flyout header, exported for use in height calculations */
|
||||
export const flyoutHeaderHeight: number = 60;
|
||||
|
@ -102,7 +102,7 @@ export const FlyoutComponent = React.memo<Props>(
|
|||
show={!show}
|
||||
timelineId={timelineId}
|
||||
onOpen={() => {
|
||||
track(METRIC_TYPE.LOADED, 'open_timeline');
|
||||
track(METRIC_TYPE.LOADED, TELEMETRY_EVENT.TIMELINE_OPENED);
|
||||
showTimeline({ id: timelineId, show: true });
|
||||
}}
|
||||
/>
|
||||
|
|
|
@ -32,6 +32,7 @@ import { useStateToaster } from '../toasters';
|
|||
import { errorToToaster } from '../ml/api/error_to_toaster';
|
||||
import { useKibanaUiSetting } from '../../lib/settings/use_kibana_ui_setting';
|
||||
import { DEFAULT_KBN_VERSION } from '../../../common/constants';
|
||||
import { METRIC_TYPE, TELEMETRY_EVENT, trackUiAction as track } from '../../lib/track_usage';
|
||||
|
||||
const PopoverContentsDiv = styled.div`
|
||||
max-width: 550px;
|
||||
|
@ -109,6 +110,8 @@ export const MlPopover = React.memo(() => {
|
|||
|
||||
// Enable/Disable Job & Datafeed -- passed to JobsTable for use as callback on JobSwitch
|
||||
const enableDatafeed = async (jobName: string, latestTimestampMs: number, enable: boolean) => {
|
||||
submitTelemetry(jobName, enable, embeddedJobIds);
|
||||
|
||||
// Max start time for job is no more than two weeks ago to ensure job performance
|
||||
const maxStartTime = moment
|
||||
.utc()
|
||||
|
@ -120,12 +123,14 @@ export const MlPopover = React.memo(() => {
|
|||
try {
|
||||
await startDatafeeds([`datafeed-${jobName}`], headers, startTime);
|
||||
} catch (error) {
|
||||
track(METRIC_TYPE.COUNT, TELEMETRY_EVENT.JOB_ENABLE_FAILURE);
|
||||
errorToToaster({ title: i18n.START_JOB_FAILURE, error, dispatchToaster });
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await stopDatafeeds([`datafeed-${jobName}`], headers);
|
||||
} catch (error) {
|
||||
track(METRIC_TYPE.COUNT, TELEMETRY_EVENT.JOB_DISABLE_FAILURE);
|
||||
errorToToaster({ title: i18n.STOP_JOB_FAILURE, error, dispatchToaster });
|
||||
}
|
||||
}
|
||||
|
@ -263,4 +268,18 @@ export const MlPopover = React.memo(() => {
|
|||
}
|
||||
});
|
||||
|
||||
const submitTelemetry = (jobName: string, enabled: boolean, embeddedJobIds: string[]) => {
|
||||
// Report type of job enabled/disabled
|
||||
track(
|
||||
METRIC_TYPE.COUNT,
|
||||
embeddedJobIds.includes(jobName)
|
||||
? enabled
|
||||
? TELEMETRY_EVENT.SIEM_JOB_ENABLED
|
||||
: TELEMETRY_EVENT.SIEM_JOB_DISABLED
|
||||
: enabled
|
||||
? TELEMETRY_EVENT.CUSTOM_JOB_ENABLED
|
||||
: TELEMETRY_EVENT.CUSTOM_JOB_DISABLED
|
||||
);
|
||||
};
|
||||
|
||||
MlPopover.displayName = 'MlPopover';
|
||||
|
|
|
@ -10,7 +10,7 @@ import * as React from 'react';
|
|||
import styled from 'styled-components';
|
||||
import classnames from 'classnames';
|
||||
|
||||
import { trackUiAction as track, METRIC_TYPE } from '../../../lib/track_usage';
|
||||
import { trackUiAction as track, METRIC_TYPE, TELEMETRY_EVENT } from '../../../lib/track_usage';
|
||||
import { HostsTableType } from '../../../store/hosts/model';
|
||||
import { UrlInputsModel } from '../../../store/inputs/model';
|
||||
import { CONSTANTS } from '../../url_state/constants';
|
||||
|
@ -96,7 +96,7 @@ export class TabNavigation extends React.PureComponent<TabNavigationProps, TabNa
|
|||
disabled={tab.disabled}
|
||||
isSelected={this.state.selectedTabId === tab.id}
|
||||
onClick={() => {
|
||||
track(METRIC_TYPE.CLICK, `tab_${tab.id}`);
|
||||
track(METRIC_TYPE.CLICK, `${TELEMETRY_EVENT.TAB_CLICKED}${tab.id}`);
|
||||
}}
|
||||
>
|
||||
{tab.name}
|
||||
|
|
|
@ -13,3 +13,19 @@ import { APP_ID } from '../../../common/constants';
|
|||
|
||||
export const trackUiAction = createUiStatsReporter(APP_ID);
|
||||
export { METRIC_TYPE };
|
||||
|
||||
export enum TELEMETRY_EVENT {
|
||||
// ML
|
||||
SIEM_JOB_ENABLED = 'siem_job_enabled',
|
||||
SIEM_JOB_DISABLED = 'siem_job_disabled',
|
||||
CUSTOM_JOB_ENABLED = 'custom_job_enabled',
|
||||
CUSTOM_JOB_DISABLED = 'custom_job_disabled',
|
||||
JOB_ENABLE_FAILURE = 'job_enable_failure',
|
||||
JOB_DISABLE_FAILURE = 'job_disable_failure',
|
||||
|
||||
// Timeline
|
||||
TIMELINE_OPENED = 'open_timeline',
|
||||
|
||||
// UI Interactions
|
||||
TAB_CLICKED = 'tab_',
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue