Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • lava lava
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 65
    • Merge requests 65
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • lava
  • lavalava
  • Issues
  • #545

Closed
Open
Created May 17, 2022 by Igor Ponomarev@igo95862Contributor

RFC: Optional JSON structured logging with `structlog`

Structured logging allows the logs to be machine read and analysed.

There is a python package called structlog that can be used to implement it. It is available in Debian repositories.

It can be inserted as a formatter for pythons logging standard library which makes it easy to integrate with lava.

Example:

"json_formatter": {
                "()": structlog.stdlib.ProcessorFormatter,
                "processor": structlog.processors.JSONRenderer(),
                "foreign_pre_chain": [
                    structlog.processors.TimeStamper(fmt="iso"),
                    structlog.stdlib.add_logger_name,
                    structlog.stdlib.add_log_level,
                    structlog.stdlib.PositionalArgumentsFormatter()
                ],
            },

I was thinking about making it configurable with /etc/lava-server/settings.d/*.yaml files.

However, first this fix should be merged: !1756 (merged)

Second, YAML can't load actual python objects and logging dict only has one level of special key (). I think adding a helper function under absolute python path lava-server.structlog.JsonFormatter which will initialise the struct log objects. It will also only make imports inside the function which makes entire structlog optional to be installed.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking