cd /news/ai-tools/show-hn-intelligent-log-sanitization… Β· home β€Ί topics β€Ί ai-tools β€Ί article
[ARTICLE Β· art-66528] src=github.com β†— pub= topic=ai-tools verified=true sentiment=↑ positive

Show HN: Intelligent Log Sanitization and logs to metrics

LogGuardAI, a Log4j2 plugin that automatically detects and masks sensitive data in Java logs using rule-based analysis and AI, has been released on May 27, 2026. The tool supports 20+ sensitive keyword detection, smart risk scoring, and logs-to-metrics extraction for Prometheus-style monitoring, with AI-powered sanitization via OpenAI, Anthropic Claude, or Azure OpenAI.

read7 min views7 publishedJul 21, 2026
Show HN: Intelligent Log Sanitization and logs to metrics
Image: source

Intelligent Log Sanitization for Java β€” Automatically detect and mask sensitive data in logs using rule-based analysis and AI.

LogGuardAI is a Log4j2 plugin that intercepts log events and intelligently sanitizes them to prevent accidental exposure of sensitive data like passwords, API keys, tokens, and personal information. It also supports logs-to-metrics extraction for Log4j2, converting log lines into Prometheus-style metrics using custom regex patterns.

❌ Logs with secrets:
  [LOG] User auth: userId=12345 apiKey=sk-abcdef123456 password=secret
        ↑ Oops! Now this secret is in logs, monitoring dashboards, and backups!
βœ… Logs with LogGuardAI:
  [LOG] User auth: userId=***** apiKey=***** password=*****
        ↑ Secrets automatically masked, structure preserved!
  • πŸ” 20+ Sensitive Keyword Detectionβ€” Automatically detects passwords, tokens, API keys, etc. - πŸ“Š Smart Risk Scoringβ€” Multi-factor analysis (keywords, patterns, entropy) - ⚑ Lightning Fastβ€” <5ms latency, non-blocking design - πŸ›‘οΈ Fail-Safeβ€” Logging never breaks, even if something fails - πŸ“ Structured Data Supportβ€” Handles key=value, JSON, query strings

  • 🧠 AI-Powered Sanitizationβ€” OpenAI GPT-based intelligent masking with context - πŸ’° LRU Cachingβ€” 80-95% cache hit rate =** 80% cost savings** - πŸ† Enhanced Exceptionsβ€” AI explains what went wrong - πŸ” Data Classificationβ€” Automatically identify PII vs. sensitive data - πŸ“Š Configurable Samplingβ€” Control AI costs (5%-100%)

πŸ“¦

Batch AI Processingβ€” Process multiple sensitive values together (5x efficiency) - ⚑

Async/Non-Blockingβ€” AI calls never block log threads (<5ms guaranteed) - πŸ”„

Smart Fallbacksβ€” Rule-based masking if AI fails or times out - πŸ›

Spring Boot Compatibilityβ€” Fixed Log4j2 plugin registration issues

  • πŸ€– Multi-Provider AIβ€” OpenAI, Anthropic Claude, or Azure OpenAI - πŸ—οΈ Anthropic Claude Integrationβ€” Claude 3 models with Messages API - ☁️ Azure OpenAI Integrationβ€” Custom endpoints and deployments - πŸ”§ Provider-Specific Configurationβ€” Azure endpoints, deployments, API versions - 🏷️ Enhanced Model Supportβ€” GPT-4, Claude 3, Azure deployments - πŸ“Š Configurable Batch Sizeβ€” Tune performance vs. API efficiency - πŸ€– Multi-Provider Supportβ€” OpenAI, Anthropic Claude, Azure OpenAI - πŸ“ˆ Metrics Extractionβ€” Convert legacy unstructured logs into rich JSON metrics. - πŸ—οΈ Backward Compatibleβ€” Existing configurations work unchanged

Released: May 27, 2026

  • πŸ“Š Pattern-Based Metricsβ€” Define custom regex patterns to extract metrics directly from logs - 🎯 User-Defined Patternsβ€” Create metrics for HTTP requests, FTP transfers, database queries, etc. - πŸ’Ύ Append-Only Fileβ€” Metrics stored in Prometheus text format with cumulative history - πŸ“ˆ Logs-to-Metrics Conversionβ€” Convert Log4j2 log entries into counters and labels for monitoring and alerting - βš™οΈ Periodic Flushingβ€” Configurable flush interval (default: 60 seconds) - πŸ” Cardinality Protectionβ€” Configurable limits prevent unbounded metric combinations (default: 10,000) - πŸ”Œ Zero Dependenciesβ€” No external monitoring infrastructure required
<LogGuardLayout 
  extractMetrics="true"
  metricsFilePath="logs/metrics.txt"
  metricsFlushIntervalMs="60000"
  metricsMaxCardinality="10000"
  metricsPatterns="http_requests|(GET|POST|DELETE) ([/\\w/]+) (\\d{3})|http_requests_total|method,endpoint,status"/>

See Metrics Configuration for full configuration details and examples.

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.logguardai</groupId>
    <artifactId>logguardai</artifactId>
    <version>0.5.0</version>  <!-- Latest: Logs to metrics -->
</dependency>
<Configuration>
  <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <LogGuardLayout/>
    </Console>
  </Appenders>

  <Loggers>
    <Root level="info">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>

Tip: To enable pattern-based metrics, set extractMetrics="true"

and configure metricsFilePath

, metricsFlushIntervalMs

, metricsMaxCardinality

, and metricsPatterns

as shown in the v0.5 section above.

LogGuardAI v0.5 makes it easy to transform Log4j2 log messages into Prometheus-compatible metrics. Use metricsPatterns

to extract method, endpoint, status, latency, and other useful labels from structured log lines.

Example: convert request logs into a counter metric for http_requests_total

with labels like method

, endpoint

, and status

.

This is ideal for:

  • Log4j2 metrics extraction
  • Logs-to-metrics pipelines
  • Prometheus text metric generation from application logs
  • Regex-based log analytics without external agents
<!-- OpenAI (default) -->
<LogGuardLayout
    aiEnabled="true"
    aiProvider="openai"
    aiApiKey="${OPENAI_API_KEY}"
    aiModel="gpt-3.5-turbo"
    samplingRate="0.1"
    extractMetrics="true"
    batchSize="5"/>

<!-- Anthropic Claude -->
<LogGuardLayout
    aiEnabled="true"
    aiProvider="anthropic"
    aiApiKey="${ANTHROPIC_API_KEY}"
    aiModel="claude-3-sonnet-20240229"
    samplingRate="0.1"
    batchSize="5"/>

<!-- Azure OpenAI -->
<LogGuardLayout
    aiEnabled="true"
    aiProvider="azure-openai"
    aiApiKey="${AZURE_OPENAI_API_KEY}"
    aiModel="gpt-35-turbo"
    azureEndpoint="https://your-resource.openai.azure.com"
    azureDeployment="your-deployment-name"
    azureApiVersion="2023-12-01"
    samplingRate="0.1"
    batchSize="5"/>
Feature v0.1 v0.2 v0.3 v0.4 v0.5
Rule-Based Masking
βœ… βœ… βœ… βœ… βœ…
AI Sanitization
❌ βœ… βœ… βœ… βœ…
LRU Caching
❌ βœ… βœ… βœ… βœ…
Batch Processing
❌ ❌ βœ… βœ… βœ…
Async/Non-Blocking
❌ ❌ βœ… βœ… βœ…
Multi-Provider AI
❌ ❌ ❌ βœ… βœ…
Metrics Extraction
❌ ❌ ❌ ❌ βœ… (pattern-based)
Latency
<5ms <5ms (rule-based) ~1500ms (API) <1ms (cached)
<5ms guaranteed <5ms guaranteed <5ms guaranteed
Cost/10M logs
$0 $95 (no cache) $19 (with cache)
$15-20 (with batching) $15-20 (with batching) $15-25 (depends on metrics config)
Dependencies
0 0 new 0 new 0 new 0 new
Backward Compatible
N/A βœ… 100% βœ… 100% βœ… 100% βœ… 100%
Logger logger = LoggerFactory.getLogger("MyApp");

// This will be automatically sanitized by LogGuardAI:
logger.info("User login: userId=12345 token=sk-abcdef123 password=secret");

// Output:
// User login: userId=***** token=***** password=*****

Development (AI Testing)

<LogGuardLayout aiEnabled="true" aiProvider="openai" samplingRate="0.05" aiTimeoutMs="1000" batchSize="3"/>
<!-- Or with Anthropic: aiProvider="anthropic" aiModel="claude-3-haiku-20240307" -->

Production (Balanced)

<LogGuardLayout aiEnabled="true" aiProvider="openai" samplingRate="0.1" aiTimeoutMs="2000" batchSize="5"/>
<!-- Or with Azure: aiProvider="azure-openai" azureEndpoint="..." azureDeployment="..." -->

High-Security (Premium)

<LogGuardLayout aiEnabled="true" aiProvider="openai" aiModel="gpt-4" samplingRate="1.0" batchSize="10"/>
<!-- Or with Claude: aiProvider="anthropic" aiModel="claude-3-sonnet-20240229" -->

Fast (No AI)

<LogGuardLayout aiEnabled="false"/>  <!-- v0.1 behavior -->

β€” 5-minute setup (with AI examples)Quick Start Guideβ€” Deep dive into AI features (3000+ words)AI Integration Guideβ€” v0.1 β†’ v0.2 upgrade pathMigration Guide

β€” All configuration optionsConfiguration Referenceβ€” Common issues & solutionsTroubleshootingβ€” Code organizationProject Structure

β€” How LogGuardAI worksSystem Overviewβ€” Detailed component descriptionsComponentsβ€” Interface referenceAIService API

β€” Complete version historyCHANGELOGβ€” v0.2 featuresv0.2.0 Release Notesβ€” Previous versionv0.1.0 Docs

β€” How to publishJitPack Publishing

// Transaction logs with credit card & billing info
logger.info("Transaction: user_id={} amount={} card={} crypto_key={}",
    userId, amount, creditCard, encryptionKey);
// Automatically masked! βœ…
// Auth logs with tokens & credentials
logger.info("Auth attempt: username={} password={} jwt_token={}",
    username, password, jwtToken);
// All masked automatically! βœ…
// Headers & API keys
logger.info("Incoming request: Authorization={} X-API-Key={} User-Agent={}",
    bearerToken, apiKey, userAgent);
// Headers sanitized intelligently! βœ…

Also: use metricsPatterns

to extract request counts, paths and status codes for lightweight in-app metrics collection.

Rule-Based Path:  <5ms    (fast, no external calls)
AI Hit (cached):  <1ms    (in-memory cache)
AI Miss (API):    ~1.5s   (to OpenAI, happens ~20% with 80% cache hit rate)
Without AI:              $0/month   (rule-based only)
With AI (no cache):      $95/month  (5% sampling)
With AI + caching:       $19/month  (5% sampling, 80% cache hits)
Savings:                 80%
Rule-Based Only:        >50,000 logs/sec
With AI Sampling:       >45,000 logs/sec (minimal impact)
With Caching:           >100,000 logs/sec (cached dominate)

βœ… Secrets Never Exposed

  • API keys, passwords, tokens, PII automatically masked
  • Fail-safe: if LogGuard fails, logging still works (never breaks!)
  • Timeout protection: no hanging requests

βœ… API Key Protection

  • API key stored in environment variable, never hardcoded
  • No logs sent to external services (caching keeps results locally)

βœ… Non-Blocking Design

  • Independent executor for AI calls

  • No thread blocking

  • Application never slows down

  • Java 8+

  • Maven 3.6+

mvn clean package
mvn test
ls target/logguardai-0.5.0.jar
Version Release Date Status What's New
v0.5.0
2026-05-27 βœ… Latest Pattern-Based Metrics (user-defined regex metrics)
v0.4.0
2026-05-03 βœ… Stable Multi-Provider AI Support
v0.3.0
2026-05-01 βœ… Stable Plugin Registration Fix
v0.2.0
2026-04-23 βœ… Stable AI + Caching
v0.1.0
2026-04-22 βœ… Stable Rule-based masking

β†’ See CHANGELOG for complete history

Contributions welcome! Please:

  • Fork the repository
  • Create a feature branch
  • Add tests for new features
  • Submit a pull request

Questions?GitHub Discussions** Report Issues:GitHub Issues Full Documentation:**docs/README.md

MIT License - See LICENSE for details

Get Started→Quick Start Guide** Enable AI→AI Integration Guide Configure→Configuration Reference Troubleshoot**→Troubleshooting Guide

LogGuardAI: Secure your logs. Automatically.

Built with ❀️ by sanitizeai

── more in #ai-tools 4 stories Β· sorted by recency
── more on @logguardai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/show-hn-intelligent-…] indexed:0 read:7min 2026-07-21 Β· β€”