From 196288db2c51698e05c98d85a852a8a2239e7352 Mon Sep 17 00:00:00 2001 From: yuye-aws Date: Tue, 5 Nov 2024 23:05:33 +0800 Subject: [PATCH 1/3] log pattern tool template Signed-off-by: yuye-aws --- .../alert-summary-log-pattern-agent.json | 94 +++++++++++++++++++ .../alert-summary-log-pattern-agent.yml | 88 +++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 sample-templates/alert-summary-log-pattern-agent.json create mode 100644 sample-templates/alert-summary-log-pattern-agent.yml diff --git a/sample-templates/alert-summary-log-pattern-agent.json b/sample-templates/alert-summary-log-pattern-agent.json new file mode 100644 index 00000000..dab1ab0c --- /dev/null +++ b/sample-templates/alert-summary-log-pattern-agent.json @@ -0,0 +1,94 @@ +{ + "name": "Alert Summary With Log Pattern Agent", + "description": "Create Alert Summary with Log Pattern Agent using Claude on BedRock", + "use_case": "REGISTER_AGENT", + "version": { + "template": "1.0.0", + "compatibility": ["2.17.0", "3.0.0"] + }, + "workflows": { + "provision": { + "user_params": {}, + "nodes": [ + { + "id": "create_claude_connector", + "type": "create_connector", + "previous_node_inputs": {}, + "user_inputs": { + "version": "1", + "name": "Claude instant runtime Connector", + "protocol": "aws_sigv4", + "description": "The connector to BedRock service for Claude model", + "actions": [ + { + "headers": { + "x-amz-content-sha256": "required", + "content-type": "application/json" + }, + "method": "POST", + "request_body": "{\"prompt\":\"\\n\\nHuman: ${parameters.prompt}\\n\\nAssistant:\", \"max_tokens_to_sample\":${parameters.max_tokens_to_sample}, \"temperature\":${parameters.temperature}, \"anthropic_version\":\"${parameters.anthropic_version}\" }", + "action_type": "predict", + "url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/anthropic.claude-instant-v1/invoke" + } + ], + "credential": { + "access_key": "", + "secret_key": "", + "session_token": "" + }, + "parameters": { + "region": "us-west-2", + "endpoint": "bedrock-runtime.us-west-2.amazonaws.com", + "content_type": "application/json", + "auth": "Sig_V4", + "max_tokens_to_sample": "8000", + "service_name": "bedrock", + "temperature": "0.0001", + "response_filter": "$.completion", + "anthropic_version": "bedrock-2023-05-31" + } + } + }, + { + "id": "register_claude_model", + "type": "register_remote_model", + "previous_node_inputs": { + "create_claude_connector": "connector_id" + }, + "user_inputs": { + "description": "Claude model", + "deploy": true, + "name": "claude-instant" + } + }, + { + "id": "create_alert_summary_with_log_pattern_ml_model_tool", + "type": "create_tool", + "previous_node_inputs": { + "register_claude_model": "model_id" + }, + "user_inputs": { + "parameters": { + "prompt": " You are an OpenSearch Alert Assistant to help summarize the alerts.\n Here is the detail of alert: \n ${parameters.context};\n \n And help detect if there is any common pattern or trend or outlier for the log pattern output. Log pattern groups the alert trigger logs by their generated patterns, the output contains some sample logs for each top-k patterns.\n Here is the log pattern output:\n ${parameters.topNLogPatternData};" + }, + "name": "MLModelTool", + "type": "MLModelTool" + } + }, + { + "id": "create_alert_summary_with_log_pattern_agent", + "type": "register_agent", + "previous_node_inputs": { + "create_alert_summary_with_log_pattern_ml_model_tool": "tools" + }, + "user_inputs": { + "parameters": {}, + "type": "flow", + "name": "Alert Summary With Log Pattern Agent", + "description": "this is an alert summary with log pattern agent" + } + } + ] + } + } +} \ No newline at end of file diff --git a/sample-templates/alert-summary-log-pattern-agent.yml b/sample-templates/alert-summary-log-pattern-agent.yml new file mode 100644 index 00000000..83b23b6d --- /dev/null +++ b/sample-templates/alert-summary-log-pattern-agent.yml @@ -0,0 +1,88 @@ +# This template creates a connector to the BedRock service for Claude model +# It then registers a model using the connector and deploys it. +# Finally, it creates a flow agent base agent with ML Model tool to generate alert summary from log patterns. +# +# To use: +# - update the "credential" fields under the create_claude_connector node. +# - if needed, update region +# +# After provisioning: +# - returns a workflow ID +# - use the status API to get the deployed agent ID +--- +name: Alert Summary With Log Pattern Agent +description: Create Alert Summary with Log Pattern Agent using Claude on BedRock +use_case: REGISTER_AGENT +version: + template: 1.0.0 + compatibility: + - 2.17.0 + - 3.0.0 +workflows: + provision: + user_params: {} + nodes: + - id: create_claude_connector + type: create_connector + previous_node_inputs: {} + user_inputs: + version: '1' + name: Claude instant runtime Connector + protocol: aws_sigv4 + description: The connector to BedRock service for Claude model + actions: + - headers: + x-amz-content-sha256: required + content-type: application/json + method: POST + request_body: '{"prompt":"\n\nHuman: ${parameters.prompt}\n\nAssistant:", + "max_tokens_to_sample":${parameters.max_tokens_to_sample}, "temperature":${parameters.temperature}, "anthropic_version":"${parameters.anthropic_version}" + }' + action_type: predict + url: https://bedrock-runtime.us-west-2.amazonaws.com/model/anthropic.claude-instant-v1/invoke + credential: + access_key: "" + secret_key: "" + session_token: "" + parameters: + region: us-west-2 + endpoint: bedrock-runtime.us-west-2.amazonaws.com + content_type: application/json + auth: Sig_V4 + max_tokens_to_sample: '8000' + service_name: bedrock + temperature: '0.0001' + response_filter: "$.completion" + anthropic_version: bedrock-2023-05-31 + - id: register_claude_model + type: register_remote_model + previous_node_inputs: + create_claude_connector: connector_id + user_inputs: + description: Claude model + deploy: true + name: claude-instant + - id: create_alert_summary_with_log_pattern_ml_model_tool + type: create_tool + previous_node_inputs: + register_claude_model: model_id + user_inputs: + parameters: + prompt: " You are an OpenSearch Alert Assistant to help summarize + the alerts.\n Here is the detail of alert: \n ${parameters.context};\n + \ \n And help detect if there is any common pattern + or trend or outlier for the log pattern output. Log pattern groups the + alert trigger logs by their generated patterns, the output contains some + sample logs for each top-k patterns.\n Here is the log + pattern output:\n ${parameters.topNLogPatternData};" + name: MLModelTool + type: MLModelTool + - id: create_alert_summary_with_log_pattern_agent + type: register_agent + previous_node_inputs: + create_alert_summary_with_log_pattern_ml_model_tool: tools + user_inputs: + parameters: {} + type: flow + name: Alert Summary With Log Pattern Agent + description: this is an alert summary with log pattern agent From 09f416acce325048a6e73376d12b94c8eb848e5d Mon Sep 17 00:00:00 2001 From: yuye-aws Date: Tue, 5 Nov 2024 23:08:48 +0800 Subject: [PATCH 2/3] update change log Signed-off-by: yuye-aws --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47f6edd5..dfdc7ed2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) ### Documentation - Add alert summary agent template ([#873](https://github.com/opensearch-project/flow-framework/pull/873)) +- Add alert summary with log pattern agent template ([#945](https://github.com/opensearch-project/flow-framework/pull/945)) ### Maintenance ### Refactoring From 41610771199f2fc23a307711c54584dab2d5c23e Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Tue, 5 Nov 2024 09:38:04 -0800 Subject: [PATCH 3/3] Update alert-summary-log-pattern-agent.json Signed-off-by: Daniel Widdis --- sample-templates/alert-summary-log-pattern-agent.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample-templates/alert-summary-log-pattern-agent.json b/sample-templates/alert-summary-log-pattern-agent.json index dab1ab0c..041518f8 100644 --- a/sample-templates/alert-summary-log-pattern-agent.json +++ b/sample-templates/alert-summary-log-pattern-agent.json @@ -91,4 +91,4 @@ ] } } -} \ No newline at end of file +}