阅读996 返回首页    go 微信


数据编码方式__公共资源说明_API-Reference_日志服务-阿里云

Protocol Buffer是Google开发的用于结构化数据交换格式,被广泛用于Google内部及外部很多服务。目前,SLS服务也使用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;
}

message LogGroup
{
    repeated Log logs= 1;
    optional string reserved =2; // 内部字段,不需要填写
    optional string topic = 3;
    optional string source = 4;
}

message LogGroupList
{
    repeated LogGroup logGroupList = 1;
}

注意:

  1. 由于PB对KeyValue对不要求唯一性,因此需要避免出现该情况,否则行为为未定义。
  2. 关于Protocol Buffer格式的更多信息请参考其Github首页
  3. 关于日志服务写入日志的API详细描述请参考PostLogStoreLogs

最后更新:2016-05-06 10:44:22

  上一篇:go 数据模型__公共资源说明_API-Reference_日志服务-阿里云
  下一篇:go 日志库__公共资源说明_API-Reference_日志服务-阿里云