prometheus

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: Apache-2.0, Apache-2.0 Imports: 18 Imported by: 0

README

Metrics

This module enables prometheus metrics for Caddy.

Use

In your Caddyfile:

prometheus

For each virtual host that you want to see metrics for.

These are the (optional) parameters that can be used:

  • use_caddy_addr - causes metrics to be exposed at the same address:port as Caddy itself. This can not be specified at the same time as address.
  • address - the address where the metrics are exposed, the default is localhost:9180
  • path - the path to serve collected metrics from, the default is /metrics
  • hostname - the host parameter that can be found in the exported metrics, this defaults to the label specified for the server block

With caddyext you'll need to put this module early in the chain, so that the duration histogram actually makes sense. I've put it at number 0.

Metrics

The following metrics are exported:

  • caddy_http_request_count_total{host, family, proto}
  • caddy_http_request_duration_seconds{host, family, proto}
  • caddy_http_response_latency_seconds{host, family, proto, status}
  • caddy_http_response_size_bytes{host, family, proto, status}
  • caddy_http_response_status_count_total{host, family, proto, status}

Each metric has the following labels:

  • host which is the hostname used for the request/response,
  • family which is the protocol family, either 1 (IP version 4) or 2 (IP version 6),
  • proto which is the HTTP protocol major and minor version used: 1.x or 2 signifying HTTP/1.x or HTTP/2.

The response_* metrics have an extra label status which holds the status code.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACL

type ACL struct {
	CannedAcl string `json:"CannedAcl"`
}

type Bucket

type Bucket struct {
	Name       string `json:"Name"`
	CreateTime string `json:"CreateTime"`
	OwnerId    string `json:"OwnerId"`
	CORS       CORS   `json:"CORS"`
	ACL        ACL    `json:"ACL"`
	LC         LC     `json:"LC"`
	Policy     Policy `json:"Policy"`
	Versioning string `json:"Versioning"`
	Usage      string `json:"Usage"`
}

type CORS

type CORS struct {
	CorsRules string `json:"CorsRules"`
}

type Cache

type Cache interface {
	Put(key interface{}, value interface{}, lifeTime time.Duration) error
	Get(key interface{}) interface{}
}

type Item

type Item struct {
	Value interface{}
	// contains filtered or unexported fields
}

type LC

type LC struct {
	XMLName XMLName `json:"XMLName"`
	Rule    string  `json:"Rule"`
}

type MemoryCache

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

func (*MemoryCache) Get

func (mc *MemoryCache) Get(key interface{}) string

func (*MemoryCache) Put

func (mc *MemoryCache) Put(key interface{}, value interface{}, lifeTime time.Duration) error

func (*MemoryCache) StartTimerGC

func (mc *MemoryCache) StartTimerGC() error

type Metrics

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

Metrics holds the prometheus configuration.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics -

func (*Metrics) ServeHTTP

func (m *Metrics) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)

type Policy

type Policy struct {
	Version   string `json:"Version"`
	Statement string `json:"Statement"`
}

type RespBody

type RespBody struct {
	Bucket Bucket `json:"Bucket"`
}

type XMLName

type XMLName struct {
	Space string `json:"Space"`
	Local string `json:"Local"`
}

Jump to

Keyboard shortcuts

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