util

package
v0.0.0-...-e03915a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLog

func InitLog(cfg TomlConfig)

InitLog init the logger

func InitProm

func InitProm()

InitProm register the Prometheus metrics

func OpenConnection

func OpenConnection(kafkaVersion string, clusterAddr []string, adminTimeout int) sarama.ClusterAdmin

OpenConnection to one of a given broker using supplied version

func PullConfigs

func PullConfigs(cfg TomlConfig, clusterName string, collector *Collector)

PullConfigs opens a connection to a given cluster, filter topics based on the config file and then run DescribeTopicConfig to populate the metrics

func RegisterMetrics

func RegisterMetrics(topicConfig []sarama.ConfigEntry, topicName string, c *Collector)

RegisterMetrics populate the metrics with a topic label

Types

type Collector

type Collector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Collector define all metrics as GaugeVec The "metrics" are configuration parameters so it's better to represent them as Gauge metrics.

func NewCollector

func NewCollector() *Collector

NewCollector for all metrics

func (*Collector) Collect

func (c *Collector) Collect(ch chan<- prometheus.Metric)

Collect implements Collector

func (*Collector) Describe

func (c *Collector) Describe(ch chan<- *prometheus.Desc)

Describe implements Collector

type TomlConfig

type TomlConfig struct {
	Global struct {
		Port    string `toml:"port"`
		Timeout int    `toml:"timeout"`
	} `toml:"global"`
	Log struct {
		Format string `toml:"format"`
		Level  string `toml:"level"`
	} `toml:"log"`
	Kafka struct {
		DefaultRefreshRate int    `toml:"default_refresh_rate"`
		MinKafkaVersion    string `toml:"min_kafka_version"`
		AdminTimeout       int    `toml:"admin_timeout"`
	} `toml:"kafka"`
	Clusters map[string]clusters
}

TomlConfig is the main config struct

var (
	// Configuration is main conig
	Configuration TomlConfig
)

Jump to

Keyboard shortcuts

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