Skip to content

Commit

Permalink
fix bad name
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Jun 1, 2023
1 parent 293c846 commit 38ff3c3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 42 deletions.
6 changes: 3 additions & 3 deletions x-pack/plugins/actions/server/lib/action_executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1355,12 +1355,12 @@ test('writes usage data to event log for gen ai events', async () => {
action: {
execution: {
uuid: '2',
gen_ai: {
usage: mockGenAi.usage,
},
},
name: 'action-1',
id: '1',
meta: {
usage: mockGenAi.usage,
},
},
alert: {
rule: {
Expand Down
10 changes: 7 additions & 3 deletions x-pack/plugins/actions/server/lib/action_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,20 @@ export class ActionExecutor {

event.event = event.event || {};

// add meta to event log when GenerativeAi Connector is executed
// add event.kibana.action.execution.gen_ai to event log when GenerativeAi Connector is executed
if (result.status === 'ok' && actionTypeId === '.gen-ai') {
const data = result.data as unknown as { usage: {} };
event.kibana = event.kibana || {};
event.kibana.action = event.kibana.action || {};
event.kibana = {
...event.kibana,
action: {
...event.kibana.action,
meta: {
usage: data.usage,
execution: {
...event.kibana.action.execution,
gen_ai: {
usage: data.usage,
},
},
},
};
Expand Down
28 changes: 14 additions & 14 deletions x-pack/plugins/event_log/generated/mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,21 +470,21 @@
"uuid": {
"ignore_above": 1024,
"type": "keyword"
}
}
},
"meta": {
"properties": {
"usage": {
},
"gen_ai": {
"properties": {
"prompt_tokens": {
"type": "long"
},
"completion_tokens": {
"type": "long"
},
"total_tokens": {
"type": "long"
"usage": {
"properties": {
"prompt_tokens": {
"type": "long"
},
"completion_tokens": {
"type": "long"
},
"total_tokens": {
"type": "long"
}
}
}
}
}
Expand Down
20 changes: 11 additions & 9 deletions x-pack/plugins/event_log/generated/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,17 @@ export const EventSchema = schema.maybe(
schema.object({
source: ecsString(),
uuid: ecsString(),
})
),
meta: schema.maybe(
schema.object({
usage: schema.object({
prompt_tokens: ecsNumber(),
completion_tokens: ecsNumber(),
total_tokens: ecsNumber(),
}),
gen_ai: schema.maybe(
schema.object({
usage: schema.maybe(
schema.object({
prompt_tokens: ecsStringOrNumber(),
completion_tokens: ecsStringOrNumber(),
total_tokens: ecsStringOrNumber(),
})
),
})
),
})
),
})
Expand Down
26 changes: 13 additions & 13 deletions x-pack/plugins/event_log/scripts/mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,20 @@ exports.EcsCustomPropertyMappings = {
ignore_above: 1024,
type: 'keyword',
},
},
},
meta: {
properties: {
usage: {
gen_ai: {
properties: {
prompt_tokens: {
type: 'long',
},
completion_tokens: {
type: 'long',
},
total_tokens: {
type: 'long',
usage: {
properties: {
prompt_tokens: {
type: 'long',
},
completion_tokens: {
type: 'long',
},
total_tokens: {
type: 'long',
},
},
},
},
},
Expand Down

0 comments on commit 38ff3c3

Please sign in to comment.