全部产品
Search
文档中心

日志服务:数据编码方式

更新时间:Nov 29, 2023

日志服务使用Protocol Buffer格式作为标准的日志写入格式。

Protocol Buffer格式用于结构化数据交换格式,当用户需要写入日志时,需要把原始日志数据序列化成如下格式的Protocol Buffer数据流,然后才能通过API写入服务端。

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 Reserved = 2; // reserved fields
    optional string Topic = 3;
    optional string Source = 4;
    repeated LogTag LogTags = 6;
}

message LogGroupList
{
    repeated LogGroup logGroupList = 1;
}
说明
  • 在使用Protobuf时要保证Key-Value对的唯一性,否则会出现行为未定义的错误。

  • 关于Protocol Buffer格式的更多信息请参见Github首页

  • 关于日志服务写入日志的API的详细描述,请参见PutLogs