Documentation
¶
Index ¶
- func AddCycleError(counter *prometheus.CounterVec, event interpreter.Event, errorTag string)
- func AddDuration(histogram prometheus.ObserverVec, duration float64, event interpreter.Event)
- func AddEventError(counter *prometheus.CounterVec, event interpreter.Event, errorTag string)
- func NewParserValidator(cycleValidator cycleValidation, eventValidator eventValidation, ...) *parserValidator
- func ParseTime(e interpreter.Event, location TimeLocation) time.Time
- func Provide() fx.Option
- func ProvideEventMetrics() fx.Option
- type CalculatorFunc
- type CycleValidationConfig
- type DurationCalculator
- type EventClient
- type EventToCurrentCalculator
- type EventValidationConfig
- type EventsParser
- type Finder
- type Measures
- type MetadataParser
- type ParserValidator
- type RebootDurationParser
- type RebootLoggerIn
- type RebootParserConfig
- type RebootParserIn
- type RebootParserNameIn
- type TimeElapsedConfig
- type TimeLocation
- type TimeValidationConfig
- type ValidatorsIn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCycleError ¶
func AddCycleError(counter *prometheus.CounterVec, event interpreter.Event, errorTag string)
AddCycleError adds a cycle error tag to the cycle error counter.
func AddDuration ¶
func AddDuration(histogram prometheus.ObserverVec, duration float64, event interpreter.Event)
AddDuration adds the duration to the specific histogram.
func AddEventError ¶
func AddEventError(counter *prometheus.CounterVec, event interpreter.Event, errorTag string)
AddEventError adds a error tag to the event error counter.
func NewParserValidator ¶
func NewParserValidator(cycleValidator cycleValidation, eventValidator eventValidation, activateFunc func([]interpreter.Event, interpreter.Event) bool) *parserValidator
NewParserValidator creates a new parserValidator.
func ParseTime ¶
func ParseTime(e interpreter.Event, location TimeLocation) time.Time
ParseTime gets the time from the proper location of an Event
func Provide ¶
Provide bundles everything needed for setting up all of the event objects for easier wiring into an uber fx application.
func ProvideEventMetrics ¶
ProvideEventMetrics builds the event-related metrics and makes them available to the container.
Types ¶
type CalculatorFunc ¶
type CalculatorFunc func([]interpreter.Event, interpreter.Event) error
CalculatorFunc is a function that calculates a duration and returns an error if there is a problem while performing the calculations.
func BootDurationCalculator ¶
func BootDurationCalculator(logger *zap.Logger, successCallback func(interpreter.Event, float64)) CalculatorFunc
BootDurationCalculator returns a CalculatorFunc that calculates the time between the birthdate and the boot-time of an event, calling the successCallback if a duration is successfully calculated.
func (CalculatorFunc) Calculate ¶
func (cf CalculatorFunc) Calculate(events []interpreter.Event, event interpreter.Event) error
Calculate implements the DurationCalculator interface.
type CycleValidationConfig ¶
type CycleValidationConfig struct { Key enums.CycleValidationType CycleType string // validate reboot events or last cycle events MetadataValidators []string EventOrder []string // the cycle will be sorted in descending order by boot-time, then birthdate }
CycleValidationConfig is the config for a cycle validator.
type DurationCalculator ¶
type DurationCalculator interface {
Calculate([]interpreter.Event, interpreter.Event) error
}
DurationCalculator calculates the different durations in a boot cycle.
type EventClient ¶
type EventClient interface {
GetEvents(deviceID string) []interpreter.Event
}
EventClient is an interface that provides a list of events related to a device.
type EventToCurrentCalculator ¶
type EventToCurrentCalculator struct {
// contains filtered or unexported fields
}
EventToCurrentCalculator calculates the difference between the current event and a previous event.
func NewEventToCurrentCalculator ¶
func NewEventToCurrentCalculator(eventFinder Finder, successCallback func(currentEvent interpreter.Event, foundEvent interpreter.Event, duration float64), logger *zap.Logger) (*EventToCurrentCalculator, error)
NewEventToCurrentCalculator creates a new EventToCurrentCalculator and an error if the finder is nil.
func (*EventToCurrentCalculator) Calculate ¶
func (c *EventToCurrentCalculator) Calculate(events []interpreter.Event, event interpreter.Event) error
Calculate implements the DurationCalculator interface by subtracting the birthdates of the two events.
type EventValidationConfig ¶
type EventValidationConfig struct { Key enums.EventValidationType BootTimeValidator TimeValidationConfig BirthdateValidator TimeValidationConfig ValidEventTypes []string MinBootDuration time.Duration BirthdateAlignmentDuration time.Duration }
EventValidationConfig is the config for each of the validators.
type EventsParser ¶
type EventsParser interface {
Parse(eventsHistory []interpreter.Event, currentEvent interpreter.Event) ([]interpreter.Event, error)
}
EventsParser parses the relevant events from a device's history of events and returns those events.
type Finder ¶
type Finder interface {
Find(events []interpreter.Event, incomingEvent interpreter.Event) (interpreter.Event, error)
}
Finder returns a specific event in a list of events.
type Measures ¶
type Measures struct { fx.In MetadataFields *prometheus.CounterVec `name:"metadata_fields"` TotalUnparsableCount *prometheus.CounterVec `name:"total_unparsable_count"` RebootUnparsableCount *prometheus.CounterVec `name:"reboot_unparsable_count"` EventErrorTags *prometheus.CounterVec `name:"event_errors"` BootCycleErrorTags *prometheus.CounterVec `name:"boot_cycle_errors"` RebootCycleErrorTags *prometheus.CounterVec `name:"reboot_cycle_errors"` BootToManageableHistogram prometheus.ObserverVec `name:"boot_to_manageable"` TimeElapsedHistograms map[string]prometheus.ObserverVec `name:"time_elapsed_histograms"` }
Measures tracks the various event-related metrics.
func (*Measures) AddMetadata ¶
AddMetadata adds to the metadata parser.
func (*Measures) AddRebootUnparsable ¶
func (m *Measures) AddRebootUnparsable(reason string, event interpreter.Event)
AddRebootUnparsable adds to the RebootUnparsable counter.
func (*Measures) AddTotalUnparsable ¶
AddTotalUnparsable adds to the total unparsable counter.
type MetadataParser ¶
type MetadataParser struct {
// contains filtered or unexported fields
}
MetadataParser parses messages coming in and counts the various metadata keys of each request.
func (*MetadataParser) Name ¶
func (m *MetadataParser) Name() string
Name returns the name of the parser. Implements the Parser interface.
func (*MetadataParser) Parse ¶
func (m *MetadataParser) Parse(event interpreter.Event)
Parse gathers metrics for each metadata key.
type ParserValidator ¶
type ParserValidator interface {
Validate(events []interpreter.Event, currentEvent interpreter.Event) (bool, error)
}
ParserValidator parses (if needed) the events from the list of events passed in and runs validation on this subset of events.
type RebootDurationParser ¶
type RebootDurationParser struct {
// contains filtered or unexported fields
}
RebootDurationParser is triggered whenever glaukos receives a fully-manageable event. Validates the event and the last boot-cycle, calculating the boot and reboot durations.
func (*RebootDurationParser) Name ¶
func (p *RebootDurationParser) Name() string
Name implements the Parser interface.
func (*RebootDurationParser) Parse ¶
func (p *RebootDurationParser) Parse(currentEvent interpreter.Event)
Parse takes an event, validates it, and calculates the time elapsed if everything is valid.
Steps: 1. HW & FW: Get the hardware and firmware values stored in the event's metadata to use as labels in Prometheus metrics. 2. Destination check: check that the incoming event is a fully-manageable event. 3. Basic checks: Check that the boot-time and device id exists. 4. Get events: Get history of events from codex, parse into slice with relevant events. 5. Parse and Validate: Go through parsers and parse and validate as needed. 6. Calculate time elapsed: Go through duration calculators to calculate durations and add to appropriate histograms.
type RebootLoggerIn ¶
type RebootParserConfig ¶
type RebootParserConfig struct { EventValidators []EventValidationConfig CycleValidators []CycleValidationConfig TimeElapsedCalculations []TimeElapsedConfig }
RebootParserConfig contains the information for which validators should be created.
type RebootParserIn ¶
type RebootParserIn struct { fx.In Name string `name:"reboot_parser_name"` Logger *zap.Logger `name:"reboot_parser_logger"` ParserValidators []ParserValidator `group:"reboot_parser_validators"` Calculators []DurationCalculator `group:"duration_calculators"` Measures Measures CodexClient *events.CodexClient }
type RebootParserNameIn ¶
type TimeElapsedConfig ¶
TimeElapsedConfig contains information for calculating the time between a fully-manageable event and another event.
type TimeLocation ¶
type TimeLocation int
TimeLocation is an enum to determine which timestamp should be used in timeElapsed calculations
const ( Birthdate TimeLocation = iota Boottime )
func ParseTimeLocation ¶
func ParseTimeLocation(location string) TimeLocation
ParseTimeLocation returns the TimeLocation enum when given a string.
type TimeValidationConfig ¶
TimeValidationConfig is the config used for time validation.
type ValidatorsIn ¶
type ValidatorsIn struct { fx.In EventValidator validation.Validator `name:"event_validator"` LastCycleValidator history.CycleValidator `name:"last_cycle_validator"` RebootCycleValidator history.CycleValidator `name:"reboot_cycle_validator"` }