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 |
|
|
|
|
Yes |
Log timestamp in UNIX time format |
|
|
|
|
Yes |
One or more key-value pairs that make up the log content |
|
|
|
|
Yes |
The log field name |
|
|
|
|
Yes |
The log field value |
|
|
|
|
No |
Nanosecond precision extension for the timestamp |
|
|
|
|
Yes |
Tag name attached to the log group |
|
|
|
|
Yes |
Tag value attached to the log group |
|
|
|
|
Yes |
The collection of logs in the group |
|
|
|
|
No |
The topic used to classify logs within a logstore |
|
|
|
|
No |
The machine or IP address that generated the logs |
|
|
|
|
No |
Metadata tags for the log group |
|
|
|
|
Yes |
A list of log groups submitted in a single API call |
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.