Categorygithub.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/googlecloudlogentryencodingextension

# README

Google Cloud LogEntry encoding extension

Status
Stabilitydevelopment
Distributions[]
IssuesOpen issues Closed issues
Code Owners@alexvanboxel

This extension can be used fo unmarshaling a Cloud Logging LogEntry message type.

The following configuration options are supported:

  • handle_json_payload_as (Optional): This controls how the json payload of the LogEntry is parsed into the body. The default json parses it as standard JSON, while text will the put the payload as a single string.
  • handle_proto_payload_as (Optional): This controls how the json payload of the LogEntry is parsed into the body. The default json parses it as standard JSON, while proto will use the well known protobuf types used in a LogEntry providing a better type handling, but sacrificing stability. Using text will the put the payload as a single string.

The encoding is mainly used in conjunction with the googlecloudpubsubreceiver. The receiver can be used to bring Cloud Logging messages into an OpenTelemetry pipeline. You'll first need to set up a logging sink with a Pub/Sub topic as its destination. This encoder can be configure to parse the LogEntry. An example config could look like this:

extensions:
  googlecloudlogentry_encoding:
    handle_json_payload_as: "json"
    handle_proto_payload_as: "json"

receivers:
  googlecloudpubsub:
    project: otel-project
    subscription: projects/otel-project/subscriptions/otlp-logs
    encoding: googlecloudlogentry_encoding

Google Cloud logging uses the LogEntry to carry log information. In this section, the mapping of the fields to OpenTelemetry fields and attributes are documented.

Semantic Mapping

Some of the attributes can be moved to OpenTelemetry Semantic Conventions. Note, however, that all the attributes are considered experimental and are subject to change.

FieldTypeDescriptionMaps to Unified Model Field
insert_idbooleanA unique identifier for the log entry.Attributes["log.record.uid"]

Attribute and Field mapping

The rest of the JSON body is either mapped to attributes with a gcp prefix or directly mapped to the LogRecord.

FieldTypeDescriptionMaps to Unified Model Field
timestampstringThe time the event described by the log entry occurred.Timestamp
receiveTimestampstringThe time the log entry was received.ObservedTimestamp
logNamestringThe URL-encoded log ID suffix of the log_name field identifies which log stream this entry belongs to.Attributes["gcp.log_name"] (string)
jsonPayloadgoogle.protobuf.StructThe log entry payload, represented as a structure that is expressed as a JSON object.Body (KVList)
protoPayloadgoogle.protobuf.AnyThe log entry payload, represented as a protocol buffer.Body (KVList, key from JSON representation)
textPayloadstringThe log entry payload, represented as a Unicode string (UTF-8).Body (string)
tracestringThe trace associated with the log entry, if any.TraceId
spanIdstringThe span ID within the trace associated with the log entry.SpanId
traceSampledbooleanThe sampling decision of the trace associated with the log entry.TraceFlags.SAMPLED
labelsmap<string,string>A set of user-defined (key, value) data that provides additional information about the log entry.Attributes["gcp.*"]
resourceMonitoredResourceThe monitored resource that produced this log entry.Resource["gcp.*"]
httpRequestHttpRequestThe HTTP request associated with the log entry, if any.Attributes["gcp.http_request"] (KVList)
operationLogEntryOperationInformation about a operation associated with the log entry.Attributes["gcp.operation"] (KVList)
sourceLocationLogEntrySourceLocationSource code location information associated with the log entry.Attributes["gcp.source_location"] (KVList)
splitLogSplitInformation indicating this LogEntry is part of a sequence of multiple log entries split from a single LogEntry.Attributes["gcp.log_split"] (KVList)

Severity Mapping

The severity is mapping from Google Cloud Log Severity to the OpenTelemetry Severity Number.

CloudLogSeverity NumberCloudLog Description
DEFAULT(0)UNSPECIFIED(0)The log entry has no assigned severity level.
DEBUG(100)DEBUG(5)Debug or trace information.
INFO(200)INFO(9)Routine information, such as ongoing status or performance.
NOTICE(300)INFO2(10)Normal but significant events, such as start up, shut down, or a configuration change.
WARNING(400)WARN(13)Warning events might cause problems.
ERROR(500)ERROR(17)Error events are likely to cause problems.
CRITICAL(600)FATAL(21)Critical events cause more severe problems or outages.
ALERT(700)FATAL2(22)A person must take an action immediately.
EMERGENCY(800)FATAL4(24)One or more systems are unusable.

# Functions

No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author

# Type aliases

No description provided by the author