-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Add additional properties to attack discovery telemetry #182249
Conversation
Pinging @elastic/security-solution (Team: SecuritySolution) |
reportAttackDiscoveriesGenerated({ | ||
actionTypeId, | ||
durationMs, | ||
alertCount: knowledgeBase.latestAlerts, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider something like:
uniq(
selectedConnectorAttackDiscoveries.flatMap((attackDiscovery) => attackDiscovery.alertIds)
).length,
to calculate alertCount
, and adding an additional stat like configuredAlertsCount
to represent the value of knowledgeBase.latestAlerts
.
@@ -11,6 +11,7 @@ import { | |||
useAssistantContext, | |||
useLoadConnectors, | |||
} from '@kbn/elastic-assistant'; | |||
import { uniq } from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: consider lodash/fp
alertsCount: { | ||
type: 'integer', | ||
_meta: { | ||
description: 'Number of alerts evaluated', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Consider something like Number of unique alerts referenced in the attack discoveries
, because this may be less than the number of alerts evaluated.
if (!connector?.isPreconfigured) { | ||
const config = (connector as ActionConnectorProps<GenAiConfig, unknown>)?.config; | ||
if (config?.apiProvider === OpenAiProviderType.AzureAi) { | ||
return { | ||
...config, | ||
defaultModel: getAzureApiVersionParameter(config.apiUrl ?? ''), | ||
}; | ||
} | ||
|
||
return (connector as ActionConnectorProps<GenAiConfig, unknown>)?.config; | ||
} | ||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider something like the following to eliminate the second cast and most references to config
:
if (!connector?.isPreconfigured) {
const config = (connector as ActionConnectorProps<GenAiConfig, unknown>)?.config;
const { apiProvider, apiUrl, defaultModel } = config ?? {};
return {
apiProvider,
apiUrl,
defaultModel:
apiProvider === OpenAiProviderType.AzureAi
? getAzureApiVersionParameter(apiUrl ?? '')
: defaultModel,
};
}
return undefined; // the connector is neither available nor editable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the additional telemetry @stephmilovic!
✅ Desk tested locally
LGTM 🚀
💚 Build Succeeded
The CI Stats report is too large to be displayed here, check out the CI build annotation for this information. History
To update your PR or re-run it, just comment with: |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…emetry (elastic#182249) (cherry picked from commit e306074) # Conflicts: # .github/CODEOWNERS
…ery telemetry (#182249) (#182997) # Backport This will backport the following commits from `main` to `8.14`: - [[Security solution] Add additional properties to attack discovery telemetry (#182249)](#182249) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Steph Milovic","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-05-02T04:48:36Z","message":"[Security solution] Add additional properties to attack discovery telemetry (#182249)","sha":"e306074aa9e8943ab342270a6f795e17ee37c1da","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team: SecuritySolution","Team:Security Generative AI","v8.14.0","v8.15.0","Feature:Attack Discovery"],"number":182249,"url":"https://github.com/elastic/kibana/pull/182249","mergeCommit":{"message":"[Security solution] Add additional properties to attack discovery telemetry (#182249)","sha":"e306074aa9e8943ab342270a6f795e17ee37c1da"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"8.14","label":"v8.14.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.15.0","labelRegex":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/182249","number":182249,"mergeCommit":{"message":"[Security solution] Add additional properties to attack discovery telemetry (#182249)","sha":"e306074aa9e8943ab342270a6f795e17ee37c1da"}}]}] BACKPORT-->
Summary
Adds 3 new properties to the
reportAttackDiscoveriesGenerated
telemetry event:durationMs
,alertsCount
, andconfiguredAlertsCount
. These fields represent how long the request took, how many alerts were used for the generation, and how many alerts were configured by the user for the generation.I also added the
provider
andmodel
arguments which were already defined, but not passed. Here is an example of what this looks like for Bedrock and Azure:CODEOWNERS change
Added the
attack_discovery
dir to be under @elastic/security-generative-ai ownership 👍