metrics

package
v3.0.0-...-2700aaf Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Metrics

Code in this folder is responsible for reading and writing metric definitions. At the moment, metric definitions support two storages:

  • PostgreSQL database
  • YAML file

Content

  • `postgres*.go` files cover the functionality for the PostgreSQL database.
  • `yaml*.go` files cover the functionality for the YAML file.
  • `metrics.yaml` holds all default metrics and presets.
  • `default.go` provides access to default metrics.

Index

Constants

View Source
const CSVLogDefaultGlobSuffix = "*.csv"
View Source
const CSVLogDefaultRegEx = `` /* 298-byte string literal not displayed */

Variables

View Source
var PgSeverities = [...]string{"DEBUG", "INFO", "NOTICE", "WARNING", "ERROR", "LOG", "FATAL", "PANIC"}
View Source
var PgSeveritiesLocale = map[string]map[string]string{
	"C.": {"DEBUG": "DEBUG", "LOG": "LOG", "INFO": "INFO", "NOTICE": "NOTICE", "WARNING": "WARNING", "ERROR": "ERROR", "FATAL": "FATAL", "PANIC": "PANIC"},
	"de": {"DEBUG": "DEBUG", "LOG": "LOG", "INFO": "INFO", "HINWEIS": "NOTICE", "WARNUNG": "WARNING", "FEHLER": "ERROR", "FATAL": "FATAL", "PANIK": "PANIC"},
	"fr": {"DEBUG": "DEBUG", "LOG": "LOG", "INFO": "INFO", "NOTICE": "NOTICE", "ATTENTION": "WARNING", "ERREUR": "ERROR", "FATAL": "FATAL", "PANIK": "PANIC"},
	"it": {"DEBUG": "DEBUG", "LOG": "LOG", "INFO": "INFO", "NOTIFICA": "NOTICE", "ATTENZIONE": "WARNING", "ERRORE": "ERROR", "FATALE": "FATAL", "PANICO": "PANIC"},
	"ko": {"디버그": "DEBUG", "로그": "LOG", "정보": "INFO", "알림": "NOTICE", "경고": "WARNING", "오류": "ERROR", "치명적오류": "FATAL", "손상": "PANIC"},
	"pl": {"DEBUG": "DEBUG", "DZIENNIK": "LOG", "INFORMACJA": "INFO", "UWAGA": "NOTICE", "OSTRZEŻENIE": "WARNING", "BŁĄD": "ERROR", "KATASTROFALNY": "FATAL", "PANIKA": "PANIC"},
	"ru": {"ОТЛАДКА": "DEBUG", "СООБЩЕНИЕ": "LOG", "ИНФОРМАЦИЯ": "INFO", "ЗАМЕЧАНИЕ": "NOTICE", "ПРЕДУПРЕЖДЕНИЕ": "WARNING", "ОШИБКА": "ERROR", "ВАЖНО": "FATAL", "ПАНИКА": "PANIC"},
	"sv": {"DEBUG": "DEBUG", "LOGG": "LOG", "INFO": "INFO", "NOTIS": "NOTICE", "VARNING": "WARNING", "FEL": "ERROR", "FATALT": "FATAL", "PANIK": "PANIC"},
	"tr": {"DEBUG": "DEBUG", "LOG": "LOG", "BİLGİ": "INFO", "NOT": "NOTICE", "UYARI": "WARNING", "HATA": "ERROR", "ÖLÜMCÜL (FATAL)": "FATAL", "KRİTİK": "PANIC"},
	"zh": {"调试": "DEBUG", "日志": "LOG", "信息": "INFO", "注意": "NOTICE", "警告": "WARNING", "错误": "ERROR", "致命错误": "FATAL", "比致命错误还过分的错误": "PANIC"},
}

Functions

func GetDefaultBuiltInMetrics

func GetDefaultBuiltInMetrics() []string

func ParseLogs

func ParseLogs(ctx context.Context, conn db.PgxIface, mdb *sources.MonitoredDatabase, realDbname, metricName string, configMap map[string]float64, storeCh chan<- []MeasurementEnvelope)

Types

type CmdOpts

type CmdOpts struct {
	Metrics                      string `` /* 132-byte string literal not displayed */
	CreateHelpers                bool   `` /* 144-byte string literal not displayed */
	DirectOSStats                bool   `` /* 177-byte string literal not displayed */
	InstanceLevelCacheMaxSeconds int64  `` /* 302-byte string literal not displayed */
	EmergencyPauseTriggerfile    string `` /* 237-byte string literal not displayed */
}

CmdOpts specifies metric command-line options

type ExtensionInfo

type ExtensionInfo struct {
	ExtName       string `yaml:"ext_name"`
	ExtMinVersion string `yaml:"ext_min_version"`
}

type ExtensionOverrides

type ExtensionOverrides struct {
	TargetMetric              string          `yaml:"target_metric"`
	ExpectedExtensionVersions []ExtensionInfo `yaml:"expected_extension_versions"`
}

type Measurement

type Measurement map[string]any

type MeasurementEnvelope

type MeasurementEnvelope struct {
	DBName           string
	SourceType       string
	MetricName       string
	CustomTags       map[string]string
	Data             Measurements
	MetricDef        Metric
	RealDbname       string
	SystemIdentifier string
}

type Measurements

type Measurements []map[string]any

type Metric

type Metric struct {
	SQLs            SQLs
	InitSQL         string   `yaml:"init_sql,omitempty"`
	NodeStatus      string   `yaml:"node_status,omitempty"`
	Gauges          []string `yaml:",omitempty"`
	IsInstanceLevel bool     `yaml:"is_instance_level,omitempty"`
	StorageName     string   `yaml:"storage_name,omitempty"`
	Description     string   `yaml:"description,omitempty"`
}

func (Metric) GetSQL

func (m Metric) GetSQL(version int) string

func (Metric) PrimaryOnly

func (m Metric) PrimaryOnly() bool

func (Metric) StandbyOnly

func (m Metric) StandbyOnly() bool

type MetricAttrs

type MetricAttrs struct {
	ExtensionVersionOverrides []ExtensionOverrides `yaml:"extension_version_based_overrides,omitempty"`
	IsPrivate                 bool                 `yaml:"is_private,omitempty"`                // used only for extension overrides currently and ignored otherwise
	DisabledDays              string               `yaml:"disabled_days,omitempty"`             // Cron style, 0 = Sunday. Ranges allowed: 0,2-4
	DisableTimes              []string             `yaml:"disabled_times,omitempty"`            // "11:00-13:00"
	StatementTimeoutSeconds   int64                `yaml:"statement_timeout_seconds,omitempty"` // overrides per monitored DB settings
}

type MetricDefs

type MetricDefs map[string]Metric

type Metrics

type Metrics struct {
	MetricDefs MetricDefs `yaml:"metrics"`
	PresetDefs PresetDefs `yaml:"presets"`
}

func GetDefaultMetrics

func GetDefaultMetrics() (metrics *Metrics)

type Migrator

type Migrator interface {
	Migrate() error
	NeedsMigration() (bool, error)
}

type Preset

type Preset struct {
	Description string
	Metrics     map[string]float64
}

type PresetDefs

type PresetDefs map[string]Preset

type Reader

type Reader interface {
	GetMetrics() (*Metrics, error)
}

type ReaderWriter

type ReaderWriter interface {
	Reader
	Writer
}

func NewDefaultMetricReader

func NewDefaultMetricReader(context.Context) (ReaderWriter, error)

NewDefaultMetricReader creates a new default metric reader with an empty path.

func NewPostgresMetricReaderWriter

func NewPostgresMetricReaderWriter(ctx context.Context, connstr string) (ReaderWriter, error)

func NewPostgresMetricReaderWriterConn

func NewPostgresMetricReaderWriterConn(ctx context.Context, conn db.PgxPoolIface) (ReaderWriter, error)

func NewYAMLMetricReaderWriter

func NewYAMLMetricReaderWriter(ctx context.Context, path string) (ReaderWriter, error)

type SQLs

type SQLs map[int]string

type Writer

type Writer interface {
	WriteMetrics(metricDefs *Metrics) error
	DeleteMetric(metricName string) error
	DeletePreset(presetName string) error
	UpdateMetric(metricName string, metric Metric) error
	UpdatePreset(presetName string, preset Preset) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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