server

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: Apache-2.0 Imports: 25 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 RunHTTPLetheQuery

func RunHTTPLetheQuery(httpQuery HTTPQuery) (string, error)

func RunHTTPLetheQueryRange

func RunHTTPLetheQueryRange(httpQueryRange HTTPQueryRange) (string, error)

func RunHTTPPrometheusQuery

func RunHTTPPrometheusQuery(httpQuery HTTPQuery) (string, error)

func RunHTTPPrometheusQueryRange

func RunHTTPPrometheusQueryRange(httpQueryRange HTTPQueryRange) (string, error)

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"`
	Host         string         `json:"host"`
	Port         int            `json:"port,omitempty" yaml:"port,omitempty"`
	IsDiscovered bool           `json:"is_discovered,omitempty" yaml:"isDiscovered,omitempty"`
}

func GetDatasources

func GetDatasources() ([]Datasource, error)

type DatasourceType

type DatasourceType string

datasource

const (
	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 HTTPQuery

type HTTPQuery struct {
	Host  string `form:"host,omitempty"`
	Port  int    `form:"port,omitempty"`
	Query string `form:"expr"`
	Time  string `form:"time,omitempty"`
}

type HTTPQueryRange

type HTTPQueryRange struct {
	Host  string `form:"host,omitempty"`
	Port  int    `form:"port,omitempty"`
	Query string `form:"expr"`
	Start string `form:"start"`
	End   string `form:"end"`
	Step  string `form:"step"`
}

type LoginForm

type LoginForm struct {
	Username string `form:"username" binding:"required"`
	Password string `form:"password" binding:"required"`
}

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