server

package
v0.1.14-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPGet

func HTTPGet(url string, params map[string]string) (string, error)

func InitDB

func InitDB()

func LoadConfig

func LoadConfig(version string)

func Run

func Run(ventiVersion string)

func StartAlertDaemon

func StartAlertDaemon()

func StartServer

func StartServer()

func TokenRequired

func TokenRequired(c *gin.Context)

TODO: add to api routes

Types

type Alert

type Alert struct {
	Status       string            `json:"status"`
	Labels       map[string]string `json:"labels,omitempty"`
	Annotations  map[string]string `json:"annotations,omitempty"`
	GeneratorURL string            `json:"generatorURL,omitempty"`
}

type AlertRule

type AlertRule struct {
	Alert       string            `json:"alert,omitempty"`
	Expr        string            `json:"expr"`
	For         time.Duration     `json:"for,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
	State       AlertState        `json:"state,omitempty"`
	ActiveAt    time.Time         `json:"activeStartTime,omitempty"`
}

type AlertRuleGroup

type AlertRuleGroup struct {
	Name           string            `json:"name"`
	Rules          []AlertRule       `json:"rules"`
	DatasourceType DatasourceType    `json:"datasource" yaml:"datasource"`
	CommonLabels   map[string]string `json:"commonLabels,omitempty" yaml:"commonLabels,omitempty"`
}

func GetAlertRuleGroups

func GetAlertRuleGroups() []AlertRuleGroup

type AlertRuleGroupList

type AlertRuleGroupList struct {
	Groups []AlertRuleGroup `json:"groups"`
}

type AlertState

type AlertState string
const (
	AlertStateInactive AlertState = "inactive"
	AlertStatePending  AlertState = "pending"
	AlertStateFiring   AlertState = "firing"
)

type ChartOptions

type ChartOptions struct {
	YMax int `json:"yMax,omitempty" yaml:"yMax,omitempty"`
}

type Config

type Config struct {
	Version           string
	EtcUsersConfig    EtcUsersConfig
	DatasourcesConfig DatasourcesConfig
	Dashboards        []Dashboard
	AlertRuleGroups   []AlertRuleGroup
}

func GetConfig

func GetConfig() Config

type Dashboard

type Dashboard struct {
	Title string `json:"title"`
	Rows  []Row  `json:"rows"`
}

dashboard

type Datasource

type Datasource struct {
	Type              DatasourceType `json:"type" yaml:"type"`
	Name              string         `json:"name" yaml:"name"`
	URL               string         `json:"url" yaml:"url"`
	BasicAuth         bool           `json:"basicAuth" yaml:"basicAuth"`
	BasicAuthUser     string         `json:"basicAuthUser" yaml:"basicAuthUser"`
	BasicAuthPassword string         `json:"basicAuthPassword" yaml:"basicAuthPassword"`
	IsDiscovered      bool           `json:"is_discovered,omitempty" yaml:"is_discovered,omitempty"`
}

func GetDatasources

func GetDatasources() ([]Datasource, error)

func GetDefaultDatasource

func GetDefaultDatasource(dstype DatasourceType) (Datasource, error)

type DatasourceType

type DatasourceType string

datasource

const (
	DatasourceTypeNone       DatasourceType = ""
	DatasourceTypePrometheus DatasourceType = "prometheus"
	DatasourceTypeLethe      DatasourceType = "lethe"
)

type DatasourcesConfig

type DatasourcesConfig struct {
	QueryTimeout time.Duration `json:"queryTimeout"`
	Datasources  []Datasource  `json:"datasources"`
}

type EtcUser

type EtcUser struct {
	Username string `yaml:"username"`
	Hash     string `yaml:"hash"`
	IsAdmin  bool   `yaml:"isAdmin,omitempty"`
}

type EtcUsersConfig

type EtcUsersConfig struct {
	EtcUsers []EtcUser `yaml:"users"`
}

user

type InstantQuery

type InstantQuery struct {
	Datasource     Datasource     `form:"datasource,omitempty"`
	DatasourceType DatasourceType `form:"datasourceType,omitempty"`
	Expr           string         `form:"expr"`
	Time           string         `form:"time,omitempty"`
}

type Panel

type Panel struct {
	Title        string        `json:"title" yaml:"title"`
	Type         string        `json:"type" yaml:"type"`
	Headers      []string      `json:"headers,omitempty" yaml:"headers,omitempty"`
	Targets      []Target      `json:"targets" yaml:"targets"`
	ChartOptions *ChartOptions `json:"chartOptions,omitempty" yaml:"chartOptions,omitempty"`
}

type PathQuery

type PathQuery struct {
	Datasource     Datasource
	DatasourceType DatasourceType
	Path           string
	Params         map[string]string
	Start          string
	End            string
	Step           string
}

type QueryData

type QueryData struct {
	ResultType ValueType `json:"resultType"`
	Result     Vector    `json:"result"`
}

type QueryResult

type QueryResult struct {
	Data   QueryData `json:"data"`
	Status string    `json:"status"`
}

{"data":{"result":[],"resultType":"logs"},"status":"success"} {"status":"success","data":{"resultType":"vector","result":[]}}

type RangeQuery

type RangeQuery struct {
	Datasource     Datasource     `form:"datasource,omitempty"`
	DatasourceType DatasourceType `form:"datasourceType,omitempty"`
	Expr           string         `form:"expr"`
	Start          string         `form:"start,omitempty"`
	End            string         `form:"end,omitempty"`
	Step           string         `form:"step,omitempty"`
}

type Row

type Row struct {
	Panels []Panel `json:"panels"`
}

type Sample

type Sample struct {
	Vaue   []interface{}     `json:"value"`
	Metric map[string]string `json:"metric"`
}

type Target

type Target struct {
	Expr       string      `json:"expr"`
	Legend     string      `json:"legend,omitempty" yaml:"legend,omitempty"`
	Legends    []string    `json:"legends,omitempty" yaml:"legends,omitempty"`
	Unit       string      `json:"unit,omitempty" yaml:"unit,omitempty"`
	Columns    []string    `json:"columns,omitempty" yaml:"columns,omitempty"`
	Headers    []string    `json:"headers,omitempty" yaml:"headers,omitempty"`
	Key        string      `json:"key,omitempty" yaml:"key,omitempty"`
	Thresholds []Threshold `json:"thresholds,omitempty" yaml:"thresholds,omitempty"`
}

type Threshold

type Threshold struct {
	Values []int `yaml:"values,omitempty" json:"values,omitempty"`
	Invert bool  `yaml:"invert,omitempty" json:"invert,omitempty"`
}

type User

type User struct {
	ID           int    `gorm:"primaryKey"`
	Username     string `gorm:"index:,unique"`
	Hash         string
	IsAdmin      bool
	Token        string
	TokenExpires time.Time
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type ValueType

type ValueType string
const (
	ValueTypeNone   ValueType = "none"
	ValueTypeVector ValueType = "vector"
	ValueTypeScalar ValueType = "scalar"
	ValueTypeMatrix ValueType = "matrix"
	ValueTypeString ValueType = "string"
)

type Vector

type Vector []Sample

Jump to

Keyboard shortcuts

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