prom

package
v0.0.60 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package prom exposes metrics on synapse-node

Index

Constants

View Source
const ChainIDVar = "chain_id"

ChainIDVar is the variable used for the chain id.

View Source
const NodeIDName = "node_id"

NodeIDName is the name of the node id.

View Source
const NodeIDVar = "node_id"

NodeIDVar is the variable used for node id.

View Source
const PrometheusDataSourceName = "Prometheus"

PrometheusDataSourceName is the name of the data source in grafana to use for prometheus.

View Source
const TimeSeriesFormat = "time_series"

TimeSeriesFormat is the format used for timeseries (in sdk.target).

View Source
const TimeSeriesGraphType = "timeseries"

TimeSeriesGraphType is the graph type used for timeseries.

Variables

This section is empty.

Functions

func CreateBoardJSONHandler

func CreateBoardJSONHandler(board *sdk.Board) http.Handler

CreateBoardJSONHandler creates a handler that returns the json for a grafana dashboard.

func MetricToTitle

func MetricToTitle(metric string) string

MetricToTitle formats a metric as a title.

func WrapMetricJobQuery

func WrapMetricJobQuery(metric string) string

WrapMetricJobQuery wraps the metric in a query around job.

Types

type Config

type Config struct {
	// PushGateway url to use (if any)
	PushGateway string `toml:"PushGateway"`
	// Enabled Whether or not to enable metrics
	Enabled bool `toml:"Enabled"`
	// GrafanaHost to push dashboards to (none will be pushed if disabled)
	GrafanaHost string `toml:"GrafanaHost"`
	// GrafanaKey to use to push dashboards
	GrafanaKey string `toml:"GrafanaKey"`
}

Config contains the configuration for the metrics handler.

func (*Config) IsValid

func (c *Config) IsValid(ctx context.Context) (ok bool, err error)

IsValid determines whether or not the metrics config is valid.

type ErrorLogger

type ErrorLogger struct {
	*log.ZapEventLogger
}

ErrorLogger is the error logger used for prometheus http.

func NewPromLogger

func NewPromLogger(logClient *log.ZapEventLogger) ErrorLogger

NewPromLogger creates a new prometheus error logger.

func (ErrorLogger) Log

func (p ErrorLogger) Log(keyvals ...interface{}) error

Log prints the output of prom to the logger.

func (ErrorLogger) Println

func (p ErrorLogger) Println(v ...interface{})

Println prints the output of prom to the error logger.

type Graphable

type Graphable interface {
	Instrumentable
	// GetGraphs gets the graphs associated with this object.
	GetGraphs() []*sdk.Panel
}

Graphable is an interface that exposes a way for metrics to be registered with a the metric handler. It allows the responsibility. of placing the graphs to be used by the client.

type Instrumentable

type Instrumentable interface {
	// GetMetrics gets the metrics associated with this object.
	GetMetrics(labels map[string]string) []prometheus.Collector
}

Instrumentable is a type that exports some (or none as an array) prometheus metrics.

type MetricHandler

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

MetricHandler stores metrics and handles exposing them.

func NewMetricHandler

func NewMetricHandler(nodeID string, cfg *Config) *MetricHandler

NewMetricHandler creates a new metrics handler.

func (*MetricHandler) Handler

func (m *MetricHandler) Handler() http.Handler

Handler gets the http handler for the metrics handler. This can be used in combination with or instead of the push gateway.

func (*MetricHandler) PutDashboard

func (m *MetricHandler) PutDashboard(ctx context.Context, dashboard *sdk.Board) error

PutDashboard creates a dashboard. TODO replace by title/verify grafana config.

func (*MetricHandler) RegisterMetrics

func (m *MetricHandler) RegisterMetrics(cs ...prometheus.Collector)

RegisterMetrics registers metrics in the registry.

func (*MetricHandler) Start

func (m *MetricHandler) Start(ctx context.Context) (err error)

Start starts the metric handler backround services with context.

Jump to

Keyboard shortcuts

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