Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/grafana-cloud/observe-and-act/send-data/alloy/reference/components/otelcol/otelcol.encoding.jsonlog.md, or by sending Accept: text/markdown to https://grafana.com/docs/grafana-cloud/observe-and-act/send-data/alloy/reference/components/otelcol/otelcol.encoding.jsonlog/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
otelcol.encoding.jsonlog
EXPERIMENTAL: This is an experimental component. Experimental components are subject to frequent breaking changes, and may be removed with no equivalent replacement. To enable and use an experimental component, you must set the
stability.levelflag toexperimental.
otelcol.encoding.jsonlog encodes and decodes OpenTelemetry log records as JSON.
It exposes a handler that compatible otelcol components can use to marshal and unmarshal logs.
Note
otelcol.encoding.jsonlogis a wrapper over the upstream OpenTelemetry Collectorjsonlogencodingextensionextension. Grafana Labs redirects bug reports or feature requests to the upstream repository when necessary.
You can specify multiple otelcol.encoding.jsonlog components by giving them different labels.
Usage
otelcol.encoding.jsonlog "<LABEL>" {
}Arguments
You can use the following arguments with otelcol.encoding.jsonlog:
| Name | Type | Description | Default | Required |
|---|---|---|---|---|
array_mode | bool | Whether to encode and decode JSON arrays. | true | no |
mode | string | How to marshal fields from each log record. | "body" | no |
The array_mode argument controls the JSON document shape.
When array_mode is true, unmarshaled input must be a JSON array of objects, and marshaled output is a JSON array.
When array_mode is false, unmarshaled input can be a single JSON object or a stream of concatenated JSON objects, including newline-delimited JSON.
Marshaled output contains one JSON object per line when array_mode is false and there are multiple log records.
The mode argument supports the following values:
bodymarshals each log record’s body and requires the body to be a map.body_with_inline_attributesmarshals each log record as an object containing itsbody,resourceAttributes, andlogAttributesfields when those fields aren’t empty.
The mode argument affects marshaling only.
During unmarshaling, the component stores each JSON object as a log record body.
Blocks
The otelcol.encoding.jsonlog component doesn’t support any blocks.
You can configure this component with arguments.
Exported fields
The following fields are exported and can be referenced by other components:
| Name | Type | Description |
|---|---|---|
handler | capsule(otelcol.Handler) | A handler that compatible otelcol components can use to encode and decode logs. |
Component health
otelcol.encoding.jsonlog is only reported as unhealthy if given an invalid configuration.
Debug information
otelcol.encoding.jsonlog doesn’t expose any component-specific debug information.
Debug metrics
otelcol.encoding.jsonlog doesn’t expose any component-specific debug metrics.
Examples
otelcol.receiver.awss3
This example uses otelcol.encoding.jsonlog to decode newline-delimited JSON log records from S3 objects with keys that end in .jsonl.
The receiver forwards the decoded logs to otelcol.exporter.debug:
otelcol.encoding.jsonlog "default" {
array_mode = false
}
otelcol.receiver.awss3 "default" {
start_time = "2024-01-01 01:00"
end_time = "2024-01-02"
s3downloader {
region = "us-west-1"
s3_bucket = "mybucket"
s3_prefix = "logs"
}
encoding {
extension = otelcol.encoding.jsonlog.default.handler
suffix = ".jsonl"
}
output {
logs = [otelcol.exporter.debug.default.input]
}
}
otelcol.exporter.debug "default" {}Was this page helpful?
Related resources from Grafana Labs


