jsonlogencodingextension

package module
v0.130.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 12 Imported by: 3

README

JSON Log encoding extension

Status
Stability alpha
Distributions []
Issues Open issues Closed issues
Code Owners @VihasMakwana, @atoulme

Configuration

Name Description Default
mode What mode of the JSON encoding extension you want body
array_mode Set whether JSON payloads is extracted from an array(legacy mode). Accepts a boolean. true
Mode
body Mode

The body mode of the JSON encoding extension is used to marshal or unmarshal the JSON log body, ignoring other log fields.

body_with_inline_attributes

The body_with_inline_attributes mode within the JSON encoding extension grabs the resource and attributes and adds them as key value pairs to the JSON body. It iterates through all the logs and creates a JSON array like the following example:

[
  {
    "body": {
      "log": "test"
    },
    "resourceAttributes": {
      "test": "logs-test"
    },
    "logAttributes": {
      "foo": "bar"
    }
  },
  {
    "body": "log testing",
    "resource": {
      "test": "logs-test"
    }
  }
]
array_mode

Configuration accepts a boolean.

  • array_mode: true : This is the default mode to preserve backward compatibility. JSON input is expected as an array

    [{"key": "value"}, {"key": "value"}]

  • array_mode: false : Disable legacy mode and allow to accept a verity of JSON payloads. This includes single document or even a concatenated JSON payload

    Single payload

    {"key": "value"}

    New line delimited JSON payload

    {"key": "value"}
    {"key": "value"}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() extension.Factory

Types

type Config

type Config struct {
	// Export raw log string instead of log wrapper
	Mode      JSONEncodingMode `mapstructure:"mode,omitempty"`
	ArrayMode bool             `mapstructure:"array_mode,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) Validate

func (c *Config) Validate() error

type JSONEncodingMode added in v0.101.0

type JSONEncodingMode string
const (
	JSONEncodingModeBodyWithInlineAttributes JSONEncodingMode = "body_with_inline_attributes"
	JSONEncodingModeBody                     JSONEncodingMode = "body"
)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL