metrics

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ResultLabel     = "result"
	ResultCodeOK    = "ok"
	ResultCodeError = "error"

	RejectedDNSQueryCount = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "rejected_dns_query_count",
	}, []string{})

	DNSRequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "dns_request_duration_seconds",
		Buckets: []float64{0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25},
	}, []string{ResultLabel})

	DNSUpstreamDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "dns_request_upstream_duration_seconds",
		Buckets: []float64{0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25},
	}, []string{ResultLabel})

	DNSCacheMiss = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "dns_cache_miss",
	}, []string{})

	DNSCacheHit = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "dns_cache_hit",
	}, []string{})

	GCStaleDistributedState = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "gc_stale_distributed_state_duration_seconds",
		Buckets: []float64{0.01, 0.05, 0.1, 0.5, 1, 2, 5, 10, 20, 45},
	}, []string{ResultLabel})

	BPFReconcileMapsDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "bpf_reconcile_maps_duration_seconds",
		Buckets: []float64{0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 2, 5, 10, 20, 30},
	}, []string{ResultLabel})

	PacketsProcessed = prometheus.NewDesc(
		"bpf_packets_processed",
		"Number of packets processed",
		[]string{"node", "type"}, nil,
	)
	RingbufDataAvailable    = prometheus.NewDesc("ringbuf_data_available", "", nil, nil)
	RingbufRingSize         = prometheus.NewDesc("ringbuf_ring_size", "", nil, nil)
	RingbufConsumerPosition = prometheus.NewDesc("ringbuf_consumer_position", "", nil, nil)
	RingbufProducerPosition = prometheus.NewDesc("ringbuf_producer_position", "", nil, nil)

	// Tunnel metrics - decapsulation (ingress)
	TunnelGeneveDecap = prometheus.NewDesc(
		"neuwerk_tunnel_geneve_decap_total",
		"Total GENEVE packets decapsulated",
		[]string{"node"}, nil,
	)
	TunnelVxlanDecap = prometheus.NewDesc(
		"neuwerk_tunnel_vxlan_decap_total",
		"Total VXLAN packets decapsulated",
		[]string{"node"}, nil,
	)
	TunnelMalformed = prometheus.NewDesc(
		"neuwerk_tunnel_malformed_total",
		"Total malformed tunnel packets dropped",
		[]string{"node"}, nil,
	)
	TunnelWrongType = prometheus.NewDesc(
		"neuwerk_tunnel_wrong_type_total",
		"Total non-tunnel packets on tunnel interface",
		[]string{"node"}, nil,
	)
	TunnelDecapFailed = prometheus.NewDesc(
		"neuwerk_tunnel_decap_failed_total",
		"Total tunnel decapsulation failures (bpf_skb_adjust_room)",
		[]string{"node"}, nil,
	)
	TunnelMapFull = prometheus.NewDesc(
		"neuwerk_tunnel_map_full_total",
		"Total flow state map full errors",
		[]string{"node"}, nil,
	)

	// Tunnel metrics - encapsulation (egress)
	TunnelGeneveEncap = prometheus.NewDesc(
		"neuwerk_tunnel_geneve_encap_total",
		"Total GENEVE packets re-encapsulated on egress",
		[]string{"node"}, nil,
	)
	TunnelVxlanEncap = prometheus.NewDesc(
		"neuwerk_tunnel_vxlan_encap_total",
		"Total VXLAN packets re-encapsulated on egress",
		[]string{"node"}, nil,
	)
	TunnelNoFlowState = prometheus.NewDesc(
		"neuwerk_tunnel_no_flow_state_total",
		"Total packets without flow state on egress",
		[]string{"node"}, nil,
	)
	TunnelEncapFailed = prometheus.NewDesc(
		"neuwerk_tunnel_encap_failed_total",
		"Total tunnel encapsulation failures (bpf_skb_adjust_room)",
		[]string{"node"}, nil,
	)

	// Session metrics
	SessionsActive = prometheus.NewDesc(
		"neuwerk_sessions_active",
		"Number of active tunnel sessions",
		[]string{"node"}, nil,
	)
	SessionsMax = prometheus.NewDesc(
		"neuwerk_sessions_max",
		"Maximum configured session capacity",
		[]string{"node"}, nil,
	)
	SessionsCreatedTotal = prometheus.NewDesc(
		"neuwerk_sessions_created_total",
		"Total sessions created since startup",
		[]string{"node"}, nil,
	)
	SessionsMapFullTotal = prometheus.NewDesc(
		"neuwerk_sessions_map_full_total",
		"Total packets dropped due to session map full",
		[]string{"node"}, nil,
	)

	// Hairpin redirect counter (GCP ILB)
	HairpinRedirects = prometheus.NewDesc(
		"neuwerk_hairpin_redirects_total",
		"Total hairpin redirects for return traffic",
		[]string{"node", "result"},
		nil,
	)

	// Session utilization gauge
	SessionUtilization = prometheus.NewDesc(
		"neuwerk_sessions_utilization",
		"Session map utilization ratio (active/max)",
		[]string{"node"},
		nil,
	)

	// Cloud registration status
	CloudRegistration = prometheus.NewDesc(
		"neuwerk_cloud_registration",
		"Cloud integration registration status (1=registered, 0=deregistered)",
		[]string{"node", "cloud", "status"},
		nil,
	)

	// BootstrapCompleted tracks bootstrap ceremony completion status.
	// Label: role (leader, follower)
	// Value: 1=completed, 0=pending
	BootstrapCompleted = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "neuwerk_bootstrap_completed",
		Help: "Bootstrap ceremony completion status (1=done, 0=pending)",
	}, []string{"role"})
)
View Source
var (
	// sync with ingress.c
	METRICS_PKT_ALLOWED         = uint32(1)
	METRICS_PKT_REDIRECT        = uint32(2)
	METRICS_PKT_BLOCKED         = uint32(3)
	METRICS_RINGBUF_AVAIL_DATA  = uint32(100)
	METRICS_RINGBUF_RING_SIZE   = uint32(101)
	METRICS_RINGBUF_CONS_POS    = uint32(102)
	METRICS_RINGBUF_PROD_POS    = uint32(103)
	METRICS_ERROR_RINGBUF_ALLOC = uint32(500)
	// Tunnel metrics - ingress decapsulation (sync with common.h and ingress.c)
	METRICS_TUNNEL_GENEVE_DECAP = uint32(200)
	METRICS_TUNNEL_VXLAN_DECAP  = uint32(201)
	METRICS_TUNNEL_MALFORMED    = uint32(502)
	METRICS_TUNNEL_WRONG_TYPE   = uint32(503)
	METRICS_TUNNEL_DECAP_FAILED = uint32(504)
	METRICS_TUNNEL_MAP_FULL     = uint32(505)
	// Tunnel metrics - egress encapsulation (sync with egress.c)
	METRICS_TUNNEL_GENEVE_ENCAP     = uint32(210)
	METRICS_TUNNEL_VXLAN_ENCAP      = uint32(211)
	METRICS_TUNNEL_HAIRPIN_REDIRECT = uint32(212)
	METRICS_TUNNEL_NO_FLOW_STATE    = uint32(506)
	METRICS_TUNNEL_ENCAP_FAILED     = uint32(507)
	// Session metrics (sync with ingress.c)
	METRICS_SESSION_CREATED  = uint32(220)
	METRICS_SESSION_MAP_FULL = uint32(508)
)

Functions

func InitializeCollector

func InitializeCollector(nodeName string, metricsMap, sessionMap *ebpf.Map, cloudIntegration string, sessionMapMaxEntries int)

Types

type MetricsCollector

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

func GetCollector

func GetCollector() *MetricsCollector

GetCollector returns the global metrics collector instance for cloud integration updates

func (MetricsCollector) Collect

func (cc MetricsCollector) Collect(ch chan<- prometheus.Metric)

func (MetricsCollector) Describe

func (cc MetricsCollector) Describe(ch chan<- *prometheus.Desc)

func (*MetricsCollector) SetCloudStatus

func (cc *MetricsCollector) SetCloudStatus(registered bool)

SetCloudStatus updates the cloud registration status for metrics

Jump to

Keyboard shortcuts

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