prom2cloudwatch

package module
v0.0.0-...-4c4303d Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

README

prom2cloudwatch

Godoc

WIP. Package prom2cloudwatch provides a bridge to push Prometheus metrics to AWS CloudWatch.

This is based on the Graphite bridge provided by prometheus/client_golang

Documentation

Overview

Package prom2cloudwatch provides a bridge to push Prometheus metrics to AWS CloudWatch

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

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

Bridge pushes metrics to AWS Cloudwatch

func NewBridge

func NewBridge(c *Config) (*Bridge, error)

NewBridge initializes and returns a pointer to a Bridge using the supplied configuration, or an error if there is a problem with the configuration

func (*Bridge) Publish

func (b *Bridge) Publish() error

Publish publishes the Prometheus metrics to Cloudwatch

func (*Bridge) Run

func (b *Bridge) Run(ctx context.Context)

Run starts a loop that will push metrics to Cloudwatch at the configured interval. Run accepts a context.Context to support cancellation.

type Config

type Config struct {
	// Required. The Prometheus namespace/prefix to scrape. Each Bridge only supports 1 prefix.
	// If multiple prefixes are required, multiple Bridges must be used.
	PrometheusNamespace string

	// Required. The CloudWatch namespace under which metrics should be published
	CloudWatchNamespace string

	// Required. The AWS Region to use
	CloudWatchRegion string

	// The frequency with which metrics should be published to Cloudwatch. Default: 15s
	Interval time.Duration

	// Timeout for sending metrics to Cloudwatch. Default: 1s
	Timeout time.Duration

	// Custom HTTP Client to use with the Cloudwatch API. Default: http.Client{}
	// If Config.Timeout is supplied, it will override any timeout defined on
	// the supplied http.Client
	Client *http.Client

	// Logger that messages are written to. Default: nil
	Logger Logger

	// The Gatherer to use for metrics. Default: prometheus.DefaultGatherer
	Gatherer prometheus.Gatherer

	// Only publish whitelisted metrics
	WhitelistOnly bool

	// List of metrics that should be published, causing all others to be ignored.
	// Config.WhitelistOnly must be set to true for this to take effect.
	Whitelist []string

	// List of metrics that should never be published. This setting overrides entries in Config.Whitelist
	Blacklist []string
}

Config defines configuration options for Bridge

type Logger

type Logger interface {
	Println(v ...interface{})
}

Logger is the minimal interface Bridge needs for logging. Note that log.Logger from the standard library implements this interface, and it is easy to implement by custom loggers, if they don't do so already anyway. Taken from https://github.com/prometheus/client_golang/blob/master/prometheus/graphite/bridge.go

Jump to

Keyboard shortcuts

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