-
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] AI Assistant telemetry #162653
Conversation
Pinging @elastic/security-solution (Team: SecuritySolution) |
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
@@ -548,6 +548,15 @@ | |||
}, | |||
"actionTypeId": { | |||
"type": "keyword" | |||
}, |
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.
I made a change in x-pack/plugins/actions/server/saved_objects/mappings.ts
, so I believe i will need it here too?
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.
We'd really prefer the mappings not be extended. Can you not access this field from the script in action_telemetry.ts
? If for some reason it's not in doc
, it should be in source
. I suspect you could also "add" a field during the telemetry query as a runtime-field added to the search.
@@ -352,7 +355,13 @@ const TabsContentComponent: React.FC<BasicTimelineTab> = ({ | |||
|
|||
const setSecurityAssistantAsActiveTab = useCallback(() => { | |||
setActiveTab(TimelineTabs.securityAssistant); | |||
}, [setActiveTab]); | |||
if (activeTab !== TimelineTabs.securityAssistant) { | |||
reportAssistantInvoked({ |
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.
I tried to do all of the telemetry from the assistant package, but the rendering in timeline proved difficult and I did not want a bunch of consumer related code (ie: isTimeline
) in the assistant package. Therefore, this is the sole EBT tracker called from security solution for assistant
state.types.put(actionType, state.types.containsKey(actionType) ? state.types.get(actionType) + 1 : 1); | ||
if (actionType =~ /.gen-ai/) { | ||
String genAiActionType = actionType +"__"+ doc['action.config.apiProvider'].value; | ||
state.types.put(genAiActionType, state.types.containsKey(genAiActionType) ? state.types.get(genAiActionType) + 1 : 1); |
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.
@ymao1 The only enhancement I needed to make to this telemetry was to answer the question, what apiProvider
is the connector? In order to stay out of the telemetry repo and change as little as possible, I decided to split the .gen-ai
connectors count up by the provider. Please let me know if you agree with that approach or if there is any impact I may not have considered? I'm wondering about the response-ops
data view and if I need to do something to get those fields to be in that data view by default, I currently added them as Runtime Fields to get my dashboard working
before:
count_by_type: {
'__gen-ai': 2,
}
after:
count_by_type: {
'__gen-ai__Azure OpenAI': 1,
'__gen-ai__OpenAI': 1
}
In my dashboard, I accounted for the sum of the three possible values to count the total of GenAI connectors for pre 8.10 data:
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.
As discussed, I am now creating a new field countGenAiProviderTypes
. I am still doing the key as explained above in painless, but putting the data in the agreed structure with JS below. This is tested in actions_telemetry.test.ts
by it('getCounts' ...
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.
I think we'd prefer to not modify the connector mappings. Changing the telemetry keys for gen-ai to include the provider in they key could also be problematic/confusing.
Makes me wonder if we should really be doing this as a completely separate piece of telemetry, vs part of the connector telemetry.
Not sure. Thoughts @mikecote?
@@ -66,7 +66,7 @@ export const stateSchemaByVersion = { | |||
avg_execution_time_by_type_per_day: schema.recordOf(schema.string(), schema.number()), | |||
count_connector_types_by_action_run_outcome_per_day: schema.recordOf( | |||
schema.string(), | |||
schema.number() | |||
schema.recordOf(schema.string(), schema.number()) |
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.
huh, same change is being made in this PR #161096 ...
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.
🏎️
@@ -548,6 +548,15 @@ | |||
}, | |||
"actionTypeId": { | |||
"type": "keyword" | |||
}, |
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.
We'd really prefer the mappings not be extended. Can you not access this field from the script in action_telemetry.ts
? If for some reason it's not in doc
, it should be in source
. I suspect you could also "add" a field during the telemetry query as a runtime-field added to the search.
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.
LGTM - noticed there's a typo I often make in regexp's; not escaping .
, as typically it matches any single char. Code will work as is, since .
matches "any single char", but we probably want to fix that, as it matches too widely.
}): { fn: keyof AssistantTelemetry; params: AssistantTelemetry[keyof AssistantTelemetry] } => | ||
fn({ | ||
...rest, | ||
conversationId: getAnonymizedConversationId(conversationId), |
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.
this maps all non-default conversationId
s that flow through the useAssistantTelemetry
hook to a single value: Custom
@elasticmachine merge upstream |
@elasticmachine merge upstream |
I did an experiment on this PR, added an extra telemetry field ✅ Data can be found on staging Test 1assistant_telemetry.mov
Test 2assistant_telemetry_2.mov
|
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 @stephmilovic for adding this telemetry 🙏
LGTM
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI Steps
Test Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
ESLint disabled in files
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Summary
Assistant Invoked
Assistant Message Sent
Assistant Quick Prompt
Update 8/2: @andrew-goldstein pointed out that user input should not be tracked, and we allow custom input for both
conversationId
and quick prompt titles. I added a commit to mask any user input id/quick prompt title with "Custom"apiProvider
in a new field in theresponse-ops
telemetry index this field is mapped to:connectors.all.totalByGenAiProviderType
telemetry-v2-staging
:I've created a gorgeous Dashboard to show off this new telemetry. The top 3 visualizations are from the connector usage collector telemetry (Data View:
response-ops
) and the bottom 3 visualizations are the new EBT (Data View:ebt-kibana-browser
)