stats

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableName = "nat-stats"
)

Variables

View Source
var Cell = cell.Module(
	"nat-stats",
	"Aggregates stats for NAT maps",
	metrics.Metric(newMetrics),
	cell.ProvidePrivate(newTables),
	cell.Provide(
		func(m Metrics) natMetrics {
			return m
		},
		newStats,
		statedb.RWTable[NatMapStats].ToTable,
	),
	cell.Config(Config{

		NATMapStatInterval: 30 * time.Second,

		NatMapStatKStoredEntries: 32,
	}),
	cell.Invoke(func(_ *Stats) {}),
)

Cell exports a module providing functionality for computing NAT map stats. This uses provided pkg/maps/nat.(Cell) maps to efficiently walk the nat map and compute the top-k most used connection tuples. In this context, a "connection tuple" refers to the 4-tuple:

{port, egressIP, remoteEndpointIP, remoteEndpointPort}

Which defines a distinct set of translated connections for which the source IP is the egress IP, who all share the same endpoint address. Egress source ports are allocated by the datapath and, in some cases, can be prone to exhaustion or allocation failures if the connection tuple already has many connections to the same endpoint.

The nat-stats module exposes this data as both prometheus metrics and via a exported statedb.Table[NatMapStats] for other modules to consume.

View Source
var (
	Index = statedb.Index[NatMapStats, string]{
		Name: "byTuple",
		FromObject: func(s NatMapStats) index.KeySet {
			return index.NewKeySet(s.Key())
		},
		FromKey: index.String,
		Unique:  true,
	}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	NATMapStatInterval       time.Duration `mapstructure:"nat-map-stats-interval"`
	NatMapStatKStoredEntries int           `mapstructure:"nat-map-stats-entries"`
}

func (Config) Flags

func (def Config) Flags(flags *pflag.FlagSet)

type Metrics

type Metrics struct {
	LocalPorts metric.Vec[metric.Gauge]
}

type NatMapStats

type NatMapStats struct {
	Type       string
	EgressIP   string
	EndpointIP string
	RemotePort uint16
	Proto      string
	Count      int
	Nth        int
}

NatMapStats is a nat-map table entry key/value. This contains a count of connection 3-tuple utilization.

func (NatMapStats) Key

func (s NatMapStats) Key() index.Key

func (NatMapStats) TableHeader

func (NatMapStats) TableHeader() []string

func (NatMapStats) TableRow

func (s NatMapStats) TableRow() []string

type Stats

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

Stats provides a implementation of performing nat map stats counting.

Jump to

Keyboard shortcuts

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