monitoring

package
v4.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 40 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  = 100
)
View Source
const (
	DefaultSuppressionCountThreshold = 3
	DisableAlertLogging              = "disable-alert-logging"

	SuppressionCountThresholdFlagName = "suppression-alert-count-threshold"

	AllProvidersFlagName    = "all-providers"
	AllProvidersMarker      = "all"
	ConsumerGrpcTLSFlagName = "consumer-grpc-tls"
)

Variables

View Source
var QueryRetries = uint64(3)

Functions

func CheckConsumersAndReferences

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

func CheckProviders

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

func CreateChainHeightsCommand added in v4.1.0

func CreateChainHeightsCommand() *cobra.Command

func CreateHealthCobraCommand

func CreateHealthCobraCommand() *cobra.Command

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[string, any]
	// 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 HealthPolicy

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

func (*HealthPolicy) GetSupportedAddons

func (pp *HealthPolicy) GetSupportedAddons(specID string) (addons []string, err error)

func (*HealthPolicy) GetSupportedExtensions

func (pp *HealthPolicy) GetSupportedExtensions(specID string) (extensions []epochstoragetypes.EndpointService, err error)

type HealthRPCEndpoint

type HealthRPCEndpoint struct {
	NetworkAddress string   `yaml:"network-address,omitempty" json:"network-address,omitempty" mapstructure:"network-address"` // HOST:PORT
	ChainID        string   `yaml:"chain-id,omitempty" json:"chain-id,omitempty" mapstructure:"chain-id"`                      // spec chain identifier
	ApiInterface   string   `yaml:"api-interface,omitempty" json:"api-interface,omitempty" mapstructure:"api-interface"`
	Geolocation    uint64   `yaml:"geolocation,omitempty" json:"geolocation,omitempty" mapstructure:"geolocation"`
	Addons         []string `yaml:"addons,omitempty" json:"addons,omitempty" mapstructure:"addons"`
}

func ParseEndpoints

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

func (*HealthRPCEndpoint) String

func (endpoint *HealthRPCEndpoint) String() string

type HealthResults

type HealthResults struct {
	LatestBlocks       map[string]int64            `json:"latestBlocks,omitempty"`
	ConsumerBlocks     map[LavaEntity]int64        `json:"consumerBlocks,omitempty"`
	ProviderData       map[LavaEntity]ReplyData    `json:"providerData,omitempty"`
	SubscriptionsData  map[string]SubscriptionData `json:"subscriptionsData,omitempty"`
	FrozenProviders    map[LavaEntity]struct{}     `json:"frozenProviders,omitempty"`
	UnhealthyProviders map[LavaEntity]string       `json:"unhealthyProviders,omitempty"`
	UnhealthyConsumers map[LavaEntity]string       `json:"unhealthyConsumers,omitempty"`
	Specs              map[string]*spectypes.Spec  `json:"specs,omitempty"`
	Lock               sync.RWMutex                `json:"-"`
}

func RunHealth

func RunHealth(ctx context.Context,
	clientCtx client.Context,
	subscriptionAddresses []string,
	providerAddresses []string,
	consumerEndpoints []*HealthRPCEndpoint,
	referenceEndpoints []*HealthRPCEndpoint,
	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 `json:"address"`
	SpecId       string `json:"specId"`
	ApiInterface string `json:"apiInterface"`
}

func (*LavaEntity) MarshalJSON

func (le *LavaEntity) MarshalJSON() ([]byte, error)

func (LavaEntity) MarshalText

func (le LavaEntity) MarshalText() ([]byte, error)

func (*LavaEntity) String

func (e *LavaEntity) String() string

type ReplyData

type ReplyData struct {
	Block   int64         `json:"block"`
	Latency time.Duration `json:"latency"`
}

type SubscriptionData

type SubscriptionData struct {
	FullMonthsLeft               uint64        `json:"fullMonthsLeft"`
	UsagePercentageLeftThisMonth float64       `json:"usagePercentageLeftThisMonth"`
	DurationLeft                 time.Duration `json:"durationLeft"`
}

Jump to

Keyboard shortcuts

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