collectors

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GrafanaCollector

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

GrafanaCollector handles the collection of alerts from Grafana.

func NewGrafanaCollector

func NewGrafanaCollector(cfg *GrafanaCollectorConfig) *GrafanaCollector

NewGrafanaCollector initializes a new GrafanaCollector instance.

func (*GrafanaCollector) Run

func (gc *GrafanaCollector) Run(ctx context.Context, dataCh chan<- service.CollectorData)

Run starts the process of collecting alerts from Grafana.

type GrafanaCollectorConfig

type GrafanaCollectorConfig struct {
	IsActive                bool          `validate:"-"`                                           // Whether the Grafana collector is active
	APIUrl                  string        `validate:"required_with=IsActive|url"`                  // API URL for Grafana
	Token                   string        `validate:"required_with=IsActive"`                      // Token for Grafana API
	IncludePrometheusAlerts bool          `validate:"-"`                                           // Whether to include Prometheus alerts
	PrometheusUIDs          []string      `validate:"required_with=IncludePrometheusAlerts|min=1"` // Prometheus UIDs
	CollectInterval         time.Duration `validate:"required_with=IsActive|min=5s"`               // Collection interval duration
	RequestTimeout          time.Duration `validate:"required_with=IsActive|min=1s,max=5s"`        // Timeout for Grafana requests
}

GrafanaCollectorConfig represents the configuration for the Grafana collector

func (*GrafanaCollectorConfig) Validate

func (gcc *GrafanaCollectorConfig) Validate() error

Validate checks if the GrafanaCollectorConfig struct is valid according to the rules defined in struct tags. It ensures that when the collector is active, required fields such as APIUrl, Token, and others are present and have valid values (e.g., URL format, PrometheusUIDs length).

type ZabbixCollector

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

ZabbixCollector handles the collection of alerts from Zabbix.

func NewZabbixCollector

func NewZabbixCollector(cfg *ZabbixCollectorConfig) *ZabbixCollector

NewZabbixCollector initializes a new ZabbixCollector instance.

func (*ZabbixCollector) Run

func (zc *ZabbixCollector) Run(ctx context.Context, dataCh chan<- service.CollectorData)

Run starts the process of collecting alerts from Zabbix.

type ZabbixCollectorConfig

type ZabbixCollectorConfig struct {
	IsActive        bool          `validate:"-"`                                    // Whether the Zabbix collector is active
	APIUrl          string        `validate:"required_with=IsActive|url"`           // API URL for Zabbix
	Token           string        `validate:"required_with=IsActive"`               // Token for Zabbix API
	CollectInterval time.Duration `validate:"required_with=IsActive|min=5s"`        // Collection interval duration
	RequestTimeout  time.Duration `validate:"required_with=IsActive|min=1s,max=5s"` // Timeout for Zabbix requests
}

ZabbixCollectorConfig represents the configuration for the Zabbix collector

func (*ZabbixCollectorConfig) Validate

func (zcc *ZabbixCollectorConfig) Validate() error

Validate checks if the ZabbixCollectorConfig struct is valid according to the rules defined in struct tags. It ensures that when the collector is active, fields such as APIUrl and Token are present, and the RequestTimeout and CollectInterval values conform to the specified constraints.

Jump to

Keyboard shortcuts

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