Documentation

Index

Constants

const (
	// Value of undefined id
	UNDEFINED_ID = -1

	UNDEFINED_ISP_ID      = int16(UNDEFINED_ID)
	UNDEFINED_PROVINCE_ID = int16(UNDEFINED_ID)
	UNDEFINED_CITY_ID     = int16(UNDEFINED_ID)
	UNDEFINED_NAME_TAG_ID = int16(UNDEFINED_ID)

	// Value of undefined string
	UNDEFINED_STRING = "<UNDEFINED>"
)

const (
	DefaultDirection byte = 0
	// Sorting by ascending
	Ascending byte = 1
	// Sorting by descending
	Descending byte = 2
)

Deprecated: use utils instead


Variables

This section is empty.

Functions

func ExtractPage

func ExtractPage(arrayObject interface{}, paging *Paging) interface{}

Extracts page from array or slice

This function would call Paging.SetTotalCount function on input paging

func GetOrderByAndLimit

func GetOrderByAndLimit(paging *Paging, dialect *OrderByDialect) string

func GetSqlLimit

func GetSqlLimit(paging *Paging) string

Types

type AgentHeartbeatRequest

type AgentHeartbeatRequest struct {
	Hostname string
	Checksum string
}

func (*AgentHeartbeatRequest) String

func (this *AgentHeartbeatRequest) String() string

type AgentPluginsResponse

type AgentPluginsResponse struct {
	Plugins       []string
	Timestamp     int64
	GitRepo       string
	GitUpdate     bool
	GitRepoUpdate bool
}

func (*AgentPluginsResponse) String

func (this *AgentPluginsResponse) String() string

type AgentReportRequest

type AgentReportRequest struct {
	Hostname      string
	IP            string
	AgentVersion  string
	PluginVersion string
	GitRepo       string
}

func (*AgentReportRequest) String

func (this *AgentReportRequest) String() string

type AgentUpdateInfo

type AgentUpdateInfo struct {
	LastUpdate    int64
	ReportRequest *AgentReportRequest
}

type BuiltinMetric

type BuiltinMetric struct {
	Metric string
	Tags   string
}

e.g. net.port.listen or proc.num

func (*BuiltinMetric) String

func (this *BuiltinMetric) String() string

type BuiltinMetricResponse

type BuiltinMetricResponse struct {
	Metrics   []*BuiltinMetric
	Checksum  string
	Timestamp int64
}

func (*BuiltinMetricResponse) String

func (this *BuiltinMetricResponse) String() string

type BuiltinMetricSlice

type BuiltinMetricSlice []*BuiltinMetric

func (BuiltinMetricSlice) Len

func (this BuiltinMetricSlice) Len() int

func (BuiltinMetricSlice) Less

func (this BuiltinMetricSlice) Less(i, j int) bool

func (BuiltinMetricSlice) Swap

func (this BuiltinMetricSlice) Swap(i, j int)

type Config

type Config struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

func (*Config) String

func (this *Config) String() string

type Event

type Event struct {
	Id          string            `json:"id"`
	Strategy    *Strategy         `json:"strategy"`
	Expression  *Expression       `json:"expression"`
	Status      string            `json:"status"` // OK or PROBLEM
	Endpoint    string            `json:"endpoint"`
	LeftValue   float64           `json:"leftValue"`
	CurrentStep int               `json:"currentStep"`
	EventTime   int64             `json:"eventTime"`
	PushedTags  map[string]string `json:"pushedTags"`
}

机器监控和实例监控都会产生Event,共用这么一个struct

func (*Event) ActionId

func (this *Event) ActionId() int

func (*Event) Counter

func (this *Event) Counter() string

func (*Event) ExpressionId

func (this *Event) ExpressionId() int

func (*Event) FormattedTime

func (this *Event) FormattedTime() string

func (*Event) Func

func (this *Event) Func() string

func (*Event) MaxStep

func (this *Event) MaxStep() int

func (*Event) Metric

func (this *Event) Metric() string

func (*Event) Note

func (this *Event) Note() string

func (*Event) Operator

func (this *Event) Operator() string

func (*Event) Priority

func (this *Event) Priority() int

func (*Event) RightValue

func (this *Event) RightValue() float64

func (*Event) StrategyId

func (this *Event) StrategyId() int

func (*Event) String

func (this *Event) String() string

func (*Event) Tpl

func (this *Event) Tpl() *Template

func (*Event) TplId

func (this *Event) TplId() int

type Expression

type Expression struct {
	Id         int               `json:"id"`
	Metric     string            `json:"metric"`
	Tags       map[string]string `json:"tags"`
	Func       string            `json:"func"`       // e.g. max(#3) all(#3)
	Operator   string            `json:"operator"`   // e.g. < !=
	RightValue float64           `json:"rightValue"` // critical value
	MaxStep    int               `json:"maxStep"`
	Priority   int               `json:"priority"`
	Note       string            `json:"note"`
	ActionId   int               `json:"actionId"`
}

func (*Expression) String

func (this *Expression) String() string

type ExpressionResponse

type ExpressionResponse struct {
	Expressions []*Expression `json:"expressions"`
}

type FalconAgentHeartbeat

type FalconAgentHeartbeat struct {
	Hostname      string `json:"hostname" conform:"trim"`
	IP            string `json:"ip" conform:"trim"`
	AgentVersion  string `json:"agent_version" conform:"trim"`
	PluginVersion string `json:"plugin_version" conform:"trim"`
	UpdateTime    int64  `json:"update_time" conform:"trim"`
}

type FalconAgentHeartbeatResult

type FalconAgentHeartbeatResult struct {
	RowsAffected int64 `json:"rows_affected"`
}

type GraphAccurateQueryParam

type GraphAccurateQueryParam struct {
	Checksum  string `json:"checksum"`
	Start     int64  `json:"start"`
	End       int64  `json:"end"`
	ConsolFun string `json:"consolFuc"`
	DsType    string `json:"dsType"`
	Step      int    `json:"step"`
}

页面上已经可以看到DsType和Step了,直接带进查询条件,Graph更易处理

type GraphAccurateQueryResponse

type GraphAccurateQueryResponse struct {
	Values []*RRDData `json:"values"`
}

type GraphDeleteParam

type GraphDeleteParam struct {
	Endpoint string `json:"endpoint"`
	Metric   string `json:"metric"`
	Step     int    `json:"step"`
	DsType   string `json:"dstype"`
	Tags     string `json:"tags"`
}

type GraphDeleteResp

type GraphDeleteResp struct {
}

type GraphFullyInfo

type GraphFullyInfo struct {
	Endpoint  string `json:"endpoint"`
	Counter   string `json:"counter"`
	ConsolFun string `json:"consolFun"`
	Step      int    `json:"step"`
	Filename  string `json:"filename"`
	Addr      string `json:"addr"`
}

type GraphInfoParam

type GraphInfoParam struct {
	Endpoint string `json:"endpoint"`
	Counter  string `json:"counter"`
}

type GraphInfoResp

type GraphInfoResp struct {
	ConsolFun string `json:"consolFun"`
	Step      int    `json:"step"`
	Filename  string `json:"filename"`
}

type GraphItem

type GraphItem struct {
	Endpoint  string            `json:"endpoint"`
	Metric    string            `json:"metric"`
	Tags      map[string]string `json:"tags"`
	Value     float64           `json:"value"`
	Timestamp int64             `json:"timestamp"`
	DsType    string            `json:"dstype"`
	Step      int               `json:"step"`
	Heartbeat int               `json:"heartbeat"`
	Min       string            `json:"min"`
	Max       string            `json:"max"`
}

DsType 即RRD中的Datasource的类型:GAUGE|COUNTER|DERIVE

func (*GraphItem) Checksum

func (t *GraphItem) Checksum() string

func (*GraphItem) PrimaryKey

func (this *GraphItem) PrimaryKey() string

func (*GraphItem) String

func (this *GraphItem) String() string

func (*GraphItem) UUID

func (this *GraphItem) UUID() string

type GraphLastParam

type GraphLastParam struct {
	Endpoint string `json:"endpoint"`
	Counter  string `json:"counter"`
}

type GraphLastResp

type GraphLastResp struct {
	Endpoint string   `json:"endpoint"`
	Counter  string   `json:"counter"`
	Value    *RRDData `json:"value"`
}

type GraphLastRespList

type GraphLastRespList struct {
	List *[]GraphLastResp
}

type GraphQueryParam

type GraphQueryParam struct {
	Start     int64  `json:"start"`
	End       int64  `json:"end"`
	ConsolFun string `json:"consolFuc"`
	Endpoint  string `json:"endpoint"`
	Counter   string `json:"counter"`
	Step      int    `json:"step"`
}

ConsolFun 是RRD中的概念,比如:MIN|MAX|AVERAGE

type GraphQueryResponse

type GraphQueryResponse struct {
	Endpoint string     `json:"endpoint"`
	Counter  string     `json:"counter"`
	DsType   string     `json:"dstype"`
	Step     int        `json:"step"`
	Values   []*RRDData `json:"Values"` //大写为了兼容已经再用这个api的用户
}

type GraphQueryResponseList

type GraphQueryResponseList struct {
	List *[]*GraphQueryResponse
}

type HistoryData

type HistoryData struct {
	Timestamp int64   `json:"timestamp"`
	Value     float64 `json:"value"`
}

type Host

type Host struct {
	Id   int
	Name string
}

func (*Host) String

func (this *Host) String() string

type HostStrategy

type HostStrategy struct {
	Hostname   string     `json:"hostname"`
	Strategies []Strategy `json:"strategies"`
}

func (*HostStrategy) String

func (this *HostStrategy) String() string

type JsonFloat

type JsonFloat float64

func (JsonFloat) MarshalJSON

func (v JsonFloat) MarshalJSON() ([]byte, error)

type JsonMetaData

type JsonMetaData struct {
	Metric      string      `json:"metric"`
	Endpoint    string      `json:"endpoint"`
	Timestamp   int64       `json:"timestamp"`
	Step        int64       `json:"step"`
	Value       interface{} `json:"value"`
	CounterType string      `json:"counterType"`
	Tags        string      `json:"tags"`
}

Same As `MetricValue`

func (*JsonMetaData) String

func (t *JsonMetaData) String() string

type JudgeItem

type JudgeItem struct {
	Endpoint  string            `json:"endpoint"`
	Metric    string            `json:"metric"`
	Value     float64           `json:"value"`
	Timestamp int64             `json:"timestamp"`
	JudgeType string            `json:"judgeType"`
	Tags      map[string]string `json:"tags"`
}

func (*JudgeItem) PrimaryKey

func (this *JudgeItem) PrimaryKey() string

func (*JudgeItem) String

func (this *JudgeItem) String() string

type MeasurementsProperty

type MeasurementsProperty struct {
	Enabled  bool
	Command  []string
	Interval time.Duration
}

type MetaData

type MetaData struct {
	Metric      string            `json:"metric"`
	Endpoint    string            `json:"endpoint"`
	Timestamp   int64             `json:"timestamp"`
	Step        int64             `json:"step"`
	Value       float64           `json:"value"`
	CounterType string            `json:"counterType"`
	Tags        map[string]string `json:"tags"`
}

func (*MetaData) PK

func (t *MetaData) PK() string

func (*MetaData) String

func (t *MetaData) String() string

type MetricValue

type MetricValue struct {
	Endpoint  string      `json:"endpoint"`
	Metric    string      `json:"metric"`
	Value     interface{} `json:"value"`
	Step      int64       `json:"step"`
	Type      string      `json:"counterType"`
	Tags      string      `json:"tags"`
	Timestamp int64       `json:"timestamp"`
}

func (*MetricValue) String

func (this *MetricValue) String() string

type NewAgentPluginsResponse

type NewAgentPluginsResponse struct {
	Plugins   []string `json:"plugins"`
	Timestamp int64    `json:"timestamp"`
	GitRepo   string   `json:"git_repo" conform:"trim"`
}

func (*NewAgentPluginsResponse) String

func (this *NewAgentPluginsResponse) String() string

type NewBuiltinMetric

type NewBuiltinMetric struct {
	Metric string `json:"metric"`
	Tags   string `json:"tags"`
}

e.g. net.port.listen or proc.num

func (*NewBuiltinMetric) String

func (this *NewBuiltinMetric) String() string

type NewBuiltinMetricResponse

type NewBuiltinMetricResponse struct {
	Metrics   []*NewBuiltinMetric `json:"metrics"`
	Checksum  string              `json:"checksum"`
	Timestamp int64               `json:"timestamp"`
}

func (*NewBuiltinMetricResponse) String

func (this *NewBuiltinMetricResponse) String() string

type NewBuiltinMetricSlice

type NewBuiltinMetricSlice []*NewBuiltinMetric

func (NewBuiltinMetricSlice) Len

func (this NewBuiltinMetricSlice) Len() int

func (NewBuiltinMetricSlice) Less

func (this NewBuiltinMetricSlice) Less(i, j int) bool

func (NewBuiltinMetricSlice) Swap

func (this NewBuiltinMetricSlice) Swap(i, j int)

type NewExpression

type NewExpression struct {
	ID         int               `json:"id"`
	Metric     string            `json:"metric"`
	Tags       map[string]string `json:"tags"`
	Func       string            `json:"func"`        // e.g. max(#3) all(#3)
	Operator   string            `json:"operator"`    // e.g. < !=
	RightValue float64           `json:"right_value"` // critical value
	MaxStep    int               `json:"max_step"`
	Priority   int               `json:"priority"`
	Note       string            `json:"note"`
	ActionID   int               `json:"action_id"`
}

func (NewExpression) String

func (this NewExpression) String() string

type NewHostStrategy

type NewHostStrategy struct {
	Hostname   string         `json:"hostname"`
	Strategies []*NewStrategy `json:"strategies"`
}

type NewStrategy

type NewStrategy struct {
	ID         int    `json:"id"`
	Metric     string `json:"metric"`
	Tags       map[string]string
	TagsStr    string       `json:"tags"`
	Func       string       `json:"func"`               // e.g. max(#3) all(#3)
	Operator   string       `json:"operator"`           // e.g. < !=
	RightValue float64      `json:"right_value,string"` // critical value
	MaxStep    int          `json:"max_step"`
	Priority   int          `json:"priority"`
	Note       string       `json:"note"`
	Tpl        *NewTemplate `json:"tpl"`
}

func (*NewStrategy) AfterLoad

func (s *NewStrategy) AfterLoad()

func (*NewStrategy) String

func (this *NewStrategy) String() string

type NewTemplate

type NewTemplate struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	ParentID int    `json:"parent_id"`
	ActionID int    `json:"action_id"`
	Creator  string `json:"creator"`
}

func (*NewTemplate) String

func (this *NewTemplate) String() string

type NodataConfig

type NodataConfig struct {
	Id       int               `json:"id"`
	Name     string            `json:"name"`
	ObjType  string            `json:"objType"`
	Endpoint string            `json:"endpoint"`
	Metric   string            `json:"metric"`
	Tags     map[string]string `json:"tags"`
	Type     string            `json:"type"`
	Step     int64             `json:"step"`
	Mock     float64           `json:"mock"`
}

func NewNodataConfig

func NewNodataConfig(id int, name string, objType string, endpoint string, metric string, tags map[string]string, dstype string, step int64, mock float64) *NodataConfig

func (*NodataConfig) String

func (this *NodataConfig) String() string

type NodataItem

type NodataItem struct {
	Counter string `json:"counter"`
	Ts      int64  `json:"ts"`
	FStatus string `json:"fstatus"`
	FTs     int64  `json:"fts"`
}

func (*NodataItem) String

func (this *NodataItem) String() string

type NqmAgent

type NqmAgent struct {
	// The id of agent
	Id int

	// The name of agent
	Name string

	// The id of ISP, UNDEFINED_ID means there is not such data for this target
	IspId int16
	// The name of ISP
	IspName string

	// The id of province, UNDEFINED_ID means there is not such data for this target
	ProvinceId int16
	// The name of province
	ProvinceName string

	// The id of city, UNDEFINED_ID means there is not such data for this target
	CityId int16
	// The name of city
	CityName string

	NameTagId int16

	// The id of group tags
	GroupTagIds []int32
}

Represents the data of agent

func (*NqmAgent) String

func (agent *NqmAgent) String() string

type NqmTarget

type NqmTarget struct {
	// The id of target
	Id int

	// The IP address or FQDN used by ping command
	Host string

	// The id of ISP, UNDEFINED_ID means there is not such data for this target
	IspId int16
	// The name of ISP
	IspName string

	// The id of province, UNDEFINED_ID means there is not such data for this target
	ProvinceId int16
	// The name of province
	ProvinceName string

	// The id of city, UNDEFINED_ID means there is not such data for this target
	CityId int16
	// The name of city
	CityName string

	// The id of name tag
	NameTagId int16
	// The name tag of the target
	NameTag string

	// The id of group tags
	GroupTagIds []int32
}

Represents the data of target used by NQM agent

func (*NqmTarget) String

func (target *NqmTarget) String() string

type NqmTaskRequest

type NqmTaskRequest struct {
	// The connection id of agent(used to identify task configurations)
	ConnectionId string `valid:"required"`
	// The hostname of agent
	Hostname string `valid:"required"`
	// The IP address of agent
	// Could be IPv4 or IPv6 format
	IpAddress string `valid:"required"`
}

NqmTaskRequest represents the request for ping task by NQM agent

type NqmTaskResponse

type NqmTaskResponse struct {
	// Whether or not the task should be performed
	NeedPing bool

	// The data of agent
	// nil if there is no need for ping
	Agent *NqmAgent

	// The list of target hosts to be probed(ping)
	// nil if there is no need for ping
	Targets []NqmTarget

	// The command/arguments of command to be executed
	// nil if there is no need for ping
	Measurements map[string]MeasurementsProperty
}

NqmTaskResponse represents the response for ping task requested from NQM agent

If NeedPing is false, Targets and Command would be empty array

type NullRpcRequest

type NullRpcRequest struct {
}

type OrderByDialect

type OrderByDialect struct {
	Separator          string
	PropertyMapping    map[string]string
	DirectionMapping   map[byte]string
	FuncEntityToSyntax func(*OrderByEntity) (string, error)
}

Dialect used to mapping property to column. And direction of sorting

func NewSqlOrderByDialect

func NewSqlOrderByDialect(propertyMapping map[string]string) *OrderByDialect

Builds a dialect for default SQL language

DefaultDirection - nothing(by default value of database) Ascending - Omit "ASC" Descending - Omit "DESC"

func (*OrderByDialect) ToQuerySyntax

func (dialect *OrderByDialect) ToQuerySyntax(entities []*OrderByEntity) (string, error)

Converts the entities of order to Query syntax

If some of mapping could be found, the returned error would be non-nil

type OrderByEntity

type OrderByEntity struct {
	// Could name of column, property or any user-defined text
	Expr string
	// See Asc/Desc constant
	Direction byte
}

The order by

func (*OrderByEntity) String

func (entity *OrderByEntity) String() string

type Paging

type Paging struct {
	Size       int32
	Position   int32
	TotalCount int32
	PageMore   bool
	OrderBy    []*OrderByEntity
}

The paging object used to hold information

func NewUndefinedPaging

func NewUndefinedPaging() *Paging

Initialize the paging with default values

Paging.Size: -1
Paging.Position: -1
Paging.TotalCount: -1
Paging.PageMore: false

func (*Paging) GetOffset

func (self *Paging) GetOffset() int32

Gets the offset to be skipped

func (*Paging) SetTotalCount

func (self *Paging) SetTotalCount(totalCount int32)

Sets the total count of data and set-up PageMore flag

func (*Paging) String

func (self *Paging) String() string

Shows the information of paging

type RRDData

type RRDData struct {
	Timestamp int64     `json:"timestamp"`
	Value     JsonFloat `json:"value"`
}

func NewRRDData

func NewRRDData(ts int64, val float64) *RRDData

func (*RRDData) String

func (this *RRDData) String() string

type SimpleRpcResponse

type SimpleRpcResponse struct {
	Code int `json:"code"`
}

code == 0 => success code == 1 => bad request

func (*SimpleRpcResponse) String

func (this *SimpleRpcResponse) String() string

type StrategiesResponse

type StrategiesResponse struct {
	HostStrategies []*HostStrategy `json:"hostStrategies"`
}

type Strategy

type Strategy struct {
	Id         int               `json:"id"`
	Metric     string            `json:"metric"`
	Tags       map[string]string `json:"tags"`
	Func       string            `json:"func"`       // e.g. max(#3) all(#3)
	Operator   string            `json:"operator"`   // e.g. < !=
	RightValue float64           `json:"rightValue"` // critical value
	MaxStep    int               `json:"maxStep"`
	Priority   int               `json:"priority"`
	Note       string            `json:"note"`
	Tpl        *Template         `json:"tpl"`
}

func (*Strategy) String

func (this *Strategy) String() string

type Template

type Template struct {
	Id       int    `json:"id"`
	Name     string `json:"name"`
	ParentId int    `json:"parentId"`
	ActionId int    `json:"actionId"`
	Creator  string `json:"creator"`
}

func (*Template) String

func (this *Template) String() string

type TransferResponse

type TransferResponse struct {
	Message string
	Total   int
	Invalid int
	Latency int64
}

func (*TransferResponse) String

func (this *TransferResponse) String() string

type TsdbItem

type TsdbItem struct {
	Metric    string            `json:"metric"`
	Tags      map[string]string `json:"tags"`
	Value     float64           `json:"value"`
	Timestamp int64             `json:"timestamp"`
}

func (*TsdbItem) String

func (this *TsdbItem) String() string

func (*TsdbItem) TsdbString

func (this *TsdbItem) TsdbString() (s string)

Directories

Path Synopsis
config
mysqlapi
nqm
owl