endpoints

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package endpoints ... Copyright 2019 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Package endpoints ... Copyright 2019 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Package endpoints ... Copyright 2019 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Package endpoints ... Copyright 2019 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Package endpoints ... Copyright 2019 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	NodeLegacyHostIP = "LegacyHostIP"
)

COPIED FROM Prometheus code

Variables

This section is empty.

Functions

This section is empty.

Types

type KubernetesTargetRetriever

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

KubernetesTargetRetriever sets the watchers for the different Targets and listens for the arrival of new data from them.

func NewKubernetesTargetRetriever

func NewKubernetesTargetRetriever(scrapeEnabledLabel string, requireScrapeEnabledLabelForNodes bool, options ...Option) (*KubernetesTargetRetriever, error)

NewKubernetesTargetRetriever creates a new KubernetesTargetRetriever setting the required label to identified targets that can be scrapped.

func (*KubernetesTargetRetriever) GetTargets

func (k *KubernetesTargetRetriever) GetTargets() ([]Target, error)

GetTargets returns a slice with all the targets currently registered.

func (*KubernetesTargetRetriever) Name

Name returns the identifying name of the KubernetesTargetRetriever.

func (*KubernetesTargetRetriever) Watch

func (k *KubernetesTargetRetriever) Watch() error

Watch retrieves and caches an initial list of URLs and triggers a process in background

type Object

type Object struct {
	Name   string
	Kind   string
	Labels labels.Set
}

Object represents a kubernetes object like a pod or a service.

type Option

type Option func(*KubernetesTargetRetriever) error

Option is implemented by functions that configure the KubernetesTargetRetriever

func WithInClusterConfig

func WithInClusterConfig() Option

WithInClusterConfig configures the KubernetesTargetRetriever to load the Kubernetes configuration from within a running pod in the cluster (/var/run/secrets/kubernetes.io/serviceaccount/*)

func WithKubeConfig

func WithKubeConfig(kubeConfigFile string) Option

WithKubeConfig configures the KubernetesTargetRetriever to load the Kubernetes configuration from a kubeconfig file. This file is usually found in ~/.kube/config

type TLSConfig

type TLSConfig struct {
	CaFilePath         string `mapstructure:"ca_file_path"`
	CertFilePath       string `mapstructure:"cert_file_path"`
	KeyFilePath        string `mapstructure:"key_file_path"`
	InsecureSkipVerify bool   `mapstructure:"insecure_skip_verify"`
}

TLSConfig is used to store all the configuration required to use Mutual TLS authentication.

type Target

type Target struct {
	Name   string
	Object Object
	URL    url.URL

	TLSConfig TLSConfig
	// contains filtered or unexported fields
}

Target is a prometheus endpoint which is exposed by an Object.

func EndpointToTarget

func EndpointToTarget(tc TargetConfig) ([]Target, error)

EndpointToTarget returns a list of Targets from the provided TargetConfig struct. The URL processing for every Target follows the next conventions: - if no schema is provided, it assumes http - if no path is provided, it assumes /metrics For example, hostname:8080 will be interpreted as http://hostname:8080/metrics

func New

func New(name string, addr url.URL, object Object) Target

New returns a Target from the discovered information

func (*Target) Metadata

func (t *Target) Metadata() labels.Set

Metadata returns the Target's metadata, if the current metadata is nil, it's constructed from the Target's attributes, saved and returned. Subsequent calls will returned the already saved value.

type TargetConfig

type TargetConfig struct {
	Description string
	URLs        []string  `mapstructure:"urls"`
	TLSConfig   TLSConfig `mapstructure:"tls_config"`
}

TargetConfig is used to parse endpoints from the configuration file.

type TargetRetriever

type TargetRetriever interface {
	GetTargets() ([]Target, error)
	Watch() error
	Name() string
}

TargetRetriever is implemented by any type that can return the URL of a set of Prometheus metrics providers

func FixedRetriever

func FixedRetriever(targetCfgs ...TargetConfig) (TargetRetriever, error)

FixedRetriever creates a TargetRetriver that returns the targets belonging to the URLs passed as arguments

func SelfRetriever

func SelfRetriever() (TargetRetriever, error)

SelfRetriever creates a TargetRetriver that returns the targets belonging to nri-prometheus.

Jump to

Keyboard shortcuts

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