Documentation ¶
Index ¶
- func CheckInfluxDBQuery(s string) (map[string]interface{}, error)
- func HasTimeCondition(statement *influxql.SelectStatement) bool
- func MetricString(data map[string]string) string
- func Register(name string, creator EngineCreator)
- func ReleasePoints(points ...Point)
- type Datasource
- type Engine
- type EngineCreator
- type Point
- type Prometheus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckInfluxDBQuery ¶
CheckInfluxDBQuery check if the query statement is valid
func HasTimeCondition ¶
func HasTimeCondition(statement *influxql.SelectStatement) bool
HasTimeCondition check if the select statement has time condition
func Register ¶
func Register(name string, creator EngineCreator)
Register add a new engine which will be used to init datasource
Types ¶
type Datasource ¶
type Datasource struct { ID int64 `json:"id" db:"id"` Name string `json:"name" db:"name"` Type string `json:"type" db:"type"` Settings string `json:"settings" db:"settings"` IsPublic bool `json:"is_public" db:"is_public"` Owners types.StringList `json:"owners" db:"owners"` Description string `json:"description" db:"description"` CreatedTime time.Time `json:"created_time" db:"created_time"` UpdatedTime time.Time `json:"updated_time" db:"updated_time"` Engine `json:"-"` }
Datasource 代表一个数据源, 数据源是用来获取告警指标的
func InitDatasource ¶
func InitDatasource(src Datasource) (Datasource, error)
InitDatasource set the Engine value
type Engine ¶
type Engine interface { Query(time.Time, string) ([]Point, error) CheckQuery(time.Time, string) error Close() error }
Engine represent a data source store meta data
func NewInfluxdbDataSource ¶
NewInfluxdbDataSource create a new influxdb data source
func NewMySQLDataSource ¶
NewMySQLDataSource create a new influxdb data source
func NewPrometheusDataSource ¶
NewPrometheusDataSource create a new influxdb data source
func NewURLDataSource ¶
NewURLDataSource used to create a url datasource engine
type EngineCreator ¶
EngineCreator used to create datasource engine
type Point ¶
type Point interface { Data() map[string]interface{} Labels() map[string]string Values() map[string]interface{} NoValue() bool }
Point 代表通用的指标返回值 Data() 返回的是用来做阈值判断和生成告警内容的数据 Labels() 返回的是数据 Label, 主要用于事件的 Metric 配对, 相同 Labels() 结果的多个 Point 被视为同一个指标
type Prometheus ¶
Prometheus represent the Prometheus datasource
func (*Prometheus) CheckQuery ¶
func (src *Prometheus) CheckQuery(now time.Time, query string) error
CheckQuery check if the query is valid