Documentation ¶
Overview ¶
Package sls 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 AliLSConfig
- type InputDetail
- type Log
- func (m *Log) GetContents() []*Log_Content
- 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 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 Log_Content
- func (m *Log_Content) GetKey() string
- func (m *Log_Content) GetValue() string
- func (m *Log_Content) Marshal() (data []byte, err error)
- func (m *Log_Content) MarshalTo(data []byte) (int, error)
- func (*Log_Content) ProtoMessage()
- func (m *Log_Content) Reset()
- func (m *Log_Content) Size() (n int)
- func (m *Log_Content) String() string
- func (m *Log_Content) Unmarshal(data []byte) error
- type MachinGroupAttribute
- type Machine
- type MachineGroup
- type MachineList
- type OutputDetail
- type Shard
Constants ¶
const ( CacheSize int = 64 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 ¶
var ( ErrInvalidLengthLog = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowLog = fmt.Errorf("proto: integer overflow") )
Functions ¶
Types ¶
type AliLSConfig ¶
type AliLSConfig 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"` }
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"` }
type Log ¶
type Log struct { Time *uint32 `protobuf:"varint,1,req,name=Time" json:"Time,omitempty"` Contents []*Log_Content `protobuf:"bytes,2,rep,name=Contents" json:"Contents,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*Log) GetContents ¶
func (m *Log) GetContents() []*Log_Content
func (*Log) ProtoMessage ¶
func (*Log) ProtoMessage()
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 }
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"` XXX_unrecognized []byte `json:"-"` }
func (*LogGroup) GetReserved ¶
func (*LogGroup) ProtoMessage ¶
func (*LogGroup) ProtoMessage()
type LogGroupList ¶
type LogGroupList struct { LogGroups []*LogGroup `protobuf:"bytes,1,rep,name=logGroups" json:"logGroups,omitempty"` XXX_unrecognized []byte `json:"-"` }
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
func (*LogGroupList) Marshal ¶
func (m *LogGroupList) Marshal() (data []byte, err error)
func (*LogGroupList) ProtoMessage ¶
func (*LogGroupList) ProtoMessage()
func (*LogGroupList) Reset ¶
func (m *LogGroupList) Reset()
func (*LogGroupList) Size ¶
func (m *LogGroupList) Size() (n int)
func (*LogGroupList) String ¶
func (m *LogGroupList) String() string
func (*LogGroupList) Unmarshal ¶
func (m *LogGroupList) Unmarshal(data []byte) error
type LogProject ¶
type LogProject struct { Name string // Project name Endpoint string // IP or hostname of SLS endpoint AccessKeyId string AccessKeySecret string }
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 }
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 Log_Content ¶
type Log_Content struct { Key *string `protobuf:"bytes,1,req,name=Key" json:"Key,omitempty"` Value *string `protobuf:"bytes,2,req,name=Value" json:"Value,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*Log_Content) GetKey ¶
func (m *Log_Content) GetKey() string
func (*Log_Content) GetValue ¶
func (m *Log_Content) GetValue() string
func (*Log_Content) Marshal ¶
func (m *Log_Content) Marshal() (data []byte, err error)
func (*Log_Content) ProtoMessage ¶
func (*Log_Content) ProtoMessage()
func (*Log_Content) Reset ¶
func (m *Log_Content) Reset()
func (*Log_Content) Size ¶
func (m *Log_Content) Size() (n int)
func (*Log_Content) String ¶
func (m *Log_Content) String() string
func (*Log_Content) Unmarshal ¶
func (m *Log_Content) Unmarshal(data []byte) error
type MachinGroupAttribute ¶
type MachineGroup ¶
type MachineGroup struct { Name string `json:"groupName"` Type string `json:"groupType"` MachineIdType string `json:"machineIdentifyType"` MachineIdList []string `json:"machineList"` Attribute MachinGroupAttribute `json:"groupAttribute"` CreateTime uint32 LastModifyTime uint32 // contains filtered or unexported fields }
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.