internal

package
v0.0.0-...-1310b52 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTLSConfig

func BuildTLSConfig(clientCert, clientKey, serverRootCACert, serverName string, insecureSkipVerify bool) (*tls.Config, error)

func SamplesToString

func SamplesToString(queriedMetrics map[string][]*model.Sample) string

SamplesToString turns our queried metrics map into something compatible with the Prometheus exposition format

Types

type APIClient

type APIClient struct {
	promapi.API
}

func NewAPIClient

func NewAPIClient(cfg APIConfig) (*APIClient, error)

func (*APIClient) ListMetrics

func (c *APIClient) ListMetrics(metricPrefix string) ([]string, []string, []string, error)

func (*APIClient) QueryMetricsInstant

func (c *APIClient) QueryMetricsInstant(promql string) (model.Vector, error)

type APIConfig

type APIConfig struct {
	TargetHost         string
	ServerRootCACert   string
	ClientCert         string
	ClientKey          string
	ServerName         string
	InsecureSkipVerify bool
}

type ByMetricName

type ByMetricName []Metric

ByMetricName lets us sort metrics

func (ByMetricName) Len

func (m ByMetricName) Len() int

func (ByMetricName) Less

func (m ByMetricName) Less(i, j int) bool

func (ByMetricName) Swap

func (m ByMetricName) Swap(i, j int)

type Config

type Config struct {
	Metrics []Metric
}

func LoadConfig

func LoadConfig(filename string) (*Config, error)

type Data

type Data map[string][]*model.Sample

func QueryMetrics

func QueryMetrics(conf *Config, client *APIClient) (Data, error)

type HttpClient

type HttpClient struct {
	Endpoint *url.URL
	Client   *http.Client
}

func NewHttpClient

func NewHttpClient(addr string, httpClient *http.Client) (*HttpClient, error)

func (*HttpClient) Do

func (c *HttpClient) Do(ctx context.Context, req *http.Request) (*http.Response, []byte, error)

func (*HttpClient) URL

func (c *HttpClient) URL(ep string, args map[string]string) *url.URL

type Metric

type Metric struct {
	MetricName string `yaml:"metric_name"`
	Query      string `yaml:"query"`
}

type PromToScrapeServer

type PromToScrapeServer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewPromToScrapeServer

func NewPromToScrapeServer(client *APIClient, conf *Config, addr string) *PromToScrapeServer

func (*PromToScrapeServer) Start

func (s *PromToScrapeServer) Start() error

Start runs the embedded http.Server.

type Querier

type Querier interface {
	ListMetrics(metricPrefix string) ([]string, []string, []string, error)
	QueryMetricsInstant(promql string) (model.Matrix, error)
}

Jump to

Keyboard shortcuts

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