OpenAI
Synopsis
Enriches events by sending field content to OpenAI's API for analysis and stores the response.
Schema
- openai:
field: <ident>
api_key: <string>
base_url: <string>
target_field: <ident>
prompt: <string>
developer_msg: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
model: <string>
temperature: <number>
max_tokens: <number>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
field | N | message | Field containing content to analyze |
api_key | N | ${OPENAI_SECRET_KEY} | OpenAI API key for authentication |
base_url | N | https://api.openai.com/v1/chat/completions | API endpoint URL |
target_field | N | field | Field to store the API response |
prompt | N | Return the context of the message. | Analysis prompt sent with the field content |
developer_msg | N | - | System context message for the AI |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue if API call fails |
ignore_missing | N | false | Continue if source field doesn't exist |
model | N | gpt-3.5-turbo | OpenAI model to use |
temperature | N | 0.7 | Response randomness (0-1) |
max_tokens | N | 1000 | Maximum response length |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
disabled | N | false | When true, the processor is skipped and the event continues to the next one. Lets you take a processor out of the path without removing its configuration |
Details
This processor is useful for automated analysis, context enrichment, and intelligent processing of log data. It supports system context messages generated for analysis, temperature control for response variation, and token limits for response length management.
System messages help guide the AI's analysis.
Multiple models can be accessed, and responses can be configured. Lower temperature values produce more focused responses.
Token limits control response length and costs. Consider rate limits and costs for high-volume processing, as long input texts may hit token limits.
Responses are not cached. Every event that reaches this processor makes its own API call, so the latency and the per-token cost are paid per event. Gate it with if so only the events that need analysis reach it.
Error recovery options and success/failure handing are also available.
API keys should be securely stored and accessed.
Examples
Basic
Analyzing a Cisco device log... | |
adds information to the event: | |
Precision
Fine-tuning analysis parameters... | |
produces more focused security insights: | |
Conditionals
Analyzing only critical errors... | |
is preferable due to level: | |
Error Handling
Anticipating API failures... | |
continues execution: | |