cache

package
v0.0.0-...-d741a62 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertConfigCache

type AlertConfigCache interface {
	// GetAlertManagerMainConfigYamlByIP 根据IP地址获取AlertManager的主配置内容
	GetAlertManagerMainConfigYamlByIP(ip string) string
	// GenerateAlertManagerMainConfig 生成所有AlertManager主配置文件
	GenerateAlertManagerMainConfig(ctx context.Context) error
	// GenerateAlertManagerMainConfigOnePool 生成单个AlertManager池的主配置
	GenerateAlertManagerMainConfigOnePool(pool *model.MonitorAlertManagerPool) *altconfig.Config
	// GenerateAlertManagerRouteConfigOnePool 生成单个AlertManager池的routes和receivers配置
	GenerateAlertManagerRouteConfigOnePool(ctx context.Context, pool *model.MonitorAlertManagerPool) ([]*altconfig.Route, []altconfig.Receiver)
}

func NewAlertConfigCache

func NewAlertConfigCache(l *zap.Logger, alertPoolDao alertPoolDao.AlertManagerPoolDAO, alertSendDao alertPoolDao.AlertManagerSendDAO) AlertConfigCache

type MonitorCache

type MonitorCache interface {
	// MonitorCacheManager 更新缓存
	MonitorCacheManager(ctx context.Context) error
}

func NewMonitorCache

func NewMonitorCache(PrometheusMainConfig PromConfigCache, AlertMangerMainConfig AlertConfigCache, AlertRuleConfig RuleConfigCache, AlertRecordConfig RecordConfigCache, l *zap.Logger) MonitorCache

type PromConfigCache

type PromConfigCache interface {
	// GetPrometheusMainConfigByIP 根据IP地址获取Prometheus的主配置内容
	GetPrometheusMainConfigByIP(ip string) string
	// GeneratePrometheusMainConfig 生成所有Prometheus主配置文件
	GeneratePrometheusMainConfig(ctx context.Context) error
	// CreateBasePrometheusConfig 创建基础Prometheus配置
	CreateBasePrometheusConfig(pool *model.MonitorScrapePool) (pc.Config, error)
	// GenerateScrapeConfigs 生成采集配置
	GenerateScrapeConfigs(ctx context.Context, pool *model.MonitorScrapePool) []*pc.ScrapeConfig
	// ApplyHashMod 应用HashMod和Keep Relabel配置进行分片
	ApplyHashMod(scrapeConfigs []*pc.ScrapeConfig, modNum, index int) []*pc.ScrapeConfig
}

func NewPromConfigCache

func NewPromConfigCache(l *zap.Logger, scrapePoolDao scrapeJobDao.ScrapePoolDAO, scrapeJobDao scrapeJobDao.ScrapeJobDAO) PromConfigCache

type RecordConfigCache

type RecordConfigCache interface {
	// GetPrometheusRecordRuleConfigYamlByIp 根据IP地址获取Prometheus的预聚合规则配置YAML
	GetPrometheusRecordRuleConfigYamlByIp(ip string) string
	// GenerateRecordRuleConfigYaml 生成并更新所有Prometheus的预聚合规则配置YAML
	GenerateRecordRuleConfigYaml(ctx context.Context) error
	// GeneratePrometheusRecordRuleConfigYamlOnePool 根据单个采集池生成Prometheus的预聚合规则配置YAML
	GeneratePrometheusRecordRuleConfigYamlOnePool(ctx context.Context, pool *model.MonitorScrapePool) map[string]string
}

func NewRecordConfig

func NewRecordConfig(l *zap.Logger, scrapePoolDao scrapePoolDao.ScrapePoolDAO, alertRecordDao alertRecordDao.AlertManagerRecordDAO) RecordConfigCache

type RecordGroup

type RecordGroup struct {
	Name  string         `yaml:"name"`
	Rules []rulefmt.Rule `yaml:"rules"`
}

RecordGroup 构造Prometheus record 结构体

type RecordGroups

type RecordGroups struct {
	Groups []RecordGroup `yaml:"groups"`
}

RecordGroups 生成Prometheus record yaml

type RuleConfigCache

type RuleConfigCache interface {
	// GetPrometheusAlertRuleConfigYamlByIp 根据IP地址获取Prometheus的告警规则配置YAML
	GetPrometheusAlertRuleConfigYamlByIp(ip string) string
	// GenerateAlertRuleConfigYaml 生成并更新所有Prometheus的告警规则配置YAML
	GenerateAlertRuleConfigYaml(ctx context.Context) error
	// GeneratePrometheusAlertRuleConfigYamlOnePool 根据单个采集池生成Prometheus的告警规则配置YAML
	GeneratePrometheusAlertRuleConfigYamlOnePool(ctx context.Context, pool *model.MonitorScrapePool) map[string]string
}

func NewRuleConfigCache

func NewRuleConfigCache(l *zap.Logger, scrapePoolDao scrapePoolDao.ScrapePoolDAO, alertRuleDao alertRuleDao.AlertManagerRuleDAO) RuleConfigCache

type RuleGroup

type RuleGroup struct {
	Name  string         `yaml:"name"`
	Rules []rulefmt.Rule `yaml:"rules"`
}

RuleGroup 构造Prometheus Rule 规则的结构体

type RuleGroups

type RuleGroups struct {
	Groups []RuleGroup `yaml:"groups"`
}

RuleGroups 生成Prometheus rule yaml

Jump to

Keyboard shortcuts

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