target

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package target provides types for managing sources of applications that can be scraped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsulSource added in v0.8.0

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

The ConsulSource type is used to source scrapable targets from a HashiCorp Consul instance.

func NewConsulSource added in v0.8.0

func NewConsulSource(client *api.Client, app string) *ConsulSource

NewConsulSource returns a new instance of the ConsulSource type that will source targets using the provided Consul client. It will search for services tagged with the provided app name.

func (*ConsulSource) Check added in v0.9.0

func (cs *ConsulSource) Check(ctx context.Context) error

Check attempts to list services within consul. This method is used to implement the operation.Check interface for use in health checks.

func (*ConsulSource) List added in v0.8.0

func (cs *ConsulSource) List(ctx context.Context) ([]Target, error)

List all targets within the Consul catalogue matching the application. This method will use the service catalogue to find services that have two main tags: autopgo.scrape=true and autopgo.scrape.app=app. The latter tag should use the configured application name as the tag value. A custom path & scheme can be set using the autopgo.scrape.path and autopgo.scrape.scheme tags.

func (*ConsulSource) Name added in v0.9.0

func (cs *ConsulSource) Name() string

Name returns "consul". This method is used to implement the operation.Check interface for use in health checks.

type FileSource

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

The FileSource type describes a source of targets loaded from a JSON file.

func NewFileSource

func NewFileSource(ctx context.Context, location string) (*FileSource, error)

NewFileSource returns a new instance of the FileSource type that loads Target data from the JSON file specified at the given location. The file is expected to contain a JSON-encoded array of the Target type. The FileSource type will also listen for SIGHUP signals and reread the JSON file and update its list of targets.

func (*FileSource) Check added in v0.9.0

func (fs *FileSource) Check(_ context.Context) error

Check performs os.Stat on the desired config file. This method is used to implement the operation.Checker interface for use in health checks.

func (*FileSource) List

func (fs *FileSource) List(_ context.Context) ([]Target, error)

List all targets within the file.

func (*FileSource) Name added in v0.9.0

func (fs *FileSource) Name() string

Name returns "file://<config location>". This method is used to implement the operation.Checker interface for use in health checks.

type KubernetesSource

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

The KubernetesSource type is used to list scrapable targets from a Kubernetes cluster.

func NewKubernetesSource

func NewKubernetesSource(client kubernetes.Interface, app string) (*KubernetesSource, error)

NewKubernetesSource returns a new instance of the KubernetesSource type that can list scrapable targets contained within a Kubernetes cluster. The app parameter determines which pods are scraped based on their autopgo.app label.

func (*KubernetesSource) Check added in v0.9.0

func (ks *KubernetesSource) Check(ctx context.Context) error

Check attempts to list pods within kubernetes. This method is used to implement the operation.Checker interface for use in health checks.

func (*KubernetesSource) List

func (ks *KubernetesSource) List(ctx context.Context) ([]Target, error)

List all scrapable targets within the Kubernetes cluster. This functions by listing all pods that have the label autopgo.scrape set to true and the autopgo.app label matching that of the scraper. The pod IP will be used as the Target.Address field and an optional pprof path can be provided by setting the autopgo.path label on the pod.

func (*KubernetesSource) Name added in v0.9.0

func (ks *KubernetesSource) Name() string

Name returns "kubernetes". This method is used to implement the operation.Check interface for use in health checks.

type NomadSource added in v0.8.0

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

The NomadSource type is used to source scrapable targets from a HashiCorp Nomad cluster using its services API.

func NewNomadSource added in v0.8.0

func NewNomadSource(client *api.Client, app string) *NomadSource

NewNomadSource returns a new instance of the NomadSource type that will source targets using the provided Nomad client. It will search for services tagged with the provided app name.

func (*NomadSource) Check added in v0.9.0

func (ns *NomadSource) Check(ctx context.Context) error

Check attempts to list services in nomad. This method is used to implement the operation.Checker interface for use in health checks.

func (*NomadSource) List added in v0.8.0

func (ns *NomadSource) List(ctx context.Context) ([]Target, error)

List all targets within the Nomad cluster matching the application. This method will use the Nomad services API to find services that have two main tags: autopgo.scrape=true and autopgo.scrape.app=app. The latter tag should use the configured application name as the tag value. A custom path & scheme can be set using the autopgo.scrape.path and autopgo.scrape.scheme tags.

func (*NomadSource) Name added in v0.9.0

func (ns *NomadSource) Name() string

Name returns "nomad". This method is used to implement the operation.Checker interface for use in health checks.

type Source added in v0.9.0

type Source interface {
	operation.Checker

	// List should return all targets that can be scraped.
	List(ctx context.Context) ([]Target, error)
}

The Source interface describes types that can query scrapable targets from some system that stores them.

type Target

type Target struct {
	// The target address, should include scheme, host & port.
	Address string `json:"address"`
	// The path to the pprof profile endpoint, including leading slash. Defaults to /debug/pprof/profile if
	// unset.
	Path string `json:"path"`
}

The Target type describes individual instances of an application that can be scraped.

Jump to

Keyboard shortcuts

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