assessment

package
v0.0.0-...-d38b3e6 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package assessment contains the core code that evaluates the agreements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssessActiveAgreements

func AssessActiveAgreements(cfg Config)

AssessActiveAgreements will get the active agreements from the provided repository and assess them, notifying about violations with the provided notifier. Mandatory fields filled in cfg are Repo, Adapter and Now.

func AssessAgreement

func AssessAgreement(a *model.Agreement, cfg Config) amodel.Result

AssessAgreement is the process that assess an agreement. The process is: 1. Check expiration date 2. Evaluate metrics if agreement is started 3. Set LastExecution time.

The output is:

  • parameter a is modified
  • evaluation results are the function return (violated metrics and raised violations). a guarantee term is filled in the result only if there are violations.

The function results are not persisted. The output must be persisted/handled accordingly. E.g.: agreement and violations must be persisted to DB. Violations must be notified to observers

func BuildRetrievalItems

func BuildRetrievalItems(a *model.Agreement,
	gt model.Guarantee,
	varnames []string,
	to time.Time) []monitor.RetrievalItem

BuildRetrievalItems returns the RetrievalItems to be passed to an EarlyRetriever.

func EvaluateAgreement

func EvaluateAgreement(a *model.Agreement, cfg Config) (amodel.Result, error)

EvaluateAgreement evaluates the guarantee terms of an agreement. The metric values are retrieved from a MonitoringAdapter. The MonitoringAdapter must feed the process correctly (e.g. if the constraint of a guarantee term is of the type "A>B && C>D", the MonitoringAdapter must supply pairs of values).

func EvaluateGtViolations

func EvaluateGtViolations(a *model.Agreement, gt model.Guarantee, violated amodel.GuaranteeData, transientTime time.Duration) []model.Violation

EvaluateGtViolations creates violations for the detected violated metrics in EvaluateGuarantee

func EvaluateGuarantee

func EvaluateGuarantee(a *model.Agreement,
	gt model.Guarantee,
	ma monitor.MonitoringAdapter,
	cfg Config) (
	failed []amodel.ExpressionData, last amodel.ExpressionData, err error)

EvaluateGuarantee evaluates a guarantee term of an Agreement (see EvaluateAgreement)

Returns the metrics that failed the GT constraint.

Types

type Config

type Config struct {
	// Now is the time considered the current time. In general terms, metrics are
	// retrieved from the adapter from the last measure to `now`.
	// If the monitoring have some delay storing metrics, now could be shifted some
	// minutes to the past.
	Now time.Time

	// Repo is the repository where to load/store entities
	Repo model.IRepository

	// Adapter is the monitoring adapter where to get metrics from
	Adapter monitor.MonitoringAdapter

	// Notifier receives the violations and notifies them (send by REST, store to DB...)
	Notifier notifier.ViolationNotifier

	// Transient is time to wait until a new violation of a GT can be raised again (default value is zero)
	Transient time.Duration
}

Config contains the configuration for an assessment process (i.e. global config)

Directories

Path Synopsis
Package model contains the model for the assessment process.
Package model contains the model for the assessment process.
Package monitor contains the interface for monitoring adapters.
Package monitor contains the interface for monitoring adapters.
dummyadapter
Package dummyadapter provides an example of MonitoringAdapter.
Package dummyadapter provides an example of MonitoringAdapter.
genericadapter
Package genericadapter provides a configurable MonitoringAdapter that works with advanced agreement schema.
Package genericadapter provides a configurable MonitoringAdapter that works with advanced agreement schema.
prometheus
Package prometheus provides a Retriever to get monitoring metrics from a Prometheus TSDB
Package prometheus provides a Retriever to get monitoring metrics from a Prometheus TSDB
prometheus/guarantees
Package guarantees contains a the monitorization of specific guarantees.
Package guarantees contains a the monitorization of specific guarantees.
simpleadapter
Package simpleadapter provides an example of MonitoringAdapter that returns the same data passed on construction
Package simpleadapter provides an example of MonitoringAdapter that returns the same data passed on construction
lognotifier
Package lognotifier contains a simple ViolationsNotifier that just logs violations.
Package lognotifier contains a simple ViolationsNotifier that just logs violations.
rabbitnotifier
Package rabbitpushgnotifier contains a simple ViolationsNotifier that send violations to a rabbit queue and also the queries to Prometheus needed to get all the information about the violation.
Package rabbitpushgnotifier contains a simple ViolationsNotifier that send violations to a rabbit queue and also the queries to Prometheus needed to get all the information about the violation.

Jump to

Keyboard shortcuts

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