libs

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 23 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"
	EnvKeyHTTPProxy       = "HTTP_PROXY"
	EnvKeyHTTPSProxy      = "HTTPS_PROXY"
)
View Source
const (
	BudgetingMethodNameTimeSlices  = "Timeslices"
	BudgetingMethodNameOccurrences = "Occurrences"
)
View Source
const DefaultScheduledViewRetention = 100
View Source
const LookupTableIdKey = "lookupTableId"
View Source
const MultiWindowMultiBurnTmpl = `` /* 791-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 NameServiceTrackerTmpl = "service-overview.tf.gotf"
View Source
const NameViewTmpl = "sched-view.tf.gotf"
View Source
const ScheduledViewQueryTemp = `` /* 396-byte string literal not displayed */
View Source
const TimeSliceMultiWindowMultiBurnTmpl = `` /* 1095-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 ExecServiceOverview added in v0.7.1

func ExecServiceOverview(slos map[string]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 GenGlobalOverviewTF added in v0.7.1

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

func GenOverviewTF

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

func GenServiceOverviewDashboard added in v0.7.1

func GenServiceOverviewDashboard(sloPathMap map[string]*SLO, outDir string) 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

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

func UploadSLOLookup(id, url, filename string) error

Types

type Alerts

type Alerts struct {
	BurnRate []BurnRate `yaml:"burnRate,omitempty"`
}

type BurnAlertTmplParams added in v0.7.0

type BurnAlertTmplParams struct {
	BurnRate
	TimesliceRatioTarget float64
}

func ConvertToBurnRateTmplParams added in v0.7.0

func ConvertToBurnRateTmplParams(alerts []BurnRate, timesliceTarget float64) []BurnAlertTmplParams

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 InfoLogger

type InfoLogger struct {
}

func (InfoLogger) Printf

func (t InfoLogger) Printf(format string, vals ...interface{})

type LayoutItem

type LayoutItem struct {
	Key       string
	Structure string
}

type MonitorConnections added in v0.7.0

type MonitorConnections struct {
	Type       string `json:"type,omitempty"`
	Name       string `json:"name,omitempty"`
	ID         string `json:"id,omitempty"`
	Desc       string `json:"description,omitempty"`
	CreatedAt  string `json:"createdAt,omitempty"`
	CreatedBy  string `json:"createdBy,omitempty"`
	ModifiedAt string `json:"modifiedAt,omitempty"`
	ModifiedBy string `json:"modifiedBy,omitempty"`
	URL        string `json:"url,omitempty"`
	UserName   string `json:"username,omitempty"`
}

func GiveConnectionIDS added in v0.7.0

func GiveConnectionIDS(token string) ([]MonitorConnections, error)

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"
	KeyPanelBreakDown  PanelKey = "breakdown"
)

type Results

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

type SLO

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

func Parse

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

func ParseFile

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

func (SLO) Target

func (s SLO) Target() float64

func (SLO) TimesliceTarget added in v0.7.0

func (s SLO) TimesliceTarget() 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
	Fields        []string
	ViewName      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 ServiceOverviewDashboard added in v0.7.1

type ServiceOverviewDashboard struct {
	Service string
	Rows    []ServiceOverviewRow
	Layout  []LayoutItem
	Vars    []string
}

type ServiceOverviewRow added in v0.7.1

type ServiceOverviewRow struct {
	SLOName string
	Panels  []SearchPanel
	SLOConf SLO
}

type TFAction

type TFAction string
const (
	TFPlan        TFAction = "PLAN"
	TFApply       TFAction = "APPLY"
	TFPlanDestroy TFAction = "PlanDestroy"
	TFDestroy     TFAction = "DESTROY"
)

type TFModules

type TFModules struct {
	Path string
	Vars []string
}

type ViewSpec

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