閱讀996 返回首頁    go 阿裏雲 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_日誌服務-阿裏雲