数据编码方式

更新时间:2024-07-15 08:14:59

日志服务使用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 Topic = 3;
    optional string Source = 4;
    repeated LogTag LogTags = 6;
}

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

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

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

    AI助理

    点击开启售前

    在线咨询服务

    你好,我是AI助理

    可以解答问题、推荐解决方案等