All Products
Search
Document Center

Simple Log Service:Data encoding

Last Updated:Jun 02, 2026

Simple Log Service (SLS) uses Protocol Buffers (protobuf) as the standard format for writing logs.

Protobuf is a language-neutral, platform-independent format for exchanging structured data. Before writing logs to the server through an API, serialize the raw log data into a protobuf data stream. The following schema defines the required format:

message Log
{
    required uint32 Time = 1; // UNIX time format
    message Content
    {
        required string Key = 1;
        required string Value = 2;
    }  
    repeated Content Contents = 2;
    optional fixed32 Time_ns = 4; // The nanosecond part of the time
}

message LogTag
{
    required string Key = 1;
    required string Value = 2;
}

message LogGroup
{
    repeated Log Logs= 1;
    optional string Topic = 3;
    optional string Source = 4;
    repeated LogTag LogTags = 6;
}

message LogGroupList
{
    repeated LogGroup logGroupList = 1;
}

The schema defines four message types. The following table describes each field:

Message

Field

Type

Required

Description

Log

Time

uint32

Yes

Log timestamp in UNIX time format

Log

Contents

Content (repeated)

Yes

One or more key-value pairs that make up the log content

Log > Content

Key

string

Yes

The log field name

Log > Content

Value

string

Yes

The log field value

Log

Time_ns

fixed32

No

Nanosecond precision extension for the timestamp

LogTag

Key

string

Yes

Tag name attached to the log group

LogTag

Value

string

Yes

Tag value attached to the log group

LogGroup

Logs

Log (repeated)

Yes

The collection of logs in the group

LogGroup

Topic

string

No

The topic used to classify logs within a logstore

LogGroup

Source

string

No

The machine or IP address that generated the logs

LogGroup

LogTags

LogTag (repeated)

No

Metadata tags for the log group

LogGroupList

logGroupList

LogGroup (repeated)

Yes

A list of log groups submitted in a single API call

Note
  • Keys in protobuf data must be unique. Duplicate keys cause undefined behavior or faults.

  • For more information about the protobuf format, see protobuf on GitHub.

  • For more information about the API operation for writing logs to Simple Log Service, see PutLogs.