Inferensys

Prompt

Log Event Extraction Prompt for SIEM Systems

A practical prompt playbook for security engineers normalizing unstructured logs into SIEM-ready events with mandatory severity, timestamp, and source fields.
Developer building agentic RAG system, retrieval pipeline diagram on laptop, technical workspace with notes.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the ideal operational context, required inputs, and clear boundaries for deploying the log normalization prompt in a production SIEM pipeline.

This prompt is built for security engineers and SOC analysts who need to convert raw, unstructured log entries into structured events that a SIEM can ingest directly. The ideal user is someone managing a heterogeneous log stream—firewall syslog, IDS alerts, cloud audit trails (AWS CloudTrail, GCP Audit Logs), endpoint agent output, or application logs—where each source speaks a different dialect. The job-to-be-done is normalization at ingestion time: taking a raw log line and producing a strictly typed payload in Common Event Format (CEF), Log Event Extended Format (LEEF), or a JSON schema aligned with a common information model. The prompt requires the raw log text, the target output schema, and a known source identifier (e.g., source_product or deviceVendor) as minimum inputs. Without these, the model cannot produce a payload that downstream parsers will accept.

Use this prompt when you control the ingestion pipeline and can validate the output before forwarding to Splunk, QRadar, ArcSight, Microsoft Sentinel, or a similar platform. It is appropriate for batch replay of historical logs, real-time streaming enrichment, or migration projects where legacy log formats must be mapped to a new SIEM schema. The prompt assumes you have already established field-mapping rules or a common information model; it does not invent mappings from scratch. You must supply the mapping contract—either as explicit field lists in the output schema or as reference examples. The prompt handles severity classification, timestamp normalization, and source identification, but it relies on your provided rules for field-level transformations.

Do not use this prompt when the raw log contains sensitive data that cannot be sent to an external model endpoint, unless you are running a local or private deployment with appropriate data handling controls. It is not a replacement for a log parsing engine (e.g., Logstash, Fluentd, Cribl) when the log format is already known and deterministic; regex-based parsers are cheaper and more predictable for static formats. Avoid this prompt for real-time alert generation where latency must be sub-second and model inference time is unacceptable. Finally, do not use it when the target SIEM requires strict schema registry compliance (e.g., Avro with a registered schema) without a post-processing validation step—the prompt produces structured output, but schema enforcement belongs in the application harness, not in the model's generation step.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Log Event Extraction Prompt for SIEM Systems works, where it fails, and what you must provide before using it in production.

01

Strong Fit: Structured SIEM Ingestion

Use when: You have raw, unstructured log lines (syslog, application logs, cloud audit trails) and need them normalized into CEF, LEEF, or a strict JSON schema for Splunk, QRadar, or Sentinel. Guardrail: Define the exact output schema and field mapping before prompting. The model excels at pattern matching against known log formats.

02

Poor Fit: Real-Time Threat Detection

Avoid when: You need sub-second latency for inline intrusion prevention or real-time alerting on raw streams. Guardrail: This prompt is for batch or near-real-time normalization. Pair it with a stream processor; do not put an LLM in the critical path for blocking security controls.

03

Required Inputs: Schema & Taxonomy

Risk: Without a defined severity taxonomy or field dictionary, the model invents categories. Guardrail: Always provide a strict [OUTPUT_SCHEMA] with allowed enum values for severity, event_type, and facility. Include a [FIELD_MAPPING] reference for vendor-specific keys.

04

Operational Risk: Hallucinated Timestamps

Risk: The model may generate a current timestamp if the log line is missing a date, silently corrupting your timeline. Guardrail: Instruct the prompt to use a null or missing sentinel for absent timestamps. Validate timestamps against a realistic window before ingestion.

05

Operational Risk: Source IP Obfuscation

Risk: The model might truncate or mangle IPv6 addresses or non-standard port notations. Guardrail: Include explicit IPv4/IPv6 regex validation in your post-processing harness. Reject events with malformed source or destination fields rather than inserting bad data into the SIEM.

06

Scalability Fit: High-Volume Log Pipelines

Use when: You are processing batches of logs through a message queue (Kafka, Kinesis) and need structured output for downstream analytics. Guardrail: Implement a dead-letter queue for events that fail schema validation. Monitor extraction confidence scores to detect log format drift over time.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for extracting structured, SIEM-ready events from raw log lines, with placeholders for your specific field mappings and severity rules.

This prompt template is the core instruction set you will send to the model. It is designed to take a raw, unstructured log line and a set of configuration parameters, and return a strictly typed JSON event payload suitable for direct ingestion into a SIEM. The template uses square-bracket placeholders for all dynamic parts—your specific log source, your target schema, your severity mapping rules, and your normalization logic. Before using this prompt in any application, you must replace every placeholder with concrete values that match your environment's contracts. Leaving a placeholder unresolved will cause the model to hallucinate or default to an unpredictable behavior, which is unacceptable in a security pipeline.

text
You are a precise log normalization engine. Your task is to parse the provided raw log line and extract a structured security event.

## Input
Raw Log Line:
[RAW_LOG_LINE]

## Configuration
- Log Source Type: [LOG_SOURCE_TYPE]
- Target Output Schema (JSON): [OUTPUT_SCHEMA]
- Timestamp Format in Log: [LOG_TIMESTAMP_FORMAT]
- Target Timestamp Format: ISO 8601 UTC (e.g., '2023-10-05T14:48:00.000Z')
- Severity Mapping Rules:
  [SEVERITY_MAPPING_RULES]
- Field Normalization Rules:
  [FIELD_NORMALIZATION_RULES]
- Default Values for Missing Fields:
  [DEFAULT_VALUES]

## Constraints
- [CONSTRAINTS]

## Instructions
1. Parse the timestamp from the raw log using the provided format and convert it to the target format. If parsing fails, use the current UTC time and set 'timestamp_confidence' to 'low'.
2. Map the log's native severity or priority to a standard scale (e.g., 0-10) using the provided rules. If no rule matches, default to [DEFAULT_SEVERITY] and set 'severity_confidence' to 'low'.
3. Extract all other fields required by the output schema. Apply the normalization rules.
4. For any required field that cannot be found or inferred, use the specified default value and set the corresponding '[field_name]_confidence' to 'absent'.
5. For any optional field that is not present, omit it from the output.
6. Add a top-level 'parser_confidence' field ('high', 'medium', 'low') based on the overall success of extraction and normalization.
7. Output ONLY the valid JSON object. Do not include any explanatory text, markdown fences, or code blocks.

## Output

To adapt this template, start by defining your [OUTPUT_SCHEMA]. This should be a strict JSON schema representing a single event, including required fields like timestamp, source_ip, event_type, and severity. The [SEVERITY_MAPPING_RULES] placeholder is critical; it should contain explicit instructions like 'Map "CRITICAL" to 10, "ERROR" to 8, "WARN" to 5...'. The [CONSTRAINTS] section is where you enforce your SIEM's contract, for example: 'The source_ip field must be a valid IPv4 or IPv6 address. If the log contains a hostname, do not resolve it; leave the field null.' This prompt is designed to be stateless and idempotent, making it safe for retry logic in your ingestion pipeline.

Before integrating this prompt into a production pipeline, you must pair it with a robust validation harness. The model's output should be validated against your [OUTPUT_SCHEMA] in application code. Any validation failure should trigger a retry with a more specific error message, or route the raw log to a dead-letter queue for human review. Never trust the model's parser_confidence field alone as a gate; always enforce schema compliance programmatically. For high-risk security environments, a human-in-the-loop review step is mandatory for all events with a 'low' confidence score or those that fail validation after a single retry.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Log Event Extraction Prompt. Each placeholder must be populated before the prompt is sent to the model. Missing or malformed inputs are the most common cause of extraction failures in production SIEM pipelines.

PlaceholderPurposeExampleValidation Notes

[RAW_LOG_LINE]

The unstructured or semi-structured log entry to extract fields from

2025-01-15T08:23:11.432Z host=web-03 level=ERROR msg="Connection timeout" src_ip=10.0.1.42 dst_ip=192.168.5.17 port=443 duration_ms=30001

Must be a non-empty string. Reject null or whitespace-only input before model call. Truncate at 8K characters to avoid token waste on truncated logs.

[LOG_SOURCE_TYPE]

Identifies the log format or originating system to guide parser selection

syslog_rfc5424

Must match one of the registered source types in the SIEM ingestion pipeline. Validate against an allowed enum before prompt assembly. Unknown source types should route to a generic fallback with lower confidence.

[SIEM_OUTPUT_FORMAT]

Target schema format for the extracted event

CEF

Must be one of: CEF, LEEF, JSON_OCSF, JSON_ELASTIC, JSON_CUSTOM. Reject any other value. This drives field naming, header construction, and required-field enforcement in the output contract.

[TIMESTAMP_FIELD_PRIORITY]

Ordered list of candidate timestamp field names to extract from the raw log

["timestamp", "@timestamp", "time", "event_time", "syslog_timestamp"]

Must be a valid JSON array of strings. First match wins. If no field matches, the prompt must fall back to ingestion time with a flag set to true.

[REQUIRED_FIELDS]

List of fields that must be present or explicitly null in the output

["event_timestamp", "severity", "source_ip", "event_type", "message"]

Must be a valid JSON array of strings. Each field must appear in the output schema. Missing required fields after extraction should trigger a repair retry or dead-letter queue routing.

[SEVERITY_MAPPING]

Mapping from source log severity strings to SIEM standard severity levels

{"ERROR": "High", "WARN": "Medium", "INFO": "Low", "DEBUG": "Informational", "CRITICAL": "Critical"}

Must be a valid JSON object. Unmapped severity values should default to "Unknown" with a confidence note. Validate that all expected source severities have explicit mappings before production deployment.

[CUSTOM_FIELD_MAP]

Mapping from raw log field names to target SIEM field names when they differ

{"src_ip": "sourceAddress", "dst_ip": "destinationAddress", "msg": "message", "level": "raw_severity"}

Must be a valid JSON object. Unmapped fields should be dropped or placed in an extensions block. Null is acceptable if no custom mapping is needed. Validate that target field names exist in the output schema.

[CONFIDENCE_THRESHOLD]

Minimum per-field confidence score before a value is accepted without flagging

0.85

Must be a float between 0.0 and 1.0. Fields below this threshold should be included with a low_confidence flag set to true. A threshold of 0.0 disables confidence gating. Validate range before prompt assembly.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the log event extraction prompt into a production SIEM ingestion pipeline with validation, retries, and human review gates.

This prompt is designed to sit inside a log normalization microservice or an event processing function that receives raw log lines and emits structured SIEM events. The typical call flow is: receive a raw log string, assemble the prompt with the log text and your SIEM field mapping contract, call the model, validate the output JSON against your expected schema, and either publish the event to your SIEM or route it to a dead letter queue for human review. Because security operations cannot tolerate hallucinated severity levels or missing timestamps, the implementation harness must enforce strict post-processing before any event reaches the SIEM.

Start by defining a JSON Schema that matches your SIEM's required fields. At minimum, validate that timestamp is present and parseable as ISO 8601, severity is one of your allowed enum values (e.g., INFO, LOW, MEDIUM, HIGH, CRITICAL), and source contains a non-empty identifier. Use a validation library like ajv (JavaScript) or pydantic (Python) to reject malformed outputs before ingestion. If the model returns a confidence score below your threshold—typically 0.7 for automated ingestion—route the event to a review queue rather than publishing it directly. For high-severity events (HIGH or CRITICAL), consider requiring human approval regardless of confidence, since false positives at those levels trigger on-call escalations.

Model choice matters here. Use a model with strong JSON mode support and low latency, since log pipelines often process high volumes. GPT-4o or Claude 3.5 Sonnet work well for low-to-medium throughput use cases; for higher throughput, consider a fine-tuned smaller model that has been trained on your specific log formats and field mappings. Implement retries with exponential backoff when the model returns invalid JSON or fails schema validation, but cap retries at three attempts to avoid queue backpressure. Log every extraction attempt—including the raw log, the model's raw response, validation errors, and the final published or quarantined event—so your security team can audit the pipeline and trace any missed or miscategorized events back to their source.

When wiring this into a streaming pipeline like Kafka, use the log source and timestamp as the partition key to preserve ordering for related events. If your SIEM expects CEF or LEEF format rather than JSON, add a post-processing transformation layer that converts the validated JSON output into the required key-value format. Never pass unvalidated model output directly to your SIEM; a single hallucinated field can corrupt dashboards, trigger false alerts, or mask real incidents. The prompt is the extraction engine, but the harness is what makes it production-safe.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact shape, types, and validation rules for the SIEM event payload the model must produce. Use this contract to build a post-processing validator before ingestion.

Field or ElementType or FormatRequiredValidation Rule

event_timestamp

ISO 8601 UTC string

Must parse to a valid datetime. Reject if original log timestamp is unparseable or missing.

severity

Integer 0-10

Must be an integer within the inclusive range. Map from extracted severity string using a predefined lookup table.

source_ip

String (IPv4 or IPv6)

Must match a valid IP address regex. Set to null only if the log contains no IP-like value.

event_type

String (enum)

Must exactly match one of the allowed event type codes defined in the SIEM information model.

raw_log

String

Must be the original, unmodified log line. Reject the entire payload if this field is truncated or missing.

normalized_message

String

Must not be empty. If no meaningful message can be extracted, set to a default description and set confidence to low.

destination_service

String

If present, must be a non-empty string. If the log context does not identify a destination service, this field must be absent, not an empty string.

extraction_confidence

Number (0.0-1.0)

Must be a float between 0 and 1. If any required field is inferred or repaired, confidence must be < 1.0 and a note added to confidence_notes.

PRACTICAL GUARDRAILS

Common Failure Modes

Log event extraction for SIEM systems is brittle. Unstructured logs, inconsistent formats, and strict downstream schemas create predictable failure points. These are the most common breaks and how to guard against them before they poison your security pipeline.

01

Timestamp Ambiguity and Drift

What to watch: The model parses a timestamp but guesses the wrong timezone, misinterprets a US vs. EU date format (MM/DD vs. DD/MM), or fails to normalize to UTC. A single mis-parsed timestamp can reorder attack sequences or break SIEM correlation rules. Guardrail: Require the prompt to output both the raw extracted string and the normalized ISO 8601 UTC value. Add a post-extraction validator that rejects any timestamp where the original and normalized values are more than 24 hours apart without an explicit timezone offset in the source.

02

Severity Misclassification

What to watch: The model assigns severity: "High" to a routine informational log line because the text contains words like "error" or "failure" in a non-critical context. Conversely, it may downgrade a subtle privilege escalation because the log language is benign. Guardrail: Provide a strict severity rubric in the prompt with explicit criteria and counterexamples. Implement a post-extraction rule that flags any High or Critical event missing a known attack indicator or error code, routing it for human review before alerting.

03

Missing or Hallucinated Mandatory Fields

What to watch: The SIEM contract requires source_ip, event_id, and log_source, but the raw log line is incomplete. The model hallucinates a placeholder like 127.0.0.1 or N/A to satisfy the schema, creating false positives and corrupting dashboards. Guardrail: Instruct the prompt to use explicit null for truly absent fields and a separate field_confidence score. Add a pre-ingestion validator that rejects any payload where a mandatory field is non-null but has a confidence score below 0.9, sending it to a dead-letter queue.

04

CEF/LEEF Header Format Drift

What to watch: The model produces syntactically invalid CEF or LEEF output—missing the required pipe-delimited prefix, escaping special characters incorrectly, or inserting spaces where the spec forbids them. The SIEM silently drops the event. Guardrail: Include the exact CEF or LEEF header template in the prompt as a non-negotiable format constraint. Run a strict regex validator against the output before ingestion that checks the header structure, pipe count, and escape sequences, rejecting any non-conforming payload immediately.

05

Source IP and Hostname Confusion

What to watch: The log line contains multiple IP addresses (source, destination, proxy, NAT gateway). The model assigns the wrong IP to the source field, misattributing the origin of an attack. Guardrail: Add a disambiguation rule to the prompt: "If multiple IPs are present, use the leftmost IP before the first '>' or space as the source. If a proxy header is present, prefer X-Forwarded-For with explicit reasoning." Require the model to output a source_ip_rationale field for auditability.

06

Multi-Line Log Truncation

What to watch: A stack trace, XML payload, or multi-line event is passed to the prompt, but the model only processes the first line, missing the actual error code or attack payload buried deeper. Guardrail: Explicitly instruct the prompt to process the entire input, including line breaks and indented blocks. Add a pre-processing step that collapses multi-line logs into a single line with escaped newlines (\n) and a length check to ensure the collapsed input matches the original character count before extraction.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of the Log Event Extraction Prompt's output before integrating it into a production SIEM pipeline. Each criterion targets a specific failure mode common to unstructured log normalization.

CriterionPass StandardFailure SignalTest Method

Schema Compliance

Output is valid JSON matching the [OUTPUT_SCHEMA] exactly. All required fields are present.

JSON parsing error, missing mandatory fields like timestamp or severity, or extra unexpected fields.

Parse output with a JSON schema validator using the provided [OUTPUT_SCHEMA]. Assert no validation errors.

Timestamp Normalization

The timestamp field is a valid ISO 8601 string in UTC, correctly converted from the raw log.

Timestamp is missing, in the wrong timezone, an ambiguous format, or an unparsed string copy of the input.

Parse the timestamp field with a datetime library. Assert it is timezone-aware and matches the expected UTC time.

Severity Mapping

The severity field is an integer from 0-10 mapped correctly from the log's verbatim level per the [SEVERITY_MAP].

Severity is a string, a number outside 0-10, or a generic mapping like 'INFO' to 5 instead of the specified value.

Assert severity is an integer between 0 and 10. For a known input, assert the exact mapped integer value.

Source IP Extraction

The source_ip field contains a valid IPv4 or IPv6 address extracted from the log, or null if no IP is present.

Field contains a hostname instead of an IP, a malformed IP string, or a non-null value when the log has no IP.

Validate the string with an IP address regex. Assert it is null for a log sample known to have no IP address.

Null vs. Empty String Handling

Missing data is represented as null. Intentionally blank values are represented as empty strings "".

A missing value is represented as an empty string, or a blank value is incorrectly set to null.

Provide a log with a blank username field and a log with no username field. Assert the output is "" and null respectively.

CEF/LEEF Header Formatting

The header field is a valid CEF or LEEF string with pipe-escaped values and correct version prefix.

The header is missing the required prefix, has an incorrect number of pipe-delimited fields, or contains unescaped special characters.

Assert the header string starts with the correct CEF/LEEF prefix and that splitting by | yields the expected number of fields.

Confidence Annotation

The extraction_confidence field is a float between 0.0 and 1.0, and is below 0.8 for any ambiguous or fuzzy field.

Confidence is always 1.0, is outside the 0-1 range, or is high for a field that was clearly not present in the log.

For a log with a misspelled severity keyword, assert that extraction_confidence for the severity field is less than 0.8.

Source Grounding

The source_span field contains the exact text substring from the log that was used to extract the primary event fields.

The source span is hallucinated, is a paraphrased summary, or points to a part of the log that doesn't contain the extracted data.

For a known log line, assert that output.source_span is a substring of the [INPUT_LOG] and contains the key data.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base extraction prompt and a simple JSON schema. Use a single example log line in the prompt to demonstrate the expected output shape. Skip strict validation—just check that timestamp, severity, and source fields are present. Run against 10-20 representative log samples and manually review output.

Prompt modification

code
Extract the following fields from this log line into JSON:
- timestamp (ISO 8601)
- severity (INFO, WARN, ERROR, CRITICAL)
- source (hostname or IP)
- event_type
- message

Log: [LOG_LINE]

Watch for

  • Timestamps parsed in wrong timezone
  • Severity guessed from message text rather than log level field
  • Source field picking up wrong IP when multiple appear
  • Missing fields silently dropped instead of marked null
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.