types

package
v0.0.0-...-e121adf Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMetric

func AddMetric(observation *pb.Observation, name string, status pb.Status, score float32) *pb.Observation

func CompareTimestamp

func CompareTimestamp(a *timestamp.Timestamp, b *timestamp.Timestamp) int32

func DumpPanorama

func DumpPanorama(w io.Writer, pano *pb.Panorama)

func DumpView

func DumpView(w io.Writer, view *pb.View)

func GetMetric

func GetMetric(observation *pb.Observation, name string) *pb.Metric

func InferenceString

func InferenceString(inf *pb.Inference) string

func JSONMarshal

func JSONMarshal(t interface{}, prefix string, indent string) ([]byte, error)

func JString

func JString(config interface{}) string

func LoadConfig

func LoadConfig(path string, config interface{}) error

func MetricsString

func MetricsString(metrics map[string]*pb.Metric) string

func NewMetrics

func NewMetrics(names ...string) map[string]*pb.Metric

func NewObservation

func NewObservation(t time.Time, names ...string) *pb.Observation

func NewObservationSingleMetric

func NewObservationSingleMetric(t time.Time, name string, status pb.Status, score float32) *pb.Observation

func NewReport

func NewReport(observer string, subject string, metrics map[string]*pb.Value) *pb.Report

func ObservationString

func ObservationString(ob *pb.Observation) string

func PanoramaString

func PanoramaString(pano *pb.Panorama) string

func SaveConfig

func SaveConfig(path string, config interface{}) error

func SetMetric

func SetMetric(observation *pb.Observation, name string, status pb.Status, score float32) bool

func StatusFromFullStr

func StatusFromFullStr(status string) pb.Status

func StatusFromStr

func StatusFromStr(status string) pb.Status

func StringArrayToSlice

func StringArrayToSlice(array string) ([]string, error)

func SubtractTimestamp

func SubtractTimestamp(a *timestamp.Timestamp, b *timestamp.Timestamp) int64

func ViewString

func ViewString(view *pb.View) string

Types

type BufferingConfig

type BufferingConfig struct {
	HoldTime    int
	HoldListLen int
}

type ClassifierConfig

type ClassifierConfig struct {
	Context string
	Subject string
	Status  string
	Score   string
}

type ConcurrentPanorama

type ConcurrentPanorama struct {
	sync.RWMutex
	Value *pb.Panorama
}

type Event

type Event struct {
	Time    time.Time
	Id      string
	Subject string
	Context string
	Status  pb.Status
	Score   float32
	Extra   string
}

type EventMap

type EventMap struct {
	Fields map[string]string
}

type EventParser

type EventParser interface {
	ParseLine(line string) *Event
}

type FieldClassifier

type FieldClassifier func(result map[string]string) *FieldClassifierResult

func NewFieldClassifier

func NewFieldClassifier(config *ClassifierConfig) (FieldClassifier, error)

type FieldClassifierResult

type FieldClassifierResult struct {
	Context string
	Subject string
	Status  pb.Status
	Score   float32
}

type FieldFilter

type FieldFilter func(fields map[string]string) (map[string]string, bool)

func NewFieldEqualsFilter

func NewFieldEqualsFilter(field string, match string) FieldFilter

func NewFieldFilter

func NewFieldFilter(config *FieldFilterClauseConfig) (FieldFilter, error)

func NewFieldInSetFilter

func NewFieldInSetFilter(field string, elements ...string) FieldFilter

func NewFieldMRegexpMapAnyFilter

func NewFieldMRegexpMapAnyFilter(field string, prefix_group string, patterns ...string) FieldFilter

func NewFieldMRegexpMapFilter

func NewFieldMRegexpMapFilter(field string, prefix_group string, pattern string) FieldFilter

func NewFieldNotEqualFilter

func NewFieldNotEqualFilter(field string, match string) FieldFilter

func NewFieldRegexAnyFilter

func NewFieldRegexAnyFilter(field string, patterns ...string) FieldFilter

func NewFieldRegexFilter

func NewFieldRegexFilter(field string, pattern string) FieldFilter

type FieldFilterBody

type FieldFilterBody struct {
	Chain      []FieldFilter
	Classifier FieldClassifier
}

type FieldFilterBranch

type FieldFilterBranch struct {
	Head   FieldFilter
	Bodies []*FieldFilterBody
}

type FieldFilterChainConfig

type FieldFilterChainConfig struct {
	Chain      []*FieldFilterClauseConfig
	Classifier ClassifierConfig
}

type FieldFilterClauseConfig

type FieldFilterClauseConfig struct {
	Field         string
	Operator      string
	Pattern       string
	CaptureResult bool // whether to capture filter result or just return the decision
}

type FieldFilterTree

type FieldFilterTree []*FieldFilterBranch

func NewFieldFilterTree

func NewFieldFilterTree(config *FieldFilterTreeConfig) (FieldFilterTree, error)

func (*FieldFilterTree) Eval

func (self *FieldFilterTree) Eval(fields map[string]string) (map[string]string, FieldClassifier, bool)

type FieldFilterTreeConfig

type FieldFilterTreeConfig struct {
	FilterTree []*FieldFilterChainConfig
}

type GarbageCollectionConfig

type GarbageCollectionConfig struct {
	Enable    bool
	Frequency int
	Threshold int
	Relative  bool
}

type HealthDB

type HealthDB interface {
	// Open or create a database with file name
	Open() (*sql.DB, error)

	// Insert a report into the database
	InsertReport(report *pb.Report) error

	// Insert an inference result into the database
	InsertInference(inf *pb.Inference) error

	// Insert a registration into the database
	InsertRegistration(registration *Registration) error

	// Read the past registrations from the database
	ReadRegistrations() (map[uint64]*Registration, uint64)

	// Close the database connection
	Close()
}

type HealthExchange

type HealthExchange interface {
	// Propagate a report to other peers
	Propagate(report *pb.Report) error

	// Let others know I'd like to subscribe to reports about subject
	Subscribe(subject string) error

	// Let others know I'd like to unsubscribe to reports about subject
	Unsubscribe(subject string) error

	// Ping one peer and get a response
	Ping(peer string) (*pb.PingReply, error)

	// Ping all peers and get response
	PingAll() (map[string]*pb.PingReply, error)

	// peer is interested in a particular subject
	Interested(peer string, subject string) bool

	// peer is not interested in a particular subject
	Uninterested(peer string, subject string) bool
}

type HealthInference

type HealthInference interface {
	// Associate database with the raw storage
	SetDB(db HealthDB)

	// Asynchronously infer the health of a subject
	InferSubjectAsync(subject string) error

	// Infer the health of a subject
	InferSubject(subject string) (*pb.Inference, error)

	// Asynchronously infer the health of a subject that has a new report
	// May support incremental inference
	InferReportAsync(report *pb.Report) error

	// Infer the health of a subject that has a new report
	// May support incremental inference
	InferReport(report *pb.Report) (*pb.Inference, error)

	// Get the health inference of a subject
	GetInference(subject string) *pb.Inference

	// Get all the health inference for all observed subjects
	DumpInference() map[string]*pb.Inference

	// Start the inference service
	Start() error

	// Stop the inference service
	Stop() error
}

type HealthServerConfig

type HealthServerConfig struct {
	Addr             string
	Id               string
	Subjects         []string
	Peers            map[string]string // all peers' id and address
	FilterSubmission bool              // whether to filter submitted report based on the subject id
	LogLevel         string
	DumpMemUsage     bool
	DBFile           string

	GCConfig  GarbageCollectionConfig
	BufConfig BufferingConfig
}

type HealthStorage

type HealthStorage interface {
	// Associate database with the raw storage
	SetDB(db HealthDB)

	// Add a subject to the observing subject list
	AddSubject(subject string) bool

	// Stop observing a particular subject, all the reports
	// concerning this subject will be ignored
	RemoveSubject(subject string, clean bool) bool

	// Get the list of subjects that we have observed
	GetSubjects() map[string]time.Time

	// Add a report to the view storage
	AddReport(report *pb.Report, filter bool) (int, error)

	// Get the latest report for a subject
	GetLatestReport(subject string) *pb.Report

	// Get the view from an observer about a subject
	GetView(observer string, subject string) *pb.View

	// Get the whole panorama for a subject
	GetPanorama(subject string) *ConcurrentPanorama

	// Get all the panoramas for all observed subjects
	DumpPanorama() map[string]*pb.Panorama

	// Garbage collect stale observations from panoramas
	// Return number of reaped observations for a subject
	// When relative is true, the GC is based on elapsed
	// time with the most recent observation rather than
	// the absolute time now.
	GC(ttl time.Duration, relative bool) map[string]uint32
}

type ObserverModule

type ObserverModule struct {
	Module   string
	Observer string
}

Simple tuple about the local observer that will monitor health of a component

type Registration

type Registration struct {
	ObserverModule
	Handle uint64
	Time   time.Time
}

Represents a registration to Panorama

Jump to

Keyboard shortcuts

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