dataobj

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: Apache-2.0 Imports: 10 Imported by: 32

Documentation

Index

Constants

View Source
const (
	GAUGE   = "GAUGE"
	COUNTER = "COUNTER"
	DERIVE  = "DERIVE"
	SPLIT   = "/"
)
View Source
const GRAPH = 1

Variables

This section is empty.

Functions

func DictedTagstring

func DictedTagstring(s string) map[string]string

func HasReservedWords

func HasReservedWords(str string) bool

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 AlertUpgrade

type AlertUpgrade struct {
	Users    []int64 `json:"users"`
	Groups   []int64 `json:"groups"`
	Duration int     `json:"duration"`
	Level    int     `json:"level"`
}

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 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:"-"`
}

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

type Exp

type Exp struct {
	Eopt      string  `json:"eopt"`
	Func      string  `json:"func"`
	Metric    string  `json:"metric"`
	Params    []int   `json:"params"`
	Threshold float64 `json:"threshold"`
}

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 added in v1.3.3

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

type IndexModel

type IndexModel struct {
	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 InfluxdbItem added in v1.4.0

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 {
	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 MetricValue

type MetricValue struct {
	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"`
	Tags         string            `json:"tags"`
	TagsMap      map[string]string `json:"tagsMap"` //保留2种格式,方便后端组件使用
	Extra        string            `json:"extra"`
}

func (*MetricValue) CheckValidity

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

func (*MetricValue) PK

func (m *MetricValue) PK() string

func (*MetricValue) String

func (m *MetricValue) String() string

type NullRpcRequest

type NullRpcRequest struct {
}

type OpenTsdbItem added in v1.4.0

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

func (*OpenTsdbItem) OpenTsdbString added in v1.4.0

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

func (*OpenTsdbItem) String added in v1.4.0

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"`
	Counters   []string `json:"counters"`
	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"`
	Tags        []string `json:"tags"`
	Step        int      `json:"step"`
	DsType      string   `json:"dstype"`
	GroupKey    []string `json:"groupKey"` //聚合维度
	AggrFunc    string   `json:"aggrFunc"` //聚合计算
	ConsolFunc  string   `json:"consolFunc"`
	Comparisons []int64  `json:"comparisons"` //环比多少时间
}

type QueryDataForUIResp added in v1.0.2

type QueryDataForUIResp struct {
	Start      int64      `json:"start"`
	End        int64      `json:"end"`
	Endpoint   string     `json:"endpoint"`
	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 added in v1.4.0

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 SimpleRpcResponse

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

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

type Stra

type Stra struct {
	ID               int64        `json:"id"`
	Name             string       `json:"name"`
	Category         int          `json:"category"`
	Nid              int64        `json:"nid"`
	AlertDur         int          `json:"alert_dur"`
	RecoveryDur      int          `json:"recovery_dur"`
	EnableStime      string       `json:"enable_stime"`
	EnableEtime      string       `json:"enable_etime"`
	Priority         int          `json:"priority"`
	Callback         string       `json:"callback"`
	Creator          string       `json:"creator"`
	Created          string       `json:"created"`
	LastUpdator      string       `json:"last_updator"`
	LastUpdated      string       `json:"last_updated"`
	ExclNid          []int64      `json:"excl_nid"`
	Exprs            []Exp        `json:"exprs"`
	Tags             []Tag        `json:"tags"`
	EnableDaysOfWeek []int        `json:"enable_days_of_week"`
	Converge         []int        `json:"converge"`
	RecoveryNotify   int          `json:"recovery_notify"`
	NotifyGroup      []int64      `json:"notify_group"`
	NotifyUser       []int64      `json:"notify_user"`
	LeafNids         interface{}  `json:"leaf_nids"`
	NeedUpgrade      int          `json:"need_upgrade"`
	AlertUpgrade     AlertUpgrade `json:"alert_upgrade"`
}

type StraData

type StraData struct {
	Dat []Stra `json:"dat"`
	Err string `json:"err"`
}

type Tag

type Tag struct {
	Tkey string   `json:"tkey"`
	Topt string   `json:"topt"`
	Tval []string `json:"tval"` //修改为数组
}

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 {
	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"`
	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"`
	Counter  string     `json:"counter"`
	DsType   string     `json:"dstype"`
	Step     int        `json:"step"`
	Values   []*RRDData `json:"values"`
}

func (*TsdbQueryResponse) Key

func (resp *TsdbQueryResponse) Key() string

Jump to

Keyboard shortcuts

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