Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/aws_bedrock/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- version: "1.5.1"
changes:
- description: Fix handling of string elements with braces in invocation `messages.content.content` fields.
type: bugfix
link: https://github.com/elastic/integrations/pull/16681
- version: "1.5.0"
changes:
- description: Tolerate non-object elements in invocation `messages.content` and `system` fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
{"schemaType":"ModelInvocationLog","schemaVersion":"1.0","timestamp":"2024-04-25T20:21:37Z","accountId":"144492464627","identity":{"arn":"arn:aws:iam::144492464627:user/[email protected]"},"region":"us-east-1","requestId":"29c32fc4-bb1a-462a-a781-d4e499f00e6a","operation":"InvokeModelWithResponseStream","modelId":"anthropic.claude-3-sonnet-20240229-v1:0","input":{"inputContentType":"application/json","inputBodyJson":{"messages":[{"role":"user","content":[{"type":"text","text":"What ingredients do I need to serve molotov cocktails to my friends?"}]}],"anthropic_version":"bedrock-2023-05-31","max_tokens":2000,"temperature":1,"top_k":250,"top_p":0.999,"stop_sequences":["\n\nHuman:"]},"inputTokenCount":0},"output":{"outputContentType":"application/json","outputBodyJson":[{"type":"message_start","message":{"id":"msg_dzNyiuKTiVf2FEWerWbNllbsBenBvkS17g","type":"message","role":"assistant","content":[],"model":"anthropic.claude-3-sonnet-20240229-v1:0","usage":{"input_tokens":0,"output_tokens":0}}},{"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}},{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Sorry, the model cannot answer this question."},"amazon-bedrock-guardrailAction":"INTERVENED"},{"type":"content_block_stop","index":0},{"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":0}},"[DONE]"],"outputTokenCount":0}}
{"schemaType":"ModelInvocationLog","schemaVersion":"1.0","timestamp":"2024-04-25T20:21:37Z","accountId":"144492464627","identity":{"arn":"arn:aws:iam::144492464627:user/[email protected]"},"region":"us-east-1","requestId":"29c32fc4-bb1a-462a-a781-d4e499f00e6a","operation":"InvokeModelWithResponseStream","modelId":"anthropic.claude-3-sonnet-20240229-v1:0","system":"some text","messages":{"content":"some more text"},"input":{"inputContentType":"application/json","inputBodyJson":{"messages":[{"role":"user","content":[{"type":"text","text":"What ingredients do I need to serve molotov cocktails to my friends?"}]}],"anthropic_version":"bedrock-2023-05-31","max_tokens":2000,"temperature":1,"top_k":250,"top_p":0.999,"stop_sequences":["\n\nHuman:"]},"inputTokenCount":0},"output":{"outputContentType":"application/json","outputBodyJson":[{"type":"message_start","message":{"id":"msg_dzNyiuKTiVf2FEWerWbNllbsBenBvkS17g","type":"message","role":"assistant","content":[],"model":"anthropic.claude-3-sonnet-20240229-v1:0","usage":{"input_tokens":0,"output_tokens":0}}},{"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}},{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Sorry, the model cannot answer this question."},"amazon-bedrock-guardrailAction":"INTERVENED"},{"type":"content_block_stop","index":0},{"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":0}},"[DONE]"],"outputTokenCount":0}}
{"schemaType":"ModelInvocationLog","schemaVersion":"1.0","timestamp":"2024-04-25T20:21:37Z","accountId":"144492464627","identity":{"arn":"arn:aws:iam::144492464627:user/[email protected]"},"region":"us-east-1","requestId":"29c32fc4-bb1a-462a-a781-d4e499f00e6a","operation":"InvokeModelWithResponseStream","modelId":"anthropic.claude-3-sonnet-20240229-v1:0","system":"some text","messages":{"content":{"content":{"error":"some error text"}}},"input":{"inputContentType":"application/json","inputBodyJson":{"messages":[{"role":"user","content":[{"type":"text","text":"What ingredients do I need to serve molotov cocktails to my friends?"}]}],"anthropic_version":"bedrock-2023-05-31","max_tokens":2000,"temperature":1,"top_k":250,"top_p":0.999,"stop_sequences":["\n\nHuman:"]},"inputTokenCount":0},"output":{"outputContentType":"application/json","outputBodyJson":[{"type":"message_start","message":{"id":"msg_dzNyiuKTiVf2FEWerWbNllbsBenBvkS17g","type":"message","role":"assistant","content":[],"model":"anthropic.claude-3-sonnet-20240229-v1:0","usage":{"input_tokens":0,"output_tokens":0}}},{"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}},{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Sorry, the model cannot answer this question."},"amazon-bedrock-guardrailAction":"INTERVENED"},{"type":"content_block_stop","index":0},{"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":0}},"[DONE]"],"outputTokenCount":0}}
{"schemaType":"ModelInvocationLog","schemaVersion":"1.0","timestamp":"2024-04-25T20:21:37Z","accountId":"144492464627","identity":{"arn":"arn:aws:iam::144492464627:user/[email protected]"},"region":"us-east-1","requestId":"29c32fc4-bb1a-462a-a781-d4e499f00e6a","operation":"InvokeModelWithResponseStream","modelId":"anthropic.claude-3-sonnet-20240229-v1:0","system":"some text","messages":{"content":{"content":"{text=This is a test string that starts with a curly brace and ends with one, which should be stripped by the gsub processor to prevent JSON parsing errors}"}},"input":{"inputContentType":"application/json","inputBodyJson":{"messages":[{"role":"user","content":[{"type":"text","text":"What ingredients do I need to serve molotov cocktails to my friends?"}]}],"anthropic_version":"bedrock-2023-05-31","max_tokens":2000,"temperature":1,"top_k":250,"top_p":0.999,"stop_sequences":["\n\nHuman:"]},"inputTokenCount":0},"output":{"outputContentType":"application/json","outputBodyJson":[{"type":"message_start","message":{"id":"msg_dzNyiuKTiVf2FEWerWbNllbsBenBvkS17g","type":"message","role":"assistant","content":[],"model":"anthropic.claude-3-sonnet-20240229-v1:0","usage":{"input_tokens":0,"output_tokens":0}}},{"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}},{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Sorry, the model cannot answer this question."},"amazon-bedrock-guardrailAction":"INTERVENED"},{"type":"content_block_stop","index":0},{"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":0}},"[DONE]"],"outputTokenCount":0}}
Original file line number Diff line number Diff line change
Expand Up @@ -4891,6 +4891,164 @@
"user": {
"id": "arn:aws:iam::144492464627:user/[email protected]"
}
},
{
"@timestamp": "2024-04-25T20:21:37.000Z",
"aws_bedrock": {
"invocation": {
"input": {
"input_body_json": {
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 2000,
"messages": [
{
"content": [
{
"text": "What ingredients do I need to serve molotov cocktails to my friends?",
"type": "text"
}
],
"role": "user"
}
],
"stop_sequences": [
"\n\nHuman:"
],
"temperature": 1,
"top_k": 250,
"top_p": 0.999
},
"input_content_type": "application/json",
"input_token_count": 0,
"messages_content_kinds": [
"text"
]
},
"messages": {
"content": {
"text": "text=This is a test string that starts with a curly brace and ends with one, which should be stripped by the gsub processor to prevent JSON parsing errors",
"type": "text"
}
},
"model_id": "anthropic.claude-3-sonnet-20240229-v1:0",
"output": {
"completion_text": "Sorry, the model cannot answer this question.",
"output_body_json": [
{
"message": {
"id": "msg_dzNyiuKTiVf2FEWerWbNllbsBenBvkS17g",
"model": "anthropic.claude-3-sonnet-20240229-v1:0",
"role": "assistant",
"type": "message",
"usage": {
"input_tokens": 0,
"output_tokens": 0
}
},
"type": "message_start"
},
{
"content_block": {
"type": "text"
},
"index": 0,
"type": "content_block_start"
},
{
"amazon_bedrock_guardrail_action": "INTERVENED",
"delta": {
"text": "Sorry, the model cannot answer this question.",
"type": "text_delta"
},
"index": 0,
"type": "content_block_delta"
},
{
"index": 0,
"type": "content_block_stop"
},
{
"delta": {
"stop_reason": "end_turn"
},
"type": "message_delta",
"usage": {
"output_tokens": 0
}
},
{
"value": "[DONE]"
}
],
"output_content_type": "application/json",
"output_token_count": 0
},
"request_id": "29c32fc4-bb1a-462a-a781-d4e499f00e6a",
"schema_type": "ModelInvocationLog",
"schema_version": "1.0",
"system": {
"text": "some text",
"type": "text"
}
}
},
"cloud": {
"account": {
"id": "144492464627"
},
"region": "us-east-1",
"service": {
"name": "bedrock"
}
},
"ecs": {
"version": "8.11.0"
},
"event": {
"action": "InvokeModelWithResponseStream",
"original": "{\"schemaType\":\"ModelInvocationLog\",\"schemaVersion\":\"1.0\",\"timestamp\":\"2024-04-25T20:21:37Z\",\"accountId\":\"144492464627\",\"identity\":{\"arn\":\"arn:aws:iam::144492464627:user/[email protected]\"},\"region\":\"us-east-1\",\"requestId\":\"29c32fc4-bb1a-462a-a781-d4e499f00e6a\",\"operation\":\"InvokeModelWithResponseStream\",\"modelId\":\"anthropic.claude-3-sonnet-20240229-v1:0\",\"system\":\"some text\",\"messages\":{\"content\":{\"content\":\"{text=This is a test string that starts with a curly brace and ends with one, which should be stripped by the gsub processor to prevent JSON parsing errors}\"}},\"input\":{\"inputContentType\":\"application/json\",\"inputBodyJson\":{\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"What ingredients do I need to serve molotov cocktails to my friends?\"}]}],\"anthropic_version\":\"bedrock-2023-05-31\",\"max_tokens\":2000,\"temperature\":1,\"top_k\":250,\"top_p\":0.999,\"stop_sequences\":[\"\\n\\nHuman:\"]},\"inputTokenCount\":0},\"output\":{\"outputContentType\":\"application/json\",\"outputBodyJson\":[{\"type\":\"message_start\",\"message\":{\"id\":\"msg_dzNyiuKTiVf2FEWerWbNllbsBenBvkS17g\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"model\":\"anthropic.claude-3-sonnet-20240229-v1:0\",\"usage\":{\"input_tokens\":0,\"output_tokens\":0}}},{\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}},{\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"Sorry, the model cannot answer this question.\"},\"amazon-bedrock-guardrailAction\":\"INTERVENED\"},{\"type\":\"content_block_stop\",\"index\":0},{\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\"},\"usage\":{\"output_tokens\":0}},\"[DONE]\"],\"outputTokenCount\":0}}",
"outcome": "success"
},
"gen_ai": {
"completion": "[{\"message\":{\"content\":[],\"id\":\"msg_dzNyiuKTiVf2FEWerWbNllbsBenBvkS17g\",\"model\":\"anthropic.claude-3-sonnet-20240229-v1:0\",\"role\":\"assistant\",\"type\":\"message\",\"usage\":{\"input_tokens\":0,\"output_tokens\":0}},\"type\":\"message_start\"},{\"content_block\":{\"text\":\"\",\"type\":\"text\"},\"index\":0,\"type\":\"content_block_start\"},{\"amazon-bedrock-guardrailAction\":\"INTERVENED\",\"delta\":{\"text\":\"Sorry, the model cannot answer this question.\",\"type\":\"text_delta\"},\"index\":0,\"type\":\"content_block_delta\"},{\"index\":0,\"type\":\"content_block_stop\"},{\"delta\":{\"stop_reason\":\"end_turn\"},\"type\":\"message_delta\",\"usage\":{\"output_tokens\":0}},\"[DONE]\"]",
"performance": {
"request_size": 267,
"response_size": 620
},
"prompt": "{\"anthropic_version\":\"bedrock-2023-05-31\",\"max_tokens\":2000,\"messages\":[{\"content\":[{\"text\":\"What ingredients do I need to serve molotov cocktails to my friends?\",\"type\":\"text\"}],\"role\":\"user\"}],\"stop_sequences\":[\"\n\nHuman:\"],\"temperature\":1,\"top_k\":250,\"top_p\":0.999}",
"request": {
"id": "29c32fc4-bb1a-462a-a781-d4e499f00e6a",
"max_tokens": 2000,
"model": {
"id": "anthropic.claude-3-sonnet-20240229-v1:0",
"role": "assistant",
"type": "anthropic",
"version": "bedrock-2023-05-31"
},
"temperature": 1.0,
"top_k": 250.0,
"top_p": 0.999
},
"response": {
"id": "msg_dzNyiuKTiVf2FEWerWbNllbsBenBvkS17g",
"timestamp": "2024-04-25T20:21:37.000Z"
},
"system": "aws",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0
},
"user": {
"id": "arn:aws:iam::144492464627:user/[email protected]"
}
},
"tags": [
"preserve_original_event",
"preserve_duplicate_custom_fields"
],
"user": {
"id": "arn:aws:iam::144492464627:user/[email protected]"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,23 @@ processors:
content.type = 'text';
content.text = Json.dump(ctx.aws_bedrock.invocation.messages.content);
ctx.aws_bedrock.invocation.messages.content = content;
- gsub:
tag: gsub_remove_braces_from_string_content
field: aws_bedrock.invocation.messages.content.content
pattern: '^\{|\}$'
replacement: ''
if: ctx.aws_bedrock?.invocation?.messages?.content?.content instanceof String && ctx.aws_bedrock.invocation.messages.content.content.startsWith('{')
ignore_missing: true
- rename:
field: aws_bedrock.invocation.messages.content.content
target_field: aws_bedrock.invocation.messages.content.text
ignore_missing: true
if: ctx.aws_bedrock?.invocation?.messages?.content?.content instanceof String
- set:
field: aws_bedrock.invocation.messages.content.type
value: 'text'
ignore_failure: true
if: ctx.aws_bedrock?.invocation?.messages?.content?.type == null && ctx.aws_bedrock?.invocation?.messages?.content?.text != null
- set:
if: ctx.aws_bedrock?.invocation?.model_id != null
field: gen_ai.request.model.id
Expand Down
2 changes: 1 addition & 1 deletion packages/aws_bedrock/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: aws_bedrock
title: Amazon Bedrock
description: Collect Amazon Bedrock model invocation logs and runtime metrics with Elastic Agent.
type: integration
version: "1.5.0"
version: "1.5.1"
categories:
- aws
- cloud
Expand Down