libs

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BuildFolder      = "build"
	ViewsFolder      = "views"
	MonitorsFolder   = "monitors"
	DashboardsFolder = "dashboards"
)
View Source
const (
	VarNameMonRootFolder  = "slo_mon_root_folder_id"
	VarNameDashRootFolder = "slo_dash_root_folder_id"
)
View Source
const (
	TriggerNameCritical        = "Critical"
	TriggerNameResolveCritical = "ResolvedCritical"
	TriggerNameWarning         = "Warning"
	TriggerNameResolveWarning  = "ResolvedWarning"
)
View Source
const (
	EnvKeySumoAccessID    = "SUMOLOGIC_ACCESSID"
	EnvKeySumoAccessKey   = "SUMOLOGIC_ACCESSKEY"
	EnvKeySumoEnvironment = "SUMOLOGIC_ENVIRONMENT"
)
View Source
const LookupTableIdKey = "lookupTableId"
View Source
const MultiWindowMultiBurnTmpl = `` /* 763-byte string literal not displayed */
View Source
const NameDashFolderTmpl = "dash-folders.tf.gotf"
View Source
const NameDashboardTmpl = "dashboard.tf.gotf"
View Source
const NameGlobalTrackerTmpl = "global-tracker.tf.gotf"
View Source
const NameMainTmpl = "main.tf.gotf"
View Source
const NameModuleTmpl = "module_interface.tf.gotf"
View Source
const NameMonitorFolderTmpl = "monitor-folders.tf.gotf"
View Source
const NameMonitorTmpl = "monitor.tf.gotf"
View Source
const NameViewTmpl = "sched-view.tf.gotf"
View Source
const ScheduledViewQueryTemp = `` /* 396-byte string literal not displayed */
View Source
const ViewPrefix = "slogen_tf"

Variables

View Source
var (
	GoodResult  = color.New(color.FgHiGreen).Add(color.Bold).Printf
	GoodUResult = color.New(color.FgHiGreen).Add(color.Bold, color.Underline).Printf
	BadResult   = color.New(color.FgHiRed).Add(color.Bold).Printf
	BadUResult  = color.New(color.FgHiRed).Add(color.Bold, color.Underline).Printf
	BadInfo     = color.New(color.FgHiRed).Add(color.BlinkSlow).Printf
	GoodInfo    = color.New(color.FgGreen).Printf
	WarnInfo    = color.New(color.FgHiMagenta).Add(color.Italic, color.Faint).Printf
	WarnUInfo   = color.New(color.FgHiMagenta).Add(color.Underline, color.Faint).Printf
	OkInfo      = color.New(color.FgHiMagenta).Printf
)

Functions

func DeDupe

func DeDupe(strSlice []string) []string

func EnsureDir

func EnsureDir(dirName string, clean bool) error

func ExecSLOTmpl

func ExecSLOTmpl(tmplName string, slo SLO, outDir string) error

func FileFromTmpl

func FileFromTmpl(name string, path string, data interface{}) error

func GenFoldersTF

func GenFoldersTF(srvList []string, outDir string) error

func GenOverviewTF

func GenOverviewTF(s map[string]*SLO, c GenConf) error

func GenTerraform

func GenTerraform(slos map[string]*SLO, c GenConf) (string, error)

GenTerraform for all openslo files in the path

func GetStartOfMonth

func GetStartOfMonth() time.Time

func GiveKeys

func GiveKeys(m map[string]bool) []string

func GiveScheduleViewName

func GiveScheduleViewName(s SLO) string

func GiveStrFromTmpl added in v0.5.1

func GiveStrFromTmpl(tmplStr string, data interface{}) (string, error)

func Log

func Log() *zap.SugaredLogger

func ParseDir

func ParseDir(path string, ignoreErrors bool) (map[string]*SLO, error)

func SetupOutDir

func SetupOutDir(c GenConf) error

func TFExec

func TFExec(wdPath string, action TFAction) error

func UploadSLOLookup added in v0.2.4

func UploadSLOLookup(id, url, filename string) error

Types

type BurnRate

type BurnRate struct {
	View          string         `yaml:"view,omitempty"`
	Budget        float64        `yaml:"budget,omitempty"`
	ShortWindow   string         `yaml:"shortWindow"`
	ShortLimit    float64        `yaml:"shortLimit"`
	LongWindow    string         `yaml:"longWindow"`
	LongLimit     float64        `yaml:"longLimit"`
	Notifications []Notification `yaml:"notifications,omitempty"`
}

BurnRate only supports 2 window with first one having

type GenConf

type GenConf struct {
	OutDir        string
	DashFolder    string
	MonitorFolder string
	ViewPrefix    string
	DoPlan        bool
	DoApply       bool
	IgnoreError   bool
	Clean         bool
}

type LayoutItem

type LayoutItem struct {
	Key       PanelKey
	Structure string
}

type Notification

type Notification struct {
	TriggerFor     []string `yaml:"triggerFor,omitempty"`
	ConnectionType string   `yaml:"connectionType"`
	ConnectionID   string   `yaml:"connectionID,omitempty"`
	Subject        string   `yaml:"subject,omitempty"`
	Recipients     []string `yaml:"recipients,omitempty"`
	MessageBody    string   `yaml:"messageBody,omitempty"`
	TimeZone       string   `yaml:"timeZone,omitempty"`
}

type PanelKey

type PanelKey string
const (
	KeyGaugeToday      PanelKey = "gauge-today"
	KeyGaugeWeek       PanelKey = "gauge-week"
	KeyGaugeMonth      PanelKey = "gauge-month"
	KeyPanelHourlyBurn PanelKey = "hourly-burn-rate"
	KeyPanelBurnTrend  PanelKey = "burn-trend"
	KeyPanelBudgetLeft PanelKey = "budget-left"
)

type Results

type Results struct {
	// contains filtered or unexported fields
}

type SLO

type SLO struct {
	*v1alpha.SLO   `yaml:",inline"`
	BurnRateAlerts []BurnRate        `yaml:"burnRateAlerts,omitempty"`
	Labels         map[string]string `yaml:"labels,omitempty"`
	Fields         map[string]string `yaml:"fields,omitempty"`
	ViewName       string            `yaml:"viewName"`
}

func Parse

func Parse(filename string) (*SLO, error)

func ParseFile

func ParseFile(path string) (*SLO, error)

func (SLO) Target added in v0.5.1

func (s SLO) Target() float64

type SLODashboard

type SLODashboard struct {
	Service       string
	SLOName       string
	Title         string
	Desc          string
	Theme         string
	Target        float64
	RefreshFreq   int
	SearchPanels  []SearchPanel
	Layout        []LayoutItem
	Viz           VisualSetting
	StrYAMLConfig string
	Labels        map[string]string
}

func DashConfigFromSLO

func DashConfigFromSLO(sloConf SLO) (*SLODashboard, error)

type SLOMap

type SLOMap map[string]*SLO

type SLOMonitorConfig

type SLOMonitorConfig struct {
	Name       string
	Desc       string
	Service    string
	Objectives []SLOObjective
}

func MonitorConfigFromOpenSLO

func MonitorConfigFromOpenSLO(sloConf SLO) (*SLOMonitorConfig, error)

type SLOObjective

type SLOObjective struct {
	Suffix        string
	Query         string
	Field         string
	TimeRange     string
	ValueWarning  float64
	ValueCritical float64
	Notifications []Notification `yaml:"notifications,omitempty"`
}

type SLOOverviewDashConf

type SLOOverviewDashConf struct {
	QueryTable string
	QueryDaily string
	DashVars   []string
}

type ScheduledView

type ScheduledView struct {
	SLOName        string `yaml:"sloName"`
	Service        string `yaml:"service"`
	Index          string `yaml:"index"`
	Query          string `yaml:"query"`
	StartTime      string `yaml:"startTime"` /// e.g. "2019-09-01T00:00:00Z"
	Retention      int    `yaml:"retention"` // unit: days
	PreventDestroy bool   `yaml:"preventDestroy,omitempty"`
}

ScheduledView implicit

func ViewConfigFromSLO

func ViewConfigFromSLO(sloConf SLO) (*ScheduledView, error)

type SearchPanel

type SearchPanel struct {
	Key                 PanelKey
	Title               string
	Desc                string
	VisualSettings      string
	Query               string
	TimeRange           string
	IsRelativeTimeRange bool
}

type TFAction

type TFAction string
const (
	TFPlan  TFAction = "PLAN"
	TFApply TFAction = "APPLY"
)

type TFModules

type TFModules struct {
	Path string
	Vars []string
}

type ViewSpec added in v0.2.4

type ViewSpec struct {
	IndexName       string `yaml:"indexName"`
	AutoParse       bool   `yaml:"autoParse"`
	StartTime       string `yaml:"startTime"`
	RetentionInDays int    `yaml:"retentionInDays"`
	PreventDestroy  bool   `yaml:"preventDestroy"`
}

type ViewTemplateValues

type ViewTemplateValues struct {
	Name       string
	Service    string
	TotalQuery string
	GoodQuery  string
	Labels     map[string]string `yaml:"labels,omitempty"`
	Fields     map[string]string `yaml:"fields,omitempty"`
	Goal       float64
}

type VisualSetting

type VisualSetting struct {
	Mode         string
	Type         string
	XAxisUnit    string
	XAxisTitle   string
	MarkerType   string
	DisplayType  string
	LineDashType string
}

Jump to

Keyboard shortcuts

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