monitoring

package
v0.32.3 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheMaxCost               = 10 * 1024 // 10K cost
	CacheNumCounters           = 100000    // expect 10K items
	OKString                   = "OK"
	FrozenProviderAttribute    = "frozen_provider_alert"
	SubscriptionAlertAttribute = "subscription_limit_alert"
	UnhealthyProviderAttribute = "unhealthy_provider_alert"
	UnhealthyConsumerAttribute = "unhealthy_consumer_alert"
	ProviderBlockGapAttribute  = "provider_block_gap_alert"
	ConsumerBlockGapAttribute  = "consumer_block_gap_alert"
	ProviderLatencyAttribute   = "provider_latency_alert"

	UsagePercentageAlert = "percentage of cu too low"
	LeftTimeAlert        = "left subscription time is too low"
	MonthDuration        = 30 * 24 * time.Hour
)
View Source
const (
	BasicQueryRetries = 3
	QuerySleepTime    = 100 * time.Millisecond
	NiceOutputLength  = 40
)
View Source
const (
	DefaultSuppressionCountThreshold = 3
	DisableAlertLogging              = "disable-alert-logging"

	SuppressionCountThresholdFlagName = "suppression-alert-count-threshold"
)

Variables

View Source
var QueryRetries = uint64(3)

Functions

func CheckConsumersAndReferences

func CheckConsumersAndReferences(ctx context.Context,
	clientCtx client.Context,
	referenceEndpoints []*lavasession.RPCEndpoint,
	consumerEndpoints []*lavasession.RPCEndpoint,
	healthResults *HealthResults,
) error

func CheckProviders

func CheckProviders(ctx context.Context, clientCtx client.Context, healthResults *HealthResults, providerEntries map[LavaEntity]epochstoragetypes.StakeEntry) error

func CreateHealthCobraCommand

func CreateHealthCobraCommand() *cobra.Command

func ParseEndpoints

func ParseEndpoints(keyName string, viper_endpoints *viper.Viper) (endpoints []*lavasession.RPCEndpoint, err error)

Types

type AlertAttribute

type AlertAttribute struct {
	// contains filtered or unexported fields
}

type AlertCount

type AlertCount struct {
	// contains filtered or unexported fields
}

type AlertEntry

type AlertEntry struct {
	// contains filtered or unexported fields
}

type Alerting

type Alerting struct {
	AlertsCache *ristretto.Cache
	// contains filtered or unexported fields
}

func NewAlerting

func NewAlerting(options AlertingOptions) *Alerting

func (*Alerting) ActiveAlerts

func (al *Alerting) ActiveAlerts() (alerts uint64, unhealthy uint64, healthy uint64)

func (*Alerting) AppendUrlAlert

func (al *Alerting) AppendUrlAlert(alert string, attrs []utils.Attribute)

func (*Alerting) CheckHealthResults

func (al *Alerting) CheckHealthResults(healthResults *HealthResults)

func (*Alerting) CheckSubscriptionData

func (al *Alerting) CheckSubscriptionData(subs map[string]SubscriptionData)

func (*Alerting) ConsumerAlerts

func (al *Alerting) ConsumerAlerts(healthResults *HealthResults)

func (*Alerting) FilterOccurenceSuppresedAlerts

func (al *Alerting) FilterOccurenceSuppresedAlerts(alert string, attributes []AlertAttribute) (filteredAttributes []AlertAttribute)

func (*Alerting) FilterTimeSuppresedAlerts

func (al *Alerting) FilterTimeSuppresedAlerts(attributes []AlertAttribute, alert string) []utils.Attribute

func (*Alerting) ProvidersAlerts

func (al *Alerting) ProvidersAlerts(healthResults *HealthResults)

func (*Alerting) SendAlert

func (al *Alerting) SendAlert(alert string, attributes []AlertAttribute)

func (al *Alerting) SendAlert(alert string, attrs []utils.Attribute) {

func (*Alerting) SendAppendedAlerts

func (al *Alerting) SendAppendedAlerts() error

func (*Alerting) SendFrozenProviders

func (al *Alerting) SendFrozenProviders(frozenProviders map[LavaEntity]struct{})

func (*Alerting) SendRecoveryAlerts

func (al *Alerting) SendRecoveryAlerts(alertEntries []AlertEntry)

func (*Alerting) ShouldAlertSubscription

func (al *Alerting) ShouldAlertSubscription(data SubscriptionData) (reason string, alert bool)

func (*Alerting) UnhealthyProviders

func (al *Alerting) UnhealthyProviders(unhealthy map[LavaEntity]string)

type AlertingOptions

type AlertingOptions struct {
	Url                           string // where to send the alerts
	Logging                       bool   // wether to log alerts to stdout
	Identifier                    string // a unique identifier added to all alerts
	SubscriptionCUPercentageAlert float64
	SubscriptionLeftTimeAlert     time.Duration
	AllowedTimeGapVsReference     time.Duration
	MaxProviderLatency            time.Duration
	SameAlertInterval             time.Duration
	DisableAlertSuppression       bool
	SuppressionCounterThreshold   uint64
}

type HealthResults

type HealthResults struct {
	LatestBlocks       map[string]int64
	ProviderData       map[LavaEntity]ReplyData
	ConsumerBlocks     map[LavaEntity]int64
	SubscriptionsData  map[string]SubscriptionData
	FrozenProviders    map[LavaEntity]struct{}
	UnhealthyProviders map[LavaEntity]string
	UnhealthyConsumers map[LavaEntity]string
	Specs              map[string]*spectypes.Spec
	Lock               sync.RWMutex
}

func RunHealth

func RunHealth(ctx context.Context,
	clientCtx client.Context,
	subscriptionAddresses []string,
	providerAddresses []string,
	consumerEndpoints []*lavasession.RPCEndpoint,
	referenceEndpoints []*lavasession.RPCEndpoint,
	prometheusListenAddr string,
) (*HealthResults, error)

func (*HealthResults) FormatForLatestBlock

func (healthResults *HealthResults) FormatForLatestBlock() map[string]uint64

func (*HealthResults) FreezeProvider

func (healthResults *HealthResults) FreezeProvider(providerKey LavaEntity)

func (*HealthResults) GetAllEntities

func (healthResults *HealthResults) GetAllEntities() map[LavaEntity]struct{}

func (*HealthResults) SetProviderData

func (healthResults *HealthResults) SetProviderData(providerKey LavaEntity, latestData ReplyData)

func (*HealthResults) SetUnhealthyProvider

func (healthResults *HealthResults) SetUnhealthyProvider(providerKey LavaEntity, errMsg string)

type LavaEntity

type LavaEntity struct {
	Address      string
	SpecId       string
	ApiInterface string
}

func (*LavaEntity) String

func (e *LavaEntity) String() string

type ReplyData

type ReplyData struct {
	// contains filtered or unexported fields
}

type SubscriptionData

type SubscriptionData struct {
	FullMonthsLeft               uint64
	UsagePercentageLeftThisMonth float64
	DurationLeft                 time.Duration
}

Jump to

Keyboard shortcuts

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