i have this log : [{"date":1747652405.197626,"time...
Created on: May 19, 2025
Created on: May 19, 2025
i have this log :
[{"date":1747652405.197626,"time":"2025-05-19T11:00:05.1972488Z","message":"requestId: 0HNCMNLI27C5L:00000003, previousRequestId: No PreviousRequestId, message: '406 (Not Acceptable) status code of request URI: http://idr-webapi/Web/IDR/hc/live.'","level":"Warning","State":"requestId: 0HNCMNLI27C5L:00000003, previousRequestId: No PreviousRequestId, message: '406 (Not Acceptable) status code of request URI: http://idr-webapi/Web/IDR/hc/live.'","SourceContext":"Ocelot.Requester.Middleware.HttpRequesterMiddleware","RequestId":"0HNCMNLI27C5L:00000003","RequestPath":"/web/idr/hc/live","EnvironmentName":"stage","TraceId":"4614c2575ff4e48172fc9786f0ab782e","HttpContext":{"Request":{"Body":null,"Method":"GET","Protocol":"HTTP/1.1","Scheme":"http","IsHttps":false,"Host":"vendorgw.tapsi.shop","PathBase":"","Path":"/web/idr/hc/live","ContentLength":null,"ContentType":null,"Query":{},"Headers":{"Host":"vendorgw.tapsi.shop","User-Agent":"Blackbox Exporter/0.25.0","X-Request-ID":"b75ec32f066aae8301c3ad06f112fe9c","X-Real-IP":"188.121.100.72","X-Forwarded-For":"188.121.100.72","X-Forwarded-Host":"vendorgw.tapsi.shop","X-Forwarded-Port":"443","X-Forwarded-Proto":"https","X-Forwarded-Scheme":"https","X-Scheme":"https","X-Original-Forwarded-For":"188.121.100.72"},"Cookies":{},"Form":null,"FormFiles":null,"type":"HttpContextInformationRequest"},"Connection":{"Id":"0HNCMNLI27C5L","IpAddress":"188.121.100.72","RemoteIpAddress":"10.42.17.48","LocalIpAddress":"10.42.12.71","type":"HttpContextInformationConnection"},"User":{"Username":null,"UserId":null,"type":"HttpContextInformationUser"},"TraceIdentifier":"0HNCMNLI27C5L:00000003","type":"HttpContextInformation"},"CorrelationId":null,"clientname":null,"clientversion":null,"MachineName":"vendorgw-89c59d447-6gkmx","EnvironmentUserName":"vendorgw-89c59d447-6gkmx\root","ApplicationName":"HIT.Hastim.Gateway.Vendor.Web"}]
i want to use json to json or nest json
and i have filed for into json to json
i want to config for fluent-bit
level 2 and level 3 nest
Below is a practical, minimal-to-begin-with Fluent Bit pipeline that does what you asked:
HttpContext
( level 2 ) and then into HttpContext.Request
→ Headers
( level 3 )ini######################################## # 1. INPUT – read the file ######################################## [INPUT] Name tail Path /var/log/vendor/api.log # <— your path Tag vendorgw Parser json_root # top-level JSON Refresh_Interval 5 ######################################## # 2. PARSER – decode the line itself ######################################## [PARSER] Name json_root Format json Time_Key time Time_Format %Y-%m-%dT%H:%M:%S.%LZ # 2025-05-19T11:00:05.1972488Z # ❯❯ If your file has one JSON array per line, add: # JSON_Keys_On_Message on ######################################## # 3a. FILTER – lift everything in “HttpContext” ######################################## [FILTER] Name nest Match vendorgw Operation lift Nested_Under HttpContext # ⬆ makes Method, Scheme, … top-level ######################################## # 3b. FILTER – lift Request-level fields ######################################## [FILTER] Name nest Match vendorgw Operation lift Nested_Under Request # now Body, Protocol, Headers, … ######################################## # 3c. FILTER – lift individual HTTP headers ######################################## [FILTER] Name nest Match vendorgw Operation lift Nested_Under Headers # Host, User-Agent, X-Request-ID, … ######################################## # 4. (optional) FILTER – drop the now-empty # HttpContext / Request / Headers shells ######################################## [FILTER] Name modify Match vendorgw Remove_Key HttpContext Remove_Key Request Remove_Key Headers ######################################## # 5. OUTPUT – wherever you need ######################################## [OUTPUT] Name es Match vendorgw Host elasticsearch.example.local Port 9200 Index vendor-logs
Stage | What it does | Your example key path | Resulting key after lift |
---|---|---|---|
Parser | Turns each log line into a record map | HttpContext.Request.Headers.Host | still nested |
nest #1 | lift everything immediately under HttpContext | HttpContext.Method | Method |
nest #2 | lift everything under Request (which is already at top because of step #1) | Request.Headers | Headers |
nest #3 | lift everything under Headers | Headers.User-Agent | User_Agent |
After those three passes, all the interesting bits (path, method, IPs, user-agent, trace ID, etc.) live side-by-side with the top-level fields such as level
, message
, EnvironmentName
, making search, alerting and dashboards painless.
Keep nesting instead of flattening
If your backend understands dots as “real” objects (e.g., OpenSearch with dynamic templates), just skip the last two nest
filters so HttpContext.Request.Headers.*
stays grouped.
Only lift a subset
Add Wildcard ^(Method|Path|IpAddress)$
(regex) to a nest
filter to pull up only those keys.
Log lines wrapped in an array
Some frameworks emit [ {...}, {...} ]
.
Add JSON_Keys_On_Message on
to the parser so Fluent Bit treats the array as one record.
Metrics exporter noise
To drop Prometheus/Blackbox health-checks, insert a grep
filter before the nest
chain:
ini[FILTER] Name grep Match vendorgw Exclude User_Agent ^Blackbox
That’s all you need: one parser + three nest filters. Once you see the structure in your destination, you can iteratively trim or rename fields with a modify
filter, or convert timestamps to nanoseconds, etc.
Happy shipping!