Documentation ¶
Overview ¶
Package alils implements the SDK(v0.5.0) of Simple Log Service(abbr. SLS).
For more description about SLS, please read this article: http://gitlab.alibaba-inc.com/sls/doc.
Index ¶
- Constants
- Variables
- func NewAliLS() logs.Logger
- type Config
- type InputDetail
- type Log
- func (m *Log) GetContents() []*LogContent
- func (m *Log) GetTime() uint32
- func (m *Log) Marshal() (data []byte, err error)
- func (m *Log) MarshalTo(data []byte) (int, error)
- func (*Log) ProtoMessage()
- func (m *Log) Reset()
- func (m *Log) Size() (n int)
- func (m *Log) String() string
- func (m *Log) Unmarshal(data []byte) error
- type LogConfig
- type LogContent
- func (m *LogContent) GetKey() string
- func (m *LogContent) GetValue() string
- func (m *LogContent) Marshal() (data []byte, err error)
- func (m *LogContent) MarshalTo(data []byte) (int, error)
- func (*LogContent) ProtoMessage()
- func (m *LogContent) Reset()
- func (m *LogContent) Size() (n int)
- func (m *LogContent) String() string
- func (m *LogContent) Unmarshal(data []byte) error
- type LogGroup
- func (m *LogGroup) GetLogs() []*Log
- func (m *LogGroup) GetReserved() string
- func (m *LogGroup) GetSource() string
- func (m *LogGroup) GetTopic() string
- func (m *LogGroup) Marshal() (data []byte, err error)
- func (m *LogGroup) MarshalTo(data []byte) (int, error)
- func (*LogGroup) ProtoMessage()
- func (m *LogGroup) Reset()
- func (m *LogGroup) Size() (n int)
- func (m *LogGroup) String() string
- func (m *LogGroup) Unmarshal(data []byte) error
- type LogGroupList
- func (m *LogGroupList) GetLogGroups() []*LogGroup
- func (m *LogGroupList) Marshal() (data []byte, err error)
- func (m *LogGroupList) MarshalTo(data []byte) (int, error)
- func (*LogGroupList) ProtoMessage()
- func (m *LogGroupList) Reset()
- func (m *LogGroupList) Size() (n int)
- func (m *LogGroupList) String() string
- func (m *LogGroupList) Unmarshal(data []byte) error
- type LogProject
- func (p *LogProject) ApplyConfigToMachineGroup(confName, groupName string) (err error)
- func (p *LogProject) CreateConfig(c *LogConfig) (err error)
- func (p *LogProject) CreateLogStore(name string, ttl, shardCnt int) (err error)
- func (p *LogProject) CreateMachineGroup(m *MachineGroup) (err error)
- func (p *LogProject) DeleteConfig(name string) (err error)
- func (p *LogProject) DeleteLogStore(name string) (err error)
- func (p *LogProject) DeleteMachineGroup(name string) (err error)
- func (p *LogProject) GetAppliedConfigs(groupName string) (confNames []string, err error)
- func (p *LogProject) GetAppliedMachineGroups(confName string) (groupNames []string, err error)
- func (p *LogProject) GetConfig(name string) (c *LogConfig, err error)
- func (p *LogProject) GetLogStore(name string) (s *LogStore, err error)
- func (p *LogProject) GetMachineGroup(name string) (m *MachineGroup, err error)
- func (p *LogProject) ListConfig(offset, size int) (cfgNames []string, total int, err error)
- func (p *LogProject) ListLogStore() (storeNames []string, err error)
- func (p *LogProject) ListMachineGroup(offset, size int) (m []string, total int, err error)
- func (p *LogProject) RemoveConfigFromMachineGroup(confName, groupName string) (err error)
- func (p *LogProject) UpdateConfig(c *LogConfig) (err error)
- func (p *LogProject) UpdateLogStore(name string, ttl, shardCnt int) (err error)
- func (p *LogProject) UpdateMachineGroup(m *MachineGroup) (err error)
- type LogStore
- func (s *LogStore) GetCursor(shardID int, from string) (cursor string, err error)
- func (s *LogStore) GetLogs(shardID int, cursor string, logGroupMaxCount int) (gl *LogGroupList, nextCursor string, err error)
- func (s *LogStore) GetLogsBytes(shardID int, cursor string, logGroupMaxCount int) (out []byte, nextCursor string, err error)
- func (s *LogStore) ListShards() (shardIDs []int, err error)
- func (s *LogStore) PutLogs(lg *LogGroup) (err error)
- type Machine
- type MachineGroup
- type MachineGroupAttribute
- type MachineList
- type OutputDetail
- type Shard
Constants ¶
const ( // CacheSize set the flush size CacheSize int = 64 // Delimiter define the topic delimiter Delimiter string = "##" )
const ( // OffsetNewest stands for the log head offset, i.e. the offset that will be // assigned to the next message that will be produced to the shard. OffsetNewest = "end" // OffsetOldest stands for the oldest offset available on the logstore for a // shard. OffsetOldest = "begin" )
Variables ¶
Functions ¶
Types ¶
type Config ¶ added in v1.8.2
type Config struct { Project string `json:"project"` Endpoint string `json:"endpoint"` KeyID string `json:"key_id"` KeySecret string `json:"key_secret"` LogStore string `json:"log_store"` Topics []string `json:"topics"` Source string `json:"source"` Level int `json:"level"` FlushWhen int `json:"flush_when"` }
Config is the Config for Ali Log
type InputDetail ¶
type InputDetail struct { LogType string `json:"logType"` LogPath string `json:"logPath"` FilePattern string `json:"filePattern"` LocalStorage bool `json:"localStorage"` TimeFormat string `json:"timeFormat"` LogBeginRegex string `json:"logBeginRegex"` Regex string `json:"regex"` Keys []string `json:"key"` FilterKeys []string `json:"filterKey"` FilterRegex []string `json:"filterRegex"` TopicFormat string `json:"topicFormat"` }
InputDetail define log detail
type Log ¶
type Log struct { Time *uint32 `protobuf:"varint,1,req,name=Time" json:"Time,omitempty"` Contents []*LogContent `protobuf:"bytes,2,rep,name=Contents" json:"Contents,omitempty"` XXXUnrecognized []byte `json:"-"` }
Log define the proto Log
func (*Log) GetContents ¶
func (m *Log) GetContents() []*LogContent
GetContents return the Log's Contents
func (*Log) Marshal ¶
Marshal the logs to byte slice
type LogConfig ¶
type LogConfig struct { Name string `json:"configName"` InputType string `json:"inputType"` InputDetail InputDetail `json:"inputDetail"` OutputType string `json:"outputType"` OutputDetail OutputDetail `json:"outputDetail"` CreateTime uint32 LastModifyTime uint32 // contains filtered or unexported fields }
LogConfig define Log Config
type LogContent ¶ added in v1.8.2
type LogContent struct { Key *string `protobuf:"bytes,1,req,name=Key" json:"Key,omitempty"` Value *string `protobuf:"bytes,2,req,name=Value" json:"Value,omitempty"` XXXUnrecognized []byte `json:"-"` }
LogContent define the Log content struct
func (*LogContent) GetKey ¶ added in v1.8.2
func (m *LogContent) GetKey() string
GetKey return the Key
func (*LogContent) GetValue ¶ added in v1.8.2
func (m *LogContent) GetValue() string
GetValue return the Value
func (*LogContent) Marshal ¶ added in v1.8.2
func (m *LogContent) Marshal() (data []byte, err error)
Marshal LogContent
func (*LogContent) MarshalTo ¶ added in v1.8.2
func (m *LogContent) MarshalTo(data []byte) (int, error)
MarshalTo logcontent to data
func (*LogContent) ProtoMessage ¶ added in v1.8.2
func (*LogContent) ProtoMessage()
ProtoMessage not implemented
func (*LogContent) Size ¶ added in v1.8.2
func (m *LogContent) Size() (n int)
Size return LogContent size based on Key and Value
func (*LogContent) String ¶ added in v1.8.2
func (m *LogContent) String() string
String return the compact text
func (*LogContent) Unmarshal ¶ added in v1.8.2
func (m *LogContent) Unmarshal(data []byte) error
Unmarshal data to LogContent
type LogGroup ¶
type LogGroup struct { Logs []*Log `protobuf:"bytes,1,rep,name=Logs" json:"Logs,omitempty"` Reserved *string `protobuf:"bytes,2,opt,name=Reserved" json:"Reserved,omitempty"` Topic *string `protobuf:"bytes,3,opt,name=Topic" json:"Topic,omitempty"` Source *string `protobuf:"bytes,4,opt,name=Source" json:"Source,omitempty"` XXXUnrecognized []byte `json:"-"` }
LogGroup define the logs struct
func (*LogGroup) MarshalTo ¶
MarshalTo LogGroup to data
type LogGroupList ¶
type LogGroupList struct { LogGroups []*LogGroup `protobuf:"bytes,1,rep,name=logGroups" json:"logGroups,omitempty"` XXXUnrecognized []byte `json:"-"` }
LogGroupList define the LogGroups
func LogsBytesDecode ¶
func LogsBytesDecode(data []byte) (gl *LogGroupList, err error)
LogsBytesDecode decodes logs binary data retruned by GetLogsBytes API
func (*LogGroupList) GetLogGroups ¶
func (m *LogGroupList) GetLogGroups() []*LogGroup
GetLogGroups return the LogGroups
func (*LogGroupList) Marshal ¶
func (m *LogGroupList) Marshal() (data []byte, err error)
Marshal LogGroupList
func (*LogGroupList) MarshalTo ¶
func (m *LogGroupList) MarshalTo(data []byte) (int, error)
MarshalTo LogGroupList to data
func (*LogGroupList) ProtoMessage ¶
func (*LogGroupList) ProtoMessage()
ProtoMessage not implemented
func (*LogGroupList) Unmarshal ¶
func (m *LogGroupList) Unmarshal(data []byte) error
Unmarshal data to LogGroupList
type LogProject ¶
type LogProject struct { Name string // Project name Endpoint string // IP or hostname of SLS endpoint AccessKeyID string AccessKeySecret string }
LogProject Define the Ali Project detail
func NewLogProject ¶
func NewLogProject(name, endpoint, AccessKeyID, accessKeySecret string) (p *LogProject, err error)
NewLogProject creates a new SLS project.
func (*LogProject) ApplyConfigToMachineGroup ¶
func (p *LogProject) ApplyConfigToMachineGroup(confName, groupName string) (err error)
ApplyConfigToMachineGroup applies config to machine group.
func (*LogProject) CreateConfig ¶
func (p *LogProject) CreateConfig(c *LogConfig) (err error)
CreateConfig creates a new config in SLS.
func (*LogProject) CreateLogStore ¶
func (p *LogProject) CreateLogStore(name string, ttl, shardCnt int) (err error)
CreateLogStore creates a new logstore in SLS, where name is logstore name, and ttl is time-to-live(in day) of logs, and shardCnt is the number of shards.
func (*LogProject) CreateMachineGroup ¶
func (p *LogProject) CreateMachineGroup(m *MachineGroup) (err error)
CreateMachineGroup creates a new machine group in SLS.
func (*LogProject) DeleteConfig ¶
func (p *LogProject) DeleteConfig(name string) (err error)
DeleteConfig deletes a config according by config name.
func (*LogProject) DeleteLogStore ¶
func (p *LogProject) DeleteLogStore(name string) (err error)
DeleteLogStore deletes a logstore according by logstore name.
func (*LogProject) DeleteMachineGroup ¶
func (p *LogProject) DeleteMachineGroup(name string) (err error)
DeleteMachineGroup deletes machine group according machine group name.
func (*LogProject) GetAppliedConfigs ¶
func (p *LogProject) GetAppliedConfigs(groupName string) (confNames []string, err error)
GetAppliedConfigs returns applied config names list according machine group name groupName.
func (*LogProject) GetAppliedMachineGroups ¶
func (p *LogProject) GetAppliedMachineGroups(confName string) (groupNames []string, err error)
GetAppliedMachineGroups returns applied machine group names list according config name.
func (*LogProject) GetConfig ¶
func (p *LogProject) GetConfig(name string) (c *LogConfig, err error)
GetConfig returns config according by config name.
func (*LogProject) GetLogStore ¶
func (p *LogProject) GetLogStore(name string) (s *LogStore, err error)
GetLogStore returns logstore according by logstore name.
func (*LogProject) GetMachineGroup ¶
func (p *LogProject) GetMachineGroup(name string) (m *MachineGroup, err error)
GetMachineGroup retruns machine group according by machine group name.
func (*LogProject) ListConfig ¶
func (p *LogProject) ListConfig(offset, size int) (cfgNames []string, total int, err error)
ListConfig returns config names list and the total number of configs. The offset starts from 0 and the size is the max number of configs could be returned.
func (*LogProject) ListLogStore ¶
func (p *LogProject) ListLogStore() (storeNames []string, err error)
ListLogStore returns all logstore names of project p.
func (*LogProject) ListMachineGroup ¶
func (p *LogProject) ListMachineGroup(offset, size int) (m []string, total int, err error)
ListMachineGroup returns machine group name list and the total number of machine groups. The offset starts from 0 and the size is the max number of machine groups could be returned.
func (*LogProject) RemoveConfigFromMachineGroup ¶
func (p *LogProject) RemoveConfigFromMachineGroup(confName, groupName string) (err error)
RemoveConfigFromMachineGroup removes config from machine group.
func (*LogProject) UpdateConfig ¶
func (p *LogProject) UpdateConfig(c *LogConfig) (err error)
UpdateConfig updates a config.
func (*LogProject) UpdateLogStore ¶
func (p *LogProject) UpdateLogStore(name string, ttl, shardCnt int) (err error)
UpdateLogStore updates a logstore according by logstore name, obviously we can't modify the logstore name itself.
func (*LogProject) UpdateMachineGroup ¶
func (p *LogProject) UpdateMachineGroup(m *MachineGroup) (err error)
UpdateMachineGroup updates a machine group.
type LogStore ¶
type LogStore struct { Name string `json:"logstoreName"` TTL int ShardCount int CreateTime uint32 LastModifyTime uint32 // contains filtered or unexported fields }
LogStore Store the logs
func (*LogStore) GetCursor ¶
GetCursor gets log cursor of one shard specified by shardID. The from can be in three form: a) unix timestamp in seccond, b) "begin", c) "end". For more detail please read: http://gitlab.alibaba-inc.com/sls/doc/blob/master/api/shard.md#logstore
func (*LogStore) GetLogs ¶
func (s *LogStore) GetLogs(shardID int, cursor string, logGroupMaxCount int) (gl *LogGroupList, nextCursor string, err error)
GetLogs gets logs from shard specified by shardID according cursor. The logGroupMaxCount is the max number of logGroup could be returned. The nextCursor is the next curosr can be used to read logs at next time.
func (*LogStore) GetLogsBytes ¶
func (s *LogStore) GetLogsBytes(shardID int, cursor string, logGroupMaxCount int) (out []byte, nextCursor string, err error)
GetLogsBytes gets logs binary data from shard specified by shardID according cursor. The logGroupMaxCount is the max number of logGroup could be returned. The nextCursor is the next curosr can be used to read logs at next time.
func (*LogStore) ListShards ¶
ListShards returns shard id list of this logstore.
type Machine ¶
type Machine struct { IP string UniqueID string `json:"machine-uniqueid"` UserdefinedID string `json:"userdefined-id"` }
Machine define the Machine
type MachineGroup ¶
type MachineGroup struct { Name string `json:"groupName"` Type string `json:"groupType"` MachineIDType string `json:"machineIdentifyType"` MachineIDList []string `json:"machineList"` Attribute MachineGroupAttribute `json:"groupAttribute"` CreateTime uint32 LastModifyTime uint32 // contains filtered or unexported fields }
MachineGroup define the machine Group
func (*MachineGroup) GetAppliedConfigs ¶
func (m *MachineGroup) GetAppliedConfigs() (confNames []string, err error)
GetAppliedConfigs returns applied configs of this machine group.
func (*MachineGroup) ListMachines ¶
func (m *MachineGroup) ListMachines() (ms []*Machine, total int, err error)
ListMachines returns machine list of this machine group.
type MachineGroupAttribute ¶ added in v1.8.2
type MachineGroupAttribute struct { ExternalName string `json:"externalName"` TopicName string `json:"groupTopic"` }
MachineGroupAttribute define the Attribute
type MachineList ¶
MachineList define the Machine List