All Products
Search
Document Center

Simple Log Service:Data encoding

Last Updated:Jul 15, 2024

Simple Log Service uses Protocol Buffer (Protobuf) as the standard log format. You can write logs to Simple Log Service in the Protobuf format.

Protobuf is used as a format to interchange structured data. Before you write logs to Simple Log Service by calling the related API operations, you must serialize raw log data to Protobuf data streams. The following example shows sample Protobuf-formatted data:

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; // for time nano part
}

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;
}
Note
  • Keys in Protobuf-formatted data must be unique. Otherwise, an error that indicates undefined behavior may occur.

  • For more information about the Protobuf format, visit GitHub.

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