惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
腾讯CDC
Y
Y Combinator Blog
L
LangChain Blog
B
Blog
U
Unit 42
P
Proofpoint News Feed
G
Google Developers Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
WordPress大学
WordPress大学
月光博客
月光博客
Vercel News
Vercel News
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 叶小钗

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Why Quarkus MDC numeric fields silently break OpenSearch ...
Zahan Turel · 2026-05-11 · via DEV Community

Zahan Turel

If you're running Quarkus with JSON logging and shipping to OpenSearch,
there's a non-obvious bug waiting for you: every numeric field you put
in MDC arrives in OpenSearch as a string.

This means queries like durationMs > 1000 silently return nothing.
No error. No warning. Just wrong results.

Here's why it happens and two ways to fix it.

The problem

Quarkus uses JBoss Log Manager under the hood. When you set MDC values:

MDC.put("durationMs", String.valueOf(duration));
MDC.put("fundsProcessed", String.valueOf(count));

Enter fullscreen mode Exit fullscreen mode

The SLF4J MDC API only accepts String. So even if your value is
numeric, it's a string from the moment it enters MDC.

When quarkus-logging-json serializes the log event, it writes the MDC
map as-is — strings in, strings out:

{
  "timestamp": "2026-05-09T05:00:00.000+00:00",
  "message": "Pipeline complete",
  "mdc": {
    "durationMs": "4521",
    "fundsProcessed": "1842",
    "pipeline": "nav_ingestion"
  }
}

Enter fullscreen mode Exit fullscreen mode

OpenSearch infers field types on first index. It sees "4521" and
maps durationMs as keyword. Now you can never do numeric aggregations
or range queries on that field — even if you fix the type later,
existing documents are already mapped wrong.

Fix 1 — Fluent Bit type conversion (collector-side)

If you're using Fluent Bit to ship logs to OpenSearch, you can fix
the types at the collector layer before indexing.

Use a type_converter filter followed by a rename to strip the
temporary suffix:

[FILTER]
    Name          modify
    Match         *
    Rename        durationMs    durationMs_str

[FILTER]
    Name          type_converter
    Match         *
    str_key       durationMs_str  int  durationMs

[FILTER]
    Name          modify
    Match         *
    Remove        durationMs_str

Enter fullscreen mode Exit fullscreen mode

Or with a Lua script for bulk conversion:

function convert_numeric_mdc(tag, timestamp, record)
    local numeric_fields = {"durationMs", "fundsProcessed", "written", "skipped", "failed"}
    for _, field in ipairs(numeric_fields) do
        if record[field] ~= nil then
            record[field] = tonumber(record[field]) or record[field]
        end
    end
    return 1, timestamp, record
end

Enter fullscreen mode Exit fullscreen mode

This works but it's a workaround — you're fixing at the wrong layer,
and you have to maintain the field list in two places.

Fix 2 — Flat MDC fields (coming in Quarkus core)

The cleaner fix is to write MDC fields as root-level JSON keys instead
of nested under "mdc": {}. This lets you define your OpenSearch index
mapping explicitly per field, with the correct type from the start.

This is what PR #54038 adds to quarkus-logging-json:

quarkus.log.console.json.mdc.flat-fields=true

Enter fullscreen mode Exit fullscreen mode

Before (flat-fields=false, default):

{
  "message": "Pipeline complete",
  "mdc": {
    "durationMs": "4521",
    "pipeline": "nav_ingestion"
  }
}

Enter fullscreen mode Exit fullscreen mode

After (flat-fields=true):

{
  "message": "Pipeline complete",
  "durationMs": "4521",
  "pipeline": "nav_ingestion"
}

Enter fullscreen mode Exit fullscreen mode

With flat fields, you can define an explicit OpenSearch index template
that maps durationMs as long regardless of what arrives as a string
— and use an ingest pipeline to do the conversion at index time,
cleanly, once.

The full production setup

Here's the stack that works in production:

  1. Quarkus emits JSON logs with flat-fields=true (once #54038 merges)
  2. Fluent Bit collects with persistent offsets and buffer limits
  3. Fluent Bit type_converter converts known numeric fields
  4. OpenSearch receives correctly-typed documents

The MDC contract I use across all pipelines:

Field Type Description
pipeline string Pipeline identifier
runId string UUID per run
event string started / progress / done / error
stage string Processing stage
status string success / failed / skipped
durationMs long Total run duration
fundsProcessed int Records processed
written int Records written
skipped int Records skipped
failed int Records failed

Full working config (Fluent Bit + docker-compose + OpenSearch 2.x)
is in the repo:
github.com/Zahanturel/quarkus-structured-logging

The flat MDC PR for Quarkus core is at:
quarkusio/quarkus#54038


If you've hit this and solved it differently, I'd like to know —
leave a comment.