alils

package
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2017 License: Apache-2.0 Imports: 21 Imported by: 0

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

View Source
const (
	CacheSize int    = 64
	Delimiter string = "##"
)
View Source
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

View Source
var (
	ErrInvalidLengthLog = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowLog   = fmt.Errorf("proto: integer overflow")
)

Functions

func NewAliLS

func NewAliLS() logs.Logger

创建提供Logger接口的日志服务

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) GetTime

func (m *Log) GetTime() uint32

func (*Log) Marshal

func (m *Log) Marshal() (data []byte, err error)

func (*Log) MarshalTo

func (m *Log) MarshalTo(data []byte) (int, error)

func (*Log) ProtoMessage

func (*Log) ProtoMessage()

func (*Log) Reset

func (m *Log) Reset()

func (*Log) Size

func (m *Log) Size() (n int)

func (*Log) String

func (m *Log) String() string

func (*Log) Unmarshal

func (m *Log) Unmarshal(data []byte) error

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
}

func (*LogConfig) GetAppliedMachineGroup

func (c *LogConfig) GetAppliedMachineGroup(confName string) (groupNames []string, err error)

GetAppliedMachineGroup returns applied machine group of this config.

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) GetLogs

func (m *LogGroup) GetLogs() []*Log

func (*LogGroup) GetReserved

func (m *LogGroup) GetReserved() string

func (*LogGroup) GetSource

func (m *LogGroup) GetSource() string

func (*LogGroup) GetTopic

func (m *LogGroup) GetTopic() string

func (*LogGroup) Marshal

func (m *LogGroup) Marshal() (data []byte, err error)

func (*LogGroup) MarshalTo

func (m *LogGroup) MarshalTo(data []byte) (int, error)

func (*LogGroup) ProtoMessage

func (*LogGroup) ProtoMessage()

func (*LogGroup) Reset

func (m *LogGroup) Reset()

func (*LogGroup) Size

func (m *LogGroup) Size() (n int)

func (*LogGroup) String

func (m *LogGroup) String() string

func (*LogGroup) Unmarshal

func (m *LogGroup) Unmarshal(data []byte) error

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) MarshalTo

func (m *LogGroupList) MarshalTo(data []byte) (int, 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

func (s *LogStore) GetCursor(shardId int, from string) (cursor string, err error)

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

func (s *LogStore) ListShards() (shardIDs []int, err error)

ListShards returns shard id list of this logstore.

func (*LogStore) PutLogs

func (s *LogStore) PutLogs(lg *LogGroup) (err error)

PutLogs put logs into logstore. The callers should transform user logs into LogGroup.

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) MarshalTo

func (m *Log_Content) MarshalTo(data []byte) (int, 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 MachinGroupAttribute struct {
	ExternalName string `json:"externalName"`
	TopicName    string `json:"groupTopic"`
}

type Machine

type Machine struct {
	IP            string
	UniqueId      string `json:"machine-uniqueid"`
	UserdefinedId string `json:"userdefined-id"`
}

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.

type MachineList

type MachineList struct {
	Total    int
	Machines []*Machine
}

type OutputDetail

type OutputDetail struct {
	Endpoint     string `json:"endpoint"`
	LogStoreName string `json:"logstoreName"`
}

type Shard

type Shard struct {
	ShardID int `json:"shardID"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL