Skip to content

Custom formatter for SemanticLogger elasticsearch appender #1770

@dmitry-sinina

Description

@dmitry-sinina

Idea is to use custom formatter to extract tags from named_tags hash to top level json attibutes.

current format:

    "_time": "2025-06-26T11:53:24.207443435Z",
    "_stream_id": "0000000000000000abaa950ac3f8300ff10e29a3b27a0c74",
....
    "name": "ActiveAdmin::Devise::SessionsController",
    "named_tags.env": "staging",
    "named_tags.system": "yeti",
    "named_tags.request_id": "a744b32f-4428-41bc-bc07-660b2c4910c1",
    "payload.action": "new",
...
  }

new format:

    "_time": "2025-06-26T11:53:24.207443435Z",
    "_stream_id": "0000000000000000abaa950ac3f8300ff10e29a3b27a0c74",
....
    "name": "ActiveAdmin::Devise::SessionsController",
    "env": "staging",
    "system": "yeti",
    "request_id": "a744b32f-4428-41bc-bc07-660b2c4910c1",
    "payload.action": "new",
...
  }

Currently elasticsearch appender using default formatter - raw_json

  • Create custom formatter https://logger.rocketjob.io/customize.html New formatter should work in same was as raw_json but extract keys from named_tags to object top level
  • Use new formatter in config/initializers/semantic_logger.rb SemanticLogger.add_appender

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions