LogPipeline.devv2.0

Log Extraction & Pipeline Architect

50 Templates Catalog
Containers & Kubernetes100% Verified RegexZero-Allocation Web Worker

Kubernetes Kube-APIServer Audit Event Log Parser

Parse Kubernetes API audit logs to monitor RBAC operations, secret access, and pod creation events. Test pattern matching, inspect named capture groups, and export production-ready parser definitions across Fluent Bit, Vector VRL, Datadog Pipelines, Logstash, and OpenTelemetry.

Live Interactive Debugger & Generator

Matches execute locally in-browser via Web Worker
Interactive Test & Config Generator Sandbox
Extraction Pattern (Grok / PCRE Expression)
Pattern Valid (7 fields)
Detected Fields:kindapi_versionlevelstagerequest_uriverbusername
Raw Log Stream Sandbox(0/3 matched)
No log lines provided. Paste lines or select a preset above.
No matching lines available to generate JSON output.
Parsed 0/3 lines0 ms (0 μs)
ReDoS Risk: SAFE
AdvertisementActive Viewability 30s

Log Architecture & Structural Overview

The Kubernetes Kube-APIServer Audit Event Log Parser is an essential telemetry stream within the Containers & Kubernetes ecosystem. Parse Kubernetes API audit logs to monitor RBAC operations, secret access, and pod creation events.

This schema defines a structure of 7 extracted attributes, including 0 numeric metrics and 7 string dimensions. In production observability architectures, these tokens provide high-cardinality indexing keys for telemetry pipelines before shipping to storage backends such as ClickHouse, Elasticsearch, Amazon S3, or Datadog.

Raw Telemetry Ingestion Profile

A typical raw event line for kubernetes-api-audit averages 204 bytes across 7 tokens. Modern collectors such as Fluent Bit and Vector require zero-backtracking regular expressions to avoid CPU spikes during traffic surges.

Extracted Field Schema & Data Types

The transpiled Grok pattern extracts the following schema fields from each raw event line. Data collectors cast these values according to the typed mappings below.

Field NameInferred TypeDescription & Collector Semantics
kindstringKubernetes resource kind (Event).
api_versionstringAudit API schema version.
levelstringAudit event detail level (None, Metadata, Request, RequestResponse).
stagestringExecution stage (RequestReceived, ResponseStarted, ResponseComplete).
request_uristringKubernetes API endpoint accessed.
verbstringAPI action (get, list, create, update, delete, watch).
usernamestringIdentity of user or ServiceAccount invoking the API.

Common Regex Traps & Production Edge Cases

Engineers frequently encounter ingestion failures or pipeline drops due to subtle variations in real-world event logs. Watch out for these verified pitfalls:

1Audit logs produce massive throughput. Apply strict audit policy filters to ignore frequent read-only events (e.g. node heartbeats).
2Full RequestResponse level records contain entire YAML bodies and can exceed 100KB per event.

Production Collector Setup & Configurations

Pre-configured parser definitions ready to be dropped into your infrastructure repository.

Fluent Bit (parsers.conf)

Format: regex
# ==============================================================================
# Fluent Bit Parser Configuration (parsers.conf)
# ==============================================================================
[PARSER]
    Name        logpipeline_parser
    Format      regex
    Regex       ^\{"kind":"(?<kind>\b\w+\b)","apiVersion":"(?<api_version>\S+)","level":"(?<level>\b\w+\b)","stage":"(?<stage>\b\w+\b)","requestURI":"(?<request_uri>\S+)","verb":"(?<verb>\b\w+\b)","user":\{"username":"(?<username>.*?)"\}\}$
    Time_Key    timestamp
    Time_Format %Y-%m-%dT%H:%M:%S%z

# ==============================================================================
# Fluent Bit Pipeline Filter (fluent-bit.conf)
# ==============================================================================
[FILTER]
    Name         parser
    Match        *
    Key_Name     log
    Parser       logpipeline_parser
    Reserve_Data On

Vector.dev (Remap VRL)

parse_regex!
# ==============================================================================
# Vector.dev Remap Language (VRL) Transform
# Use inside a 'remap' transform in vector.yaml
# ==============================================================================
.parsed, err = parse_regex(.message, r'^\{"kind":"(?<kind>\b\w+\b)","apiVersion":"(?<api_version>\S+)","level":"(?<level>\b\w+\b)","stage":"(?<stage>\b\w+\b)","requestURI":"(?<request_uri>\S+)","verb":"(?<verb>\b\w+\b)","user":\{"username":"(?<username>.*?)"\}\}$')

if err == null {
    . = merge(., .parsed)
    del(.parsed)

} else {
    log("LogPipeline parsing warning: " + err, level: "warn")
}

# ==============================================================================
# vector.yaml Pipeline Component
# ==============================================================================
transforms:
  parse_logs:
    type: remap
    inputs: ["source_logs"]
    source: |
      .parsed, err = parse_regex(.message, r'^\{"kind":"(?<kind>\b\w+\b)","apiVersion":"(?<api_version>\S+)","level":"(?<level>\b\w+\b)","stage":"(?<stage>\b\w+\b)","requestURI":"(?<request_uri>\S+)","verb":"(?<verb>\b\w+\b)","user":\{"username":"(?<username>.*?)"\}\}$')
      if err == null {
        . = merge(., .parsed)
        del(.parsed)
      }

Datadog Log Pipeline Grok Parser

match_rules
# ==============================================================================
# Datadog Log Processing Pipeline Grok Parser
# Navigate to: Logs -> Configuration -> Pipelines -> Add Processor -> Grok Parser
# ==============================================================================

# Match Rule:
rule \{"kind":"%{WORD:kind}","apiVersion":"%{NOTSPACE:api_version}","level":"%{WORD:level}","stage":"%{WORD:stage}","requestURI":"%{NOTSPACE:request_uri}","verb":"%{WORD:verb}","user":\{"username":"%{DATA:username}"\}\}

# Complete Datadog Pipeline Processor JSON:
{
  "type": "grok-parser",
  "name": "LogPipeline Grok Parser",
  "is_enabled": true,
  "source": "message",
  "samples": [],
  "grok": {
    "match_rules": "rule \\{\"kind\":\"%{WORD:kind}\",\"apiVersion\":\"%{NOTSPACE:api_version}\",\"level\":\"%{WORD:level}\",\"stage\":\"%{WORD:stage}\",\"requestURI\":\"%{NOTSPACE:request_uri}\",\"verb\":\"%{WORD:verb}\",\"user\":\\{\"username\":\"%{DATA:username}\"\\}\\}",
    "support_rules": ""
  }
}

# Target Fields Created:
# kind (string), api_version (string), level (string), stage (string), request_uri (string), verb (string), username (string)

OpenTelemetry Collector (transform processor)

regex_parser
# ==============================================================================
# OpenTelemetry Collector Configuration (otel-collector-config.yaml)
# Option 1: Filelog Receiver with regex_parser Operator
# ==============================================================================
receivers:
  filelog:
    include: [ /var/log/**/*.log ]
    start_at: beginning
    operators:
      - type: regex_parser
        id: logpipeline_regex_parser
        regex: '^\{"kind":"(?<kind>\b\w+\b)","apiVersion":"(?<api_version>\S+)","level":"(?<level>\b\w+\b)","stage":"(?<stage>\b\w+\b)","requestURI":"(?<request_uri>\S+)","verb":"(?<verb>\b\w+\b)","user":\{"username":"(?<username>.*?)"\}\}$'
        timestamp:
          parse_from: attributes.timestamp
          layout: '%Y-%m-%dT%H:%M:%S%z'

# ==============================================================================
# Option 2: Transform Processor (OTel Transformation Language - OTTL)
# ==============================================================================
processors:
  transform:
    error_mode: ignore
    log_statements:
      - context: log
        statements:
          - merge_maps(attributes, extract_patterns(body, "^\\{\"kind\":\"(?<kind>\\b\\w+\\b)\",\"apiVersion\":\"(?<api_version>\\S+)\",\"level\":\"(?<level>\\b\\w+\\b)\",\"stage\":\"(?<stage>\\b\\w+\\b)\",\"requestURI\":\"(?<request_uri>\\S+)\",\"verb\":\"(?<verb>\\b\\w+\\b)\",\"user\":\\{\"username\":\"(?<username>.*?)\"\\}\\}$"), "insert")

service:
  pipelines:
    logs:
      receivers: [filelog]
      processors: [transform]
      exporters: [otlp]

Logstash Filter Configuration

filter.grok
# ==============================================================================
# Logstash Pipeline Configuration (/etc/logstash/conf.d/logpipeline.conf)
# ==============================================================================
filter {
  grok {
    match => { "message" => "\{\"kind\":\"%{WORD:kind}\",\"apiVersion\":\"%{NOTSPACE:api_version}\",\"level\":\"%{WORD:level}\",\"stage\":\"%{WORD:stage}\",\"requestURI\":\"%{NOTSPACE:request_uri}\",\"verb\":\"%{WORD:verb}\",\"user\":\{\"username\":\"%{DATA:username}\"\}\}" }
    tag_on_failure => [ "_grokparsefailure" ]
  }

  date {
    match => [ "timestamp", "ISO8601", "dd/MMM/yyyy:HH:mm:ss Z" ]
    target => "@timestamp"
    remove_field => [ "timestamp" ]
  }
}