Help us shape the future of Go! Take the 2026 Go Developer Survey

file

package
v0.305.4 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 20 Imported by: 311

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultSDConfig is the default file SD configuration.
	DefaultSDConfig = SDConfig{
		RefreshInterval: model.Duration(5 * time.Minute),
	}
)

Functions

This section is empty.

Types

type Discovery

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

Discovery provides service discovery functionality based on files that contain target groups in JSON or YAML format. Refreshing happens using file watches and periodic refreshes.

func NewDiscovery

func NewDiscovery(conf *SDConfig, logger *slog.Logger, metrics discovery.DiscovererMetrics) (*Discovery, error)

NewDiscovery returns a new file discovery for the given paths.

func (*Discovery) Run

func (d *Discovery) Run(ctx context.Context, ch chan<- []*targetgroup.Group)

Run implements the Discoverer interface.

type SDConfig

type SDConfig struct {
	Files           []string       `yaml:"files"`
	RefreshInterval model.Duration `yaml:"refresh_interval,omitempty"`
}

SDConfig is the configuration for file based discovery.

func (*SDConfig) Name

func (*SDConfig) Name() string

Name returns the name of the Config.

func (*SDConfig) NewDiscoverer

func (c *SDConfig) NewDiscoverer(opts discovery.DiscovererOptions) (discovery.Discoverer, error)

NewDiscoverer returns a Discoverer for the Config.

func (*SDConfig) NewDiscovererMetrics added in v0.50.0

NewDiscovererMetrics implements discovery.Config.

func (*SDConfig) SetDirectory

func (c *SDConfig) SetDirectory(dir string)

SetDirectory joins any relative file paths with dir.

func (*SDConfig) UnmarshalYAML

func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type TimestampCollector

type TimestampCollector struct {
	Description *prometheus.Desc
	// contains filtered or unexported fields
}

TimestampCollector is a Custom Collector for Timestamps of the files. TODO(ptodev): Now that each file SD has its own TimestampCollector inside discovery/file/metrics.go, we can refactor this collector (or get rid of it) as each TimestampCollector instance will only use one discoverer.

func NewTimestampCollector

func NewTimestampCollector() *TimestampCollector

NewTimestampCollector creates a TimestampCollector.

func (*TimestampCollector) Collect

func (t *TimestampCollector) Collect(ch chan<- prometheus.Metric)

Collect creates constant metrics for each file with last modified time of the file.

func (*TimestampCollector) Describe

func (t *TimestampCollector) Describe(ch chan<- *prometheus.Desc)

Describe method sends the description to the channel.

Jump to

Keyboard shortcuts

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