全部产品
Search
文档中心

Simple Log Service:Pengkodean data

更新时间:Jul 06, 2025

Simple Log Service menggunakan Protocol Buffer (Protobuf) sebagai format log standar. Anda dapat menulis log ke Simple Log Service dalam format Protobuf.

Protobuf digunakan sebagai format untuk pertukaran data terstruktur. Sebelum menulis log ke Simple Log Service dengan memanggil operasi API terkait, Anda harus mengubah log mentah menjadi aliran data Protobuf. Contoh berikut menunjukkan data berformat Protobuf:

message Log
{
    required uint32 Time = 1;// Format Waktu UNIX
    message Content
    {
        required string Key = 1;
        required string Value = 2;
    }  
    repeated Content Contents = 2;
    optional fixed32 Time_ns = 4; // untuk bagian nano waktu
}

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;
}
Catatan
  • Kunci dalam data berformat Protobuf harus unik. Jika tidak, kesalahan yang menunjukkan perilaku tidak terdefinisi mungkin terjadi.

  • Untuk informasi lebih lanjut tentang format Protobuf, kunjungi GitHub.

  • Untuk informasi lebih lanjut tentang operasi API untuk menulis log ke Simple Log Service, lihat PutLogs.