Building an Integration Trace Log Pipeline with Fluent Bit
An Integration log starts as an application string, but operators need a searchable event document. Fluent Bit builds a lightweight pipeline that reads pod or node log files, extracts Trace fields with a parser, keeps only required events, and sends them to OpenSearch.
This article designs a Tail → Parser → Filter → Output flow for anonymized logs containing GUID, UUID, HOP, and SEQ. The collector does not reprocess business transactions, so delivery guarantees for the log pipeline must be designed separately from business-message guarantees.
The pipeline
Section titled “The pipeline”The Tail input stores file offsets in a position database. To resume from the last position after a pod restart, the position database and filesystem buffering must not exist only in ephemeral memory.
Tail: the file boundary
Section titled “Tail: the file boundary”[INPUT] Name tail Path /var/log/integration/plain/*.log Tag integration.plain.* Parser runtime-line Skip_Long_Lines On Buffer_Chunk_Size 64K Buffer_Max_Size 8M storage.type filesystem storage.pause_on_chunks_overlimit On
[INPUT] Name tail Path /var/log/integration/json/*.log Tag integration.json.* Skip_Long_Lines On Buffer_Chunk_Size 64K Buffer_Max_Size 8M storage.type filesystem storage.pause_on_chunks_overlimit OnWhat Skip_Long_Lines actually decides
Section titled “What Skip_Long_Lines actually decides”The name suggests it only decides whether a long line is dropped, but the blast radius is much wider. When a single line exceeds Buffer_Max_Size, the tail plugin cannot assemble it. With the default Skip_Long_Lines Off, the plugin stops watching that file entirely. One long stack trace therefore costs every subsequent log line written to that file. With On, only the oversized line is skipped and reading continues from the next line.
So this setting is not “do I protect long lines?” but a trade-off between losing one long line and losing an entire file. In an operational pipeline On is almost always correct. If preserving the long line itself matters, do not revert to Off; raise Buffer_Max_Size comfortably above the real maximum line length instead. And expose a skip counter as a Metrics value so skipped lines never disappear silently.
Consider inode and filename during rotation, and add Metadata so identical tags from multiple pods do not collide.
Parser: turning a line into a document
Section titled “Parser: turning a line into a document”Prefer a JSON parser when the application can emit JSON. For legacy plain logs, split the fixed prefix and Trace fields with named captures.
[PARSER] Name runtime-line Format regex Regex ^(?<time>[^ ]+) (?<logLevel>[^ ]+) (?<appName>[^ ]+) (?<eventType>[^ ]+) (?<guid>[^ ]+) (?<uuid>[^ ]+) (?<hop>[0-9]+) (?<seq>[0-9]+) (?<interfaceId>[^ ]+) (?<statusCode>[^ ]+) (?<message>.*)$ Time_Key time Time_Format %Y-%m-%dT%H:%M:%S.%LZ
[PARSER] Name runtime-json Format json Time_Key time Time_Format %Y-%m-%dT%H:%M:%S.%LZRemember exactly which field names runtime-line produces. Because the named capture is (?<message>.*), the body lands in message, not in log. If a later filter names the wrong key, that filter silently does nothing and the record passes through unchanged.
Time_Key time promotes the extracted time field to the record timestamp. That value later determines the OpenSearch output index name and @timestamp.
A regex parser must distinguish normal lines from multiline stack traces. An incorrect multiline rule can join lines from different requests. Prefer one-line JSON exceptions or a clear multiline prefix at the application boundary.
Filter: scope and masking
Section titled “Filter: scope and masking”A parser failure does not have to discard the original. Add parse_error=true and route it to a quarantine index. Send only event types needed by the Trace dashboard to the primary index; route debug events separately.
The first filter below is not layered on top of the regex INPUT. It is a branch that handles only JSON-formatted logs, which is why it matches integration.json.* and why that INPUT declares no parser and forwards the raw line. In that path the default key produced by tail is log, so Key_Name log is correct. If you instead apply this filter to records that already went through the regex parser, Key_Name must be message. Splitting the two paths by tag removes the ambiguity entirely.
[FILTER] Name parser Match integration.json.* Key_Name log Parser runtime-json Reserve_Data True Preserve_Key False
[FILTER] Name grep Match integration.* Regex eventType ^(IFST|IFEN|TXST|TXEN|SEND|RECV|ERR)$Reserve_Data is useful while the original is needed, but it is dangerous if that original contains secrets. Remove headers, tokens, cookies, and personal identifiers at the application boundary, then apply a field allowlist and maximum message length in the collector. If a raw payload is required, keep it in a separately controlled store rather than the search index.
Output and backpressure
Section titled “Output and backpressure”[OUTPUT] Name opensearch Match integration.* Host search.example.invalid Port 443 tls On tls.verify On Logstash_Format On Logstash_Prefix integration-trace Suppress_Type_Name On storage.total_limit_size 1GThe host is a documentation placeholder. Never put real credentials directly in a ConfigMap or settings file; use secret injection and a least-privilege account. Disabling TLS verification can expose both log content and authentication data between the collector and the search cluster.
Which keys govern backpressure under filesystem storage
Section titled “Which keys govern backpressure under filesystem storage”A common mistake is specifying Mem_Buf_Limit together with storage.type filesystem. The two do not operate at the same layer. Mem_Buf_Limit only applies to memory buffering (storage.type memory) and is ignored the moment an input switches to filesystem storage. That is why the INPUT examples above carry no Mem_Buf_Limit. Under filesystem storage, three keys actually govern input backpressure.
storage.max_chunks_up: the ceiling on chunks held in memory at once. Beyond it, remaining chunks live only on disk.storage.pause_on_chunks_overlimit: whenOn, the input is paused at that ceiling, slowing file reads. WhenOff, the input keeps reading and chunks accumulate on disk.storage.total_limit_size: the per-output disk queue ceiling. Once full, the oldest chunks are discarded.
In short, pause_on_chunks_overlimit On means “slow down reading to preserve logs,” while Off plus storage.total_limit_size means “keep reading and drop the oldest.” Neither is an infinite queue, so the policy must be chosen explicitly. Protect business response latency by avoiding a collector configuration that blocks application stdout, and expose drop count, retry count, and chunk usage as Metrics.
OpenSearch mapping and queries
Section titled “OpenSearch mapping and queries”Map guid, interfaceId, eventType, and statusCode as keyword; timestamps as date; and hop and seq as integers. Use text for message only when full-text search is required, and never search inside the message string for a field a dashboard filters on. Pin these rules in an index template rather than in prose.
{ "index_patterns": ["integration-trace-*"], "priority": 100, "template": { "settings": { "number_of_shards": 3, "number_of_replicas": 1, "refresh_interval": "5s" }, "mappings": { "dynamic_templates": [ { "strings_as_keyword": { "match_mapping_type": "string", "mapping": { "type": "keyword", "ignore_above": 256 } } } ], "properties": { "@timestamp": { "type": "date" }, "time": { "type": "date" }, "guid": { "type": "keyword" }, "uuid": { "type": "keyword" }, "interfaceId": { "type": "keyword" }, "eventType": { "type": "keyword" }, "statusCode": { "type": "keyword" }, "appName": { "type": "keyword" }, "logLevel": { "type": "keyword" }, "hop": { "type": "integer" }, "seq": { "type": "integer" }, "message": { "type": "text" } } } }}The dynamic_templates block stops an unexpected string field from expanding into a dual text plus keyword mapping. When the field list is fully fixed, dynamic: strict is the stronger choice.
{ "mappings": { "dynamic": "strict", "properties": { "guid": { "type": "keyword" }, "interfaceId": { "type": "keyword" }, "eventType": { "type": "keyword" }, "statusCode": { "type": "keyword" }, "hop": { "type": "integer" }, "seq": { "type": "integer" }, "message": { "type": "text" } } }}strict rejects the whole document when an unknown field arrives. It reliably prevents mapping explosion, but ingestion stops the moment an application adds a field. Observe rejection counts as Metrics and keep a Schedule that deploys the template before the application change.
Rotate a date-based index behind an alias and apply retention. In OpenSearch, an ISM policy automates rollover and deletion.
{ "policy": { "description": "integration trace rollover and retention", "default_state": "hot", "ism_template": [ { "index_patterns": ["integration-trace-*"], "priority": 100 } ], "states": [ { "name": "hot", "actions": [ { "rollover": { "min_primary_shard_size": "30gb", "min_index_age": "1d" } } ], "transitions": [{ "state_name": "warm", "conditions": { "min_index_age": "7d" } }] }, { "name": "warm", "actions": [ { "read_only": {} }, { "force_merge": { "max_num_segments": 1 } } ], "transitions": [{ "state_name": "delete", "conditions": { "min_index_age": "90d" } }] }, { "name": "delete", "actions": [{ "delete": {} }], "transitions": [] } ] }}Trace detail queries use guid and a time range; dashboards aggregate by interfaceId and time buckets. A stalled rollover or a failed ISM action turns directly into missing query results, so make index count and policy failure state an Alert target. Designing OpenSearch Hot/Cold Storage and Index Lifecycles on Kubernetes continues with the full boundary of Data Streams, Hot/Cold tiers, StatefulSet storage, rollover, and snapshot recovery.
Verification sequence
Section titled “Verification sequence”- Feed a safe fictional line to the parser and verify every extracted field.
- Test a malformed line, a stack trace larger than
Buffer_Max_Size, and JSON containing a newline. In particular, confirm that lines written after the oversized one are still collected from the same file. - Confirm that the Filter keeps normal events and
ERRwhile removing sensitive fields. - Simulate an output outage and verify chunk growth, post-recovery flush, and the configured behaviour when
storage.total_limit_sizeis reached. - Account for duplicate collection and evaluate
uuidor(guid, uuid)as a candidate document ID. At-least-once collection must not assume zero duplicates.
Summary
Section titled “Summary”Tail owns offsets and file collection, Parser extracts the schema, Filter controls scope and redaction, and Output owns delivery, buffering, and TLS. Separating these stages makes log-format changes and search-cluster outages independently operable. Never interpret collection success as business success; observe loss and backpressure in the pipeline itself.