metrics

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AgentErrorsGauge tracks the number of agents in error status per namespace/project
	AgentErrorsGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "flecto_agent_errors_total",
			Help: "Number of agents in error status (excluding offline agents)",
		},
		[]string{"namespace", "project"},
	)

	// AgentOnlineGauge tracks the number of online agents per namespace/project
	AgentOnlineGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "flecto_agent_online_total",
			Help: "Number of online agents",
		},
		[]string{"namespace", "project"},
	)

	// HTTPRequestsTotal counts HTTP requests
	HTTPRequestsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "flecto_http_requests_total",
			Help: "Total number of HTTP requests",
		},
		[]string{"method", "path", "status"},
	)

	// HTTPRequestDuration tracks HTTP request duration
	HTTPRequestDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "flecto_http_request_duration_seconds",
			Help:    "HTTP request duration in seconds",
			Buckets: prometheus.DefBuckets,
		},
		[]string{"method", "path"},
	)
)

Functions

func EchoHandler

func EchoHandler() echo.HandlerFunc

EchoHandler returns an Echo handler for Prometheus metrics

func EchoMiddleware

func EchoMiddleware() echo.MiddlewareFunc

EchoMiddleware returns an Echo middleware that records HTTP metrics

func Handler

func Handler() http.Handler

Handler returns the Prometheus metrics HTTP handler

func StartCollector

func StartCollector(ctx *appContext.Context, provider AgentMetricsProvider, interval time.Duration)

StartCollector starts a background goroutine that periodically updates agent metrics

func StartServer

func StartServer(ctx *appContext.Context, listen string) *http.Server

StartServer starts a dedicated metrics server on the specified address

Types

type AgentCount

type AgentCount struct {
	NamespaceCode string
	ProjectCode   string
	Status        commonTypes.AgentStatus
	Count         int64
}

AgentCount represents agent count for a namespace/project/status combination

type AgentMetricsProvider

type AgentMetricsProvider interface {
	GetAgentCounts(ctx context.Context, onlineThreshold time.Time) ([]AgentCount, error)
}

AgentMetricsProvider provides agent metrics data

func NewAgentMetricsProvider

func NewAgentMetricsProvider(agentService service.AgentService) AgentMetricsProvider

NewAgentMetricsProvider creates a new AgentMetricsProvider

Jump to

Keyboard shortcuts

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