libs

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BuildFolder      = "build"
	ViewsFolder      = "views"
	MonitorsFolder   = "monitors"
	DashboardsFolder = "dashboards"
	NativeSLOFolder  = "slos"
)
View Source
const (
	VarNameMonRootFolder        = "slo_mon_root_folder_id"
	VarNameDashRootFolder       = "slo_dash_root_folder_id"
	VarNameNativeSLORootFolder  = "slo_root_folder_id"
	VarNameSLOMonitorRootFolder = "slo_monitor_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 = `` /* 878-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 NameModuleTmpl = "module_interface.tf.gotf"
View Source
const NameMonitorFolderTmpl = "monitor-folders.tf.gotf"
View Source
const NameMonitorTmpl = "monitor.tf.gotf"
View Source
const NameSLOFolderTmpl = "slo-folders.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 SLOv1Alpha, outDir string) error

func FileFromTmpl

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

func GenFoldersTF

func GenFoldersTF(srvList []string, conf GenConf) error

func GenGlobalOverviewTF

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

func GenMainTF added in v1.0.2

func GenMainTF(path string, conf GenConf) error

func GenOverviewTF

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

func GenSLOFoldersTF

func GenSLOFoldersTF(srvList []string, conf GenConf) error

func GenServiceOverviewDashboard

func GenServiceOverviewDashboard(sloPathMap map[string]*SLOv1Alpha, outDir string) error

func GenTerraform

func GenTerraform(slosMv map[string]*SLOMultiVerse, 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 SLOv1Alpha) string

func GiveStrFromTmpl

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

func GiveStructCompare

func GiveStructCompare(a, b interface{}) bool

func Log

func Log() *zap.SugaredLogger

func ParseDir

func ParseDir(path string, ignoreErrors bool, slos map[string]*SLOMultiVerse) 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

type BurnAlertTmplParams struct {
	BurnRate
	Target               float64 // SLO goal i.e. the slo percent age in [0.0,1.0] decimal form
	TimesliceRatioTarget float64 // only applicable for timeslice based budgeting
}

func ConvertToBurnRateTmplParams

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

type BurnRate

type BurnRate struct {
	View          string         `yaml:"view,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
	SLORootFolder        string
	SLOMonitorRootFolder string
	DoPlan               bool
	DoApply              bool
	IgnoreError          bool
	Clean                bool
	AsModule             bool
	UseViewHash          bool
	OnlyNative           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

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

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"`
	PayloadOverride           string   `yaml:"payload_override,omitempty"`
	ResolutionPayloadOverride string   `yaml:"resolution_payload_override,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 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 SLOv1Alpha) (*SLODashboard, error)

type SLOMap

type SLOMap map[string]*SLOv1Alpha

type SLOMonitorConfig

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

func MonitorConfigFromOpenSLO

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

type SLOMultiVerse

type SLOMultiVerse struct {
	ConfigPath              string
	SLOAlpha                *SLOv1Alpha
	SLO                     *specs.OpenSLOSpec
	AlertPolicy             *oslo.AlertPolicy
	AlertCondition          *oslo.AlertCondition
	AlertNotificationTarget *oslo.AlertNotificationTarget
}

func Parse

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

func ParseFile

func ParseFile(path string) (*SLOMultiVerse, 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 SLOv1Alpha

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

func (SLOv1Alpha) Name

func (s SLOv1Alpha) Name() string

func (SLOv1Alpha) Target

func (s SLOv1Alpha) Target() float64

func (SLOv1Alpha) TimesliceTarget

func (s SLOv1Alpha) TimesliceTarget() float64

func (SLOv1Alpha) ViewID

func (s SLOv1Alpha) ViewID() string

ViewID return the short sha1 hash for view query to ensure old view data is not reused

func (SLOv1Alpha) ViewName

func (s SLOv1Alpha) ViewName() string

func (SLOv1Alpha) ViewQuery

func (s SLOv1Alpha) ViewQuery() (string, error)

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 SLOv1Alpha) (*ScheduledView, error)

type SearchPanel

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

type ServiceOverviewDashboard

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

type ServiceOverviewRow

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

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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