dataobj

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GAUGE    = "GAUGE"
	COUNTER  = "COUNTER"
	SUBTRACT = "SUBTRACT"
	DERIVE   = "DERIVE"
	SPLIT    = "/"
)
View Source
const (
	MachineDep   = 1
	MachineIndep = 2
)
View Source
const (
	COMMON_MODULE = "common"
)
View Source
const GRAPH = 1

Variables

This section is empty.

Functions

func DictedTagstring

func DictedTagstring(s string) map[string]string

func GetCounter

func GetCounter(metric, tag string, tagMap map[string]string) (counter string, err error)

func HasReservedWords

func HasReservedWords(str string) bool

func NidToEndpoint

func NidToEndpoint(nid string) string

func PKWhitEndpointAndTags

func PKWhitEndpointAndTags(endpoint, metric, tags string) string

func PKWithCounter

func PKWithCounter(endpoint, counter string) string

func PKWithTags

func PKWithTags(metric, tags string) string

func SortedTags

func SortedTags(tags map[string]string) string

func SplitTagsString

func SplitTagsString(s string) (tags map[string]string, err error)

Types

type AggrCalc

type AggrCalc struct {
	Id               int64     `xorm:"id pk autoincr" json:"id"`
	Nid              int64     `xorm:"nid" json:"nid"`
	Category         int       `xorm:"category" json:"category"`
	NewMetric        string    `xorm:"new_metric" json:"new_metric"`
	NewStep          int       `xorm:"new_step" json:"new_step"`
	GroupByString    string    `xorm:"groupby" json:"-"`
	RawMetricsString string    `xorm:"raw_metrics" json:"-"`
	GlobalOperator   string    `xorm:"global_operator"json:"global_operator"` //指标聚合方式
	Expression       string    `xorm:"expression" json:"expression"`
	RPN              string    `xorm:"rpn" json:"rpn"`
	Status           int       `xorm:"status" json:"-"`
	Quota            int       `xorm:"quota" json:"quota"`
	Comment          string    `xorm:"comment" json:"comment"`
	Creator          string    `xorm:"creator" json:"creator"`
	Created          time.Time `xorm:"created" json:"created"`
	LastUpdator      string    `xorm:"last_updator" json:"last_updator"`
	LastUpdated      time.Time `xorm:"<-" json:"last_updated"`

	RawMetrics []*RawMetric `xorm:"-" json:"raw_metrics"`
	GroupBy    []string     `xorm:"-" json:"groupby"`
}

type AggrCalcStra

type AggrCalcStra struct {
	SID            int64  `json:"sid"`
	NID            string `json:"nid"`
	ResultStep     int    `json:"step"`
	RawStep        int    `json:"rawStep"`
	GroupKey       string `json:"key"`
	GlobalOperator string `json:"global"`
	InnerOperator  string `json:"inner"`
	VarID          string `json:"varID"`
	VarNum         int    `json:"varNum"`
	RPN            string `json:"RPN"`
	Lateness       int    `json:"lateness"`
}

type AggrList

type AggrList struct {
	Data []*CentralAggrV2Point `json:"data"`
}

type AggrOut

type AggrOut struct {
	Index   string `json:"index"`
	Operate int    `json:"operate"`
	Data    struct {
		Nid       string      `json:"nid"`
		Step      int64       `json:"step"`
		GroupTag  string      `json:"groupTag"`
		Value     interface{} `json:"value"`
		Sid       int64       `json:"sid"`
		Timestamp int64       `json:"timestamp"`
	} `json:"data"`
	Type string `json:"type"`
}

type AggrTagsFilter

type AggrTagsFilter struct {
	TagK string   `json:"tagk"`
	Opt  string   `json:"opt"`
	TagV []string `json:"tagv"`
}

type AssignTask

type AssignTask struct {
	Id     int64
	Clock  int64
	Action string
}

type Auth

type Auth struct {
	Community     Secret `json:"community,omitempty"`
	SecurityLevel string `json:"security_level,omitempty"`
	Username      string `json:"username,omitempty"`
	Password      Secret `json:"password,omitempty"`
	AuthProtocol  string `json:"auth_protocol,omitempty"`
	PrivProtocol  string `json:"priv_protocol,omitempty"`
	PrivPassword  Secret `json:"priv_password,omitempty"`
	ContextName   string `json:"context_name,omitempty"`
}

type BuiltinMetric

type BuiltinMetric struct {
	Metric string
	Tags   string
}

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

func (*BuiltinMetric) String

func (bm *BuiltinMetric) String() string

type BuiltinMetricRequest

type BuiltinMetricRequest struct {
	Ty       int
	IP       string
	Checksum string
}

type BuiltinMetricResponse

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

func (*BuiltinMetricResponse) String

func (br *BuiltinMetricResponse) String() string

type BuiltinMetricSlice

type BuiltinMetricSlice []*BuiltinMetric

func (BuiltinMetricSlice) Len

func (bm BuiltinMetricSlice) Len() int

func (BuiltinMetricSlice) Less

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

func (BuiltinMetricSlice) Swap

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

type CentralAggrV2Point

type CentralAggrV2Point struct {
	Timestamp int64           `json:"t"`
	Value     float64         `json:"v"`
	Strategys []*AggrCalcStra `json:"s"`
	Hash      uint64          `json:"h"`
}

type CludeRecv

type CludeRecv struct {
	Endpoints      []string   `json:"endpoints"`
	Nids           []string   `json:"nids"`
	Metric         string     `json:"metric"`
	Include        []*TagPair `json:"include"`
	Exclude        []*TagPair `json:"exclude"`
	Start          int64      `json:"start" description:"inclusive"`
	End            int64      `json:"end" description:"exclusive"`
	StartInclusive time.Time  `json:"-"`
	EndExclusive   time.Time  `json:"-"`
}

func (*CludeRecv) Validate

func (p *CludeRecv) Validate() (err error)

type EndpointMetricRecv

type EndpointMetricRecv struct {
	Endpoints      []string  `json:"endpoints"`
	Nids           []string  `json:"nids"`
	Metrics        []string  `json:"metrics"`
	Start          int64     `json:"start" description:"inclusive"`
	End            int64     `json:"end" description:"exclusive"`
	StartInclusive time.Time `json:"-"`
	EndExclusive   time.Time `json:"-"`
}

func (*EndpointMetricRecv) Validate

func (p *EndpointMetricRecv) Validate() (err error)

type EndpointsRecv

type EndpointsRecv struct {
	Endpoints      []string  `json:"endpoints"`
	Nids           []string  `json:"nids"`
	Start          int64     `json:"start" description:"inclusive"`
	End            int64     `json:"end" description:"exclusive"`
	StartInclusive time.Time `json:"-"`
	EndExclusive   time.Time `json:"-"`
}

func (*EndpointsRecv) Validate

func (p *EndpointsRecv) Validate() (err error)

type Event

type Event struct {
	ID        string    `json:"-"`
	Sid       int64     `json:"sid"`
	EventType string    `json:"event_type"` // alert/recover
	Hashid    uint64    `json:"hashid"`     // 全局唯一 根据counter计算
	Etime     int64     `json:"etime"`
	Endpoint  string    `json:"endpoint"`
	History   []History `json:"-"`
	Detail    string    `json:"detail"`
	Info      string    `json:"info"`
	Value     string    `json:"value"`
	Partition string    `json:"-"`
	CurNid    string    `json:"cur_nid"`
}

Event 传递到alarm的结构体, 尽可能少的字段, 发出通知需要的信息由alarm自己补全

type File

type File struct {
	Key      interface{}
	Filename string
	Body     []byte
}

type History

type History struct {
	Key         string            `json:"-"`              // 用于计算event的hashid
	Metric      string            `json:"metric"`         // 指标名
	Tags        map[string]string `json:"tags,omitempty"` // endpoint/counter
	Granularity int               `json:"-"`              // alarm补齐数据时需要
	Points      []*HistoryData    `json:"points"`         // 现场值
}

type HistoryData

type HistoryData struct {
	Timestamp int64     `json:"timestamp"`
	Value     JsonFloat `json:"value"`
	Extra     string    `json:"extra"`
}

func RRDData2HistoryData

func RRDData2HistoryData(datas []*RRDData) []*HistoryData

type IPAndSnmp

type IPAndSnmp struct {
	IP          string    `json:"ip"`
	Module      string    `json:"module"`
	Version     string    `json:"version"`
	Auth        string    `json:"auth"`
	Region      string    `json:"region"`
	Step        int       `json:"step"`
	Timeout     int       `json:"timeout"`
	Port        int       `json:"port"`
	Metric      Metric    `json:"metric"`
	LastUpdated time.Time `json:"last_updated"`
}

type IPAndSnmpRpcResp

type IPAndSnmpRpcResp struct {
	Data []*IPAndSnmp
	Msg  string
}

type IfTags

type IfTags struct {
	IfName  string
	IfIndex string
}

type Index

type Index struct {
	Labelname string `yaml:"labelname" json:"labelname"`
	Type      string `yaml:"type" json:"type"`
	FixedSize int    `yaml:"fixed_size" json:"fixed_size,omitempty"`
	Implied   bool   `yaml:"implied" json:"implied,omitempty"`
}

type IndexByFullTagsRecv

type IndexByFullTagsRecv struct {
	Endpoints      []string  `json:"endpoints"`
	Nids           []string  `json:"nids"`
	Metric         string    `json:"metric"`
	Tagkv          []TagPair `json:"tagkv"`
	Start          int64     `json:"start" description:"inclusive"`
	End            int64     `json:"end" description:"exclusive"`
	StartInclusive time.Time `json:"-"`
	EndExclusive   time.Time `json:"-"`
}

func (*IndexByFullTagsRecv) Validate

func (p *IndexByFullTagsRecv) Validate() (err error)

type IndexByFullTagsResp

type IndexByFullTagsResp struct {
	Endpoints []string `json:"endpoints"`
	Nids      []string `json:"nids"`
	Metric    string   `json:"metric"`
	Tags      []string `json:"tags"`
	Step      int      `json:"step"`
	DsType    string   `json:"dstype"`
	Count     int      `json:"count"`
}

type IndexModel

type IndexModel struct {
	Nid       string            `json:"nid"`
	Endpoint  string            `json:"endpoint"`
	Metric    string            `json:"metric"`
	DsType    string            `json:"dsType"`
	Step      int               `json:"step"`
	Tags      map[string]string `json:"tags"`
	Timestamp int64             `json:"ts"`
}

type IndexResp

type IndexResp struct {
	Msg     string
	Total   int
	Invalid int
	Latency int64
}

type IndexTagkvResp

type IndexTagkvResp struct {
	Endpoints []string   `json:"endpoints"`
	Nids      []string   `json:"nids"`
	Metric    string     `json:"metric"`
	Tagkv     []*TagPair `json:"tagkv"`
}

type InfluxdbItem

type InfluxdbItem struct {
	Measurement string                 `json:"metric"`
	Tags        map[string]string      `json:"tags"`
	Fields      map[string]interface{} `json:"fields"`
	Timestamp   int64                  `json:"timestamp"`
}

type JsonFloat

type JsonFloat float64

func (JsonFloat) MarshalJSON

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

type JudgeItem

type JudgeItem struct {
	Nid       string            `json:"nid"`
	Endpoint  string            `json:"endpoint"`
	Metric    string            `json:"metric"`
	Tags      string            `json:"tags"`
	TagsMap   map[string]string `json:"tagsMap"`
	Value     float64           `json:"value"`
	Timestamp int64             `json:"timestamp"`
	DsType    string            `json:"dstype"`
	Step      int               `json:"step"`
	Sid       int64             `json:"sid"`
	Extra     string            `json:"extra"`
}

func (*JudgeItem) MD5

func (j *JudgeItem) MD5() string

func (*JudgeItem) PrimaryKey

func (j *JudgeItem) PrimaryKey() string

type Lookup

type Lookup struct {
	Labels    []string `yaml:"labels" json:"labels"`
	Labelname string   `yaml:"labelname" json:"labelname"`
	Oid       string   `yaml:"oid" json:"oid,omitempty"`
	Type      string   `yaml:"type" json:"type,omitempty"`
}

type Message

type Message struct {
	Tos     []string `json:"tos"`
	Subject string   `json:"subject"`
	Content string   `json:"content"`
}

type Metric

type Metric struct {
	Name           string                     `yaml:"name" json:"name"`
	Oid            string                     `yaml:"oid" json:"oid"`
	Type           string                     `yaml:"type" json:"type"`
	Help           string                     `yaml:"help" json:"help"`
	Indexes        []*Index                   `yaml:"indexes" json:"indexes,omitempty"`
	Lookups        []*Lookup                  `yaml:"lookups" json:"lookups,omitempty"`
	RegexpExtracts map[string][]RegexpExtract `yaml:"regex_extracts" json:"regex_extracts,omitempty"`
	EnumValues     map[int]string             `yaml:"enum_values" json:"enum_values,omitempty"`
}

type MetricResp

type MetricResp struct {
	Metrics []string `json:"metrics"`
}

type MetricValue

type MetricValue struct {
	Nid          string            `json:"nid"`
	Metric       string            `json:"metric"`
	Endpoint     string            `json:"endpoint"`
	Timestamp    int64             `json:"timestamp"`
	Step         int64             `json:"step"`
	ValueUntyped interface{}       `json:"value"`
	Value        float64           `json:"-"`
	CounterType  string            `json:"counterType"` // GAUGE | COUNTER | SUBTRACT | DERIVE
	Tags         string            `json:"tags"`        // a=1,b=2,c=3
	TagsMap      map[string]string `json:"tagsMap"`     // {"a":1, "b"=2, "c="3} 保留2种格式,方便后端组件使用
	Extra        string            `json:"extra"`
}

func (*MetricValue) CheckValidity

func (m *MetricValue) CheckValidity(now int64) (err error)

func (*MetricValue) PK

func (m *MetricValue) PK() string

type Notify

type Notify struct {
	Tos     []string `json:"tos"`
	Subject string   `json:"subject,omitempty"`
	Content string   `json:"content"`
}

type NullRpcRequest

type NullRpcRequest struct {
}

type OpenTsdbItem

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

func (*OpenTsdbItem) OpenTsdbString

func (t *OpenTsdbItem) OpenTsdbString() (s string)

func (*OpenTsdbItem) String

func (t *OpenTsdbItem) String() string

type QueryData

type QueryData struct {
	Start      int64    `json:"start"`
	End        int64    `json:"end"`
	ConsolFunc string   `json:"consolFunc"`
	Endpoints  []string `json:"endpoints"`
	Nids       []string `json:"nids"`
	Counters   []string `json:"counters" description:"metric/tags"`
	Step       int      `json:"step"`
	DsType     string   `json:"dstype"`
}

func (*QueryData) Key

func (req *QueryData) Key() string

judge 数据层 必须

type QueryDataForUI

type QueryDataForUI struct {
	Start       int64    `json:"start"`
	End         int64    `json:"end"`
	Metric      string   `json:"metric"`
	Endpoints   []string `json:"endpoints"`
	Nids        []string `json:"nids"`
	Tags        []string `json:"tags"`
	Step        int      `json:"step"`
	DsType      string   `json:"dstype"`
	GroupKey    []string `json:"groupKey"`                               //聚合维度
	AggrFunc    string   `json:"aggrFunc" description:"sum,avg,max,min"` //聚合计算
	ConsolFunc  string   `json:"consolFunc" description:"AVERAGE,MIN,MAX,LAST"`
	Comparisons []int64  `json:"comparisons"` //环比多少时间
}

type QueryDataForUIResp

type QueryDataForUIResp struct {
	Start      int64      `json:"start"`
	End        int64      `json:"end"`
	Endpoint   string     `json:"endpoint"`
	Nid        string     `json:"nid"`
	Counter    string     `json:"counter"`
	DsType     string     `json:"dstype"`
	Step       int        `json:"step"`
	Values     []*RRDData `json:"values"`
	Comparison int64      `json:"comparison"`
}

type QueryDataResp

type QueryDataResp struct {
	Data []*TsdbQueryResponse
	Msg  string
}

type RRDData

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

func HistoryData2RRDData

func HistoryData2RRDData(datas []*HistoryData) []*RRDData

func NewRRDData

func NewRRDData(ts int64, val float64) *RRDData

func (*RRDData) String

func (rrd *RRDData) String() string

type RRDFile

type RRDFile struct {
	Key      interface{}
	Filename string
}

type RRDFileQuery

type RRDFileQuery struct {
	Files []RRDFile
}

type RRDFileResp

type RRDFileResp struct {
	Files []File
	Msg   string
}

type RRDValues

type RRDValues []*RRDData

func (RRDValues) Len

func (r RRDValues) Len() int

func (RRDValues) Less

func (r RRDValues) Less(i, j int) bool

func (RRDValues) Swap

func (r RRDValues) Swap(i, j int)

type RawMetric

type RawMetric struct {
	Nid       int64             `json:"nid"`
	ExclNid   []int64           `json:"excl_nid"`
	Endpoints []string          `json:"endpoints"`
	Nids      []string          `json:"nids"`
	VarID     string            `json:"var_id"`
	Name      string            `json:"name"`
	Opt       string            `json:"opt"`
	Filters   []*AggrTagsFilter `json:"filters"`
}

type RawMetricAggrCalc

type RawMetricAggrCalc struct {
	Sid            int64             `json:"sid"`
	Nid            int64             `json:"nid"`
	NewMetric      string            `json:"newMetric"`
	NewStep        int               `json:"newStep"`
	GroupBy        []string          `json:"groupBy"`
	GlobalOperator string            `json:"globalOperator"`
	InnerOperator  string            `json:"innerOperator"`
	VarID          string            `json:"varID"`
	VarNum         int               `json:"varNum"`
	SourceNid      int64             `json:"source_nid"`
	SourceMetric   string            `json:"sourceMetric"`
	RPN            string            `json:"RPN"`
	TagFilters     []*AggrTagsFilter `json:"tagFilters"`
	Lateness       int               `json:"lateness"`
}

type Regexp

type Regexp struct {
	*regexp.Regexp
}

Regexp encapsulates a regexp.Regexp and makes it YAML marshalable.

type RegexpExtract

type RegexpExtract struct {
	Value string `yaml:"value" json:"value"`
	Regex Regexp `yaml:"regex" json:"regex"`
}

type ReportRequest

type ReportRequest struct {
	Ident       string
	ReportTasks []ReportTask
}

type ReportResponse

type ReportResponse struct {
	Message     string
	AssignTasks []AssignTask
}

type ReportTask

type ReportTask struct {
	Id     int64
	Clock  int64
	Status string
	Stdout string
	Stderr string
}

type Secret

type Secret string

Secret is a string that must not be revealed on marshaling.

type SimpleRpcResponse

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

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

type TagPair

type TagPair struct {
	Key    string   `json:"tagk"` // json 和变量不一致为了兼容前端
	Values []string `json:"tagv"`
}

type TaskMetaResponse

type TaskMetaResponse struct {
	Message string
	Script  string
	Args    string
	Account string
}

type TransferResp

type TransferResp struct {
	Msg     string
	Total   int
	Invalid int
	Latency int64
}

func (*TransferResp) String

func (t *TransferResp) String() string

type TsdbItem

type TsdbItem struct {
	Nid       string            `json:"nid"`
	Endpoint  string            `json:"endpoint"`
	Metric    string            `json:"metric"`
	Tags      string            `json:"tags"`
	TagsMap   map[string]string `json:"tagsMap"`
	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"`
	From      int               `json:"from"`
}

func (*TsdbItem) MD5

func (t *TsdbItem) MD5() string

func (*TsdbItem) PrimaryKey

func (t *TsdbItem) PrimaryKey() string

func (*TsdbItem) String

func (t *TsdbItem) String() string

func (*TsdbItem) UUID

func (t *TsdbItem) UUID() string

type TsdbQueryParam

type TsdbQueryParam struct {
	Start      int64  `json:"start"`
	End        int64  `json:"end"`
	ConsolFunc string `json:"consolFunc"`
	Nid        string `json:"nid"`
	Endpoint   string `json:"endpoint"`
	Counter    string `json:"counter"`
	Step       int    `json:"step"`
	DsType     string `json:"dsType"`
}

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

func (*TsdbQueryParam) PK

func (g *TsdbQueryParam) PK() string

type TsdbQueryResponse

type TsdbQueryResponse struct {
	Start    int64      `json:"start"`
	End      int64      `json:"end"`
	Endpoint string     `json:"endpoint"`
	Nid      string     `json:"nid"`
	Counter  string     `json:"counter"`
	DsType   string     `json:"dstype"`
	Step     int        `json:"step"`
	Values   []*RRDData `json:"values"`
}

func (*TsdbQueryResponse) Key

func (resp *TsdbQueryResponse) Key() string

type XcludeResp

type XcludeResp struct {
	Endpoint string   `json:"endpoint"`
	Nid      string   `json:"nid"`
	Metric   string   `json:"metric"`
	Tags     []string `json:"tags"`
	Step     int      `json:"step"`
	DsType   string   `json:"dstype"`
}

Jump to

Keyboard shortcuts

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