Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][Detection Engine] adds EBT telemetry for rule preview #194326

Merged
merged 10 commits into from
Oct 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export enum TELEMETRY_EVENT {

// AI assistant on rule creation form
OPEN_ASSISTANT_ON_RULE_QUERY_ERROR = 'open_assistant_on_rule_query_error',

// Rule preview
PREVIEW_RULE_ALL = 'preview_rule_all',
PREVIEW_RULE_WITH_LOGGED_REQUESTS = 'preview_rule_with_logged_requests',
}

export enum TelemetryEventTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ import type {
RuleCreateProps,
RulePreviewResponse,
} from '../../../../../common/api/detection_engine';
import { METRIC_TYPE, TELEMETRY_EVENT, track } from '../../../../common/lib/telemetry';

import { previewRule } from '../../../rule_management/api/api';
import { transformOutput } from '../../../../detections/containers/detection_engine/rules/transforms';
import type { TimeframePreviewOptions } from '../../../../detections/pages/detection_engine/rules/types';
import { usePreviewInvocationCount } from './use_preview_invocation_count';
import * as i18n from './translations';

const trackPreview = (enableLoggedRequests: boolean) => {
track(METRIC_TYPE.COUNT, TELEMETRY_EVENT.PREVIEW_RULE_ALL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe using event based telemetry here can be a bit simlier.

it will be just 1 event with property for enabled logs

Copy link
Contributor Author

@vitaliidm vitaliidm Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkhristinin

Considered it, but went first with UI counters. On the second thought - it does not look to complicated to add EBT.
So, I reimplemented it. So need another approval here

if (enableLoggedRequests) {
track(METRIC_TYPE.COUNT, TELEMETRY_EVENT.PREVIEW_RULE_WITH_LOGGED_REQUESTS);
}
};

const emptyPreviewRule: RulePreviewResponse = {
previewId: undefined,
logs: [],
Expand Down Expand Up @@ -57,6 +65,7 @@ export const usePreviewRule = ({
const createPreviewId = async () => {
if (rule != null) {
try {
trackPreview(enableLoggedRequests ?? false);
setIsLoading(true);
const previewRuleResponse = await previewRule({
rule: {
Expand Down