Conversation
- Remove separate MI analytics log input; read SYNAPSE_ANALYTICS_DATA from carbon log via rewrite_tag + lua parse_mi_analytics instead - Remove general-logs output that double-wrote MI data (Match_regex ^(mi|wso2apim).* also matched rewritten tags mi_app_logs, mi_metrics) - Remove dead parsers: bal_parser, jsonparser, docker (unreferenced) - Remove mi_metrics_json_extract, mi_metrics_parse_json (replaced by lua) - Merge 3 sequential BI lua filters (extract_app_from_path, enrich_bal_logs, construct_bal_app_name) into single process_bal_logs - Add ballerina-metrics-logs-* and mi-metrics-logs-* to index template - Remove unused kubernetes object from index template 312 -> 240 lines fluent-bit.conf 59 -> 28 lines parsers.conf 235 -> 233 lines scripts.lua (net +50 for parse_mi_analytics, -52 for merged/removed) 75 -> 60 lines index-template-request.json
WalkthroughThis change refactors the Fluent Bit logging pipeline architecture. MI analytics processing is restructured to derive from the existing general MI input using rewrite rules rather than a dedicated input. Ballerina log enrichment is simplified by consolidating two processing functions into one. Unused parsers are removed, OpenSearch index templates are updated to accommodate new metrics log patterns, and Kubernetes field mappings are removed from the schema. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
icp_server/resources/observability/opensearch-observability-dashboard/config/fluent-bit/scripts/scripts.lua (1)
132-133: Potential truncation of decimal latency values.The pattern
(%d+)only captures integer portions. If the source JSON ever contains decimal latency values (e.g.,"latency": 123.45), this would capture only123, losing precision.Consider using a pattern that handles optional decimals:
♻️ Suggested pattern for decimal support
- local latency = string.match(json_str, '"latency"%s*:%s*(%d+)') + local latency = string.match(json_str, '"latency"%s*:%s*([%d%.]+)')If the upstream MI analytics data is guaranteed to always emit integer latency values (which the successful testing suggests), this is purely defensive.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@icp_server/resources/observability/opensearch-observability-dashboard/config/fluent-bit/scripts/scripts.lua` around lines 132 - 133, The current string.match call extracts only integer latency because it uses '(%d+)' on json_str; update the pattern used in the string.match(...) expression that assigns local latency so it accepts optional decimal fractions (e.g., allow an optional '.' and digits after the integer), then keep the existing tonumber(latency) and payload["latency"] assignment so decimals are preserved; locate the string.match call that reads into local latency from json_str and modify its pattern accordingly (string.match, local latency, json_str, payload["latency"]).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@icp_server/resources/observability/opensearch-observability-dashboard/config/fluent-bit/scripts/scripts.lua`:
- Around line 132-133: The current string.match call extracts only integer
latency because it uses '(%d+)' on json_str; update the pattern used in the
string.match(...) expression that assigns local latency so it accepts optional
decimal fractions (e.g., allow an optional '.' and digits after the integer),
then keep the existing tonumber(latency) and payload["latency"] assignment so
decimals are preserved; locate the string.match call that reads into local
latency from json_str and modify its pattern accordingly (string.match, local
latency, json_str, payload["latency"]).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8ae2dd94-72c0-407c-9704-c7ea075bcecc
📒 Files selected for processing (4)
icp_server/resources/observability/opensearch-observability-dashboard/config/fluent-bit/fluent-bit.conficp_server/resources/observability/opensearch-observability-dashboard/config/fluent-bit/parsers.conficp_server/resources/observability/opensearch-observability-dashboard/config/fluent-bit/scripts/scripts.luaicp_server/resources/observability/opensearch-observability-dashboard/setup/index-template-request.json
💤 Files with no reviewable changes (1)
- icp_server/resources/observability/opensearch-observability-dashboard/config/fluent-bit/parsers.conf
Summary
Simplify fluent-bit observability pipeline — fix bugs, remove dead code, merge redundant filters.
Changes
Bug fixes
${MI_ANALYTICS_LOG_FILE_NAME}) that reads a file that does not exist.ElasticStatisticsPublisherwrites vialog.info()to the carbon log, not a separate file. Replaced withrewrite_tagon$message ^SYNAPSE_ANALYTICS_DATAfrom the existing carbon log input, parsed via luaparse_mi_analytics.general-logsdouble-write: Removed fallback output withMatch_regex ^(mi|wso2apim).*— this also matched rewritten tagsmi_app_logsandmi_metrics, causing all MI data to be written twice (once to its proper index, once togeneral-logs).ballerina-metrics-logs-*andmi-metrics-logs-*index patterns.Dead code removal
bal_parser,jsonparser,docker(unreferenced). Removedmi_metrics_json_extract,mi_metrics_parse_json(replaced by lua).kubernetesobject mapping.Simplification
extract_app_from_path,enrich_bal_logs,construct_bal_app_name(all matchingballerina.*, running sequentially) into singleprocess_bal_logs.Line count
Testing
Verified in docker-compose dev environment with BI + MI runtimes:
ballerina-application-logs,ballerina-metrics-logs,mi-application-logs,mi-metrics-logsgeneral-logsindex: 0 docs (was 34 duplicates before fix)Id_Key doc_idworking (version conflict on duplicate MI metrics confirms it)Summary by CodeRabbit
Refactor
Chores