nftreceiver

package module
v0.0.0-...-43ccc69 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

otel-nft-receiver

OpenTelemetry Collector receiver that exports nftables named counters as metrics.

Reads all counter objects from a configured nftables table (default: accounting, inet family) and emits two metrics per counter:

  • nft_counter_bytes — total bytes matched
  • nft_counter_packets — total packets matched

Each metric has name and direction labels. Counter names are expected to follow the <name>_<tx|rx> convention (e.g. wan_tx becomes name=wan, direction=tx).

Configuration

receivers:
  nft:
    interval: "60s"    # scrape interval (default: 60s)
    table: "accounting" # nftables table name (default: accounting)

nftables setup

Create an inet table with named counters:

table inet accounting {
    counter wan_tx { }
    counter wan_rx { }
    counter lan_tx { }
    counter lan_rx { }
}

Reference them from your rules:

chain forward {
    type filter hook forward priority 0; policy accept;
    oifname "wan0" counter name wan_tx
    iifname "wan0" counter name wan_rx
}

Requirements

Requires CAP_NET_ADMIN (or root) to read nftables counters via netlink.

Documentation

Overview

This file is the refactored version of https://github.com/open-telemetry/opentelemetry-go-contrib/blob/bridges/prometheus/v0.63.0/bridges/prometheus/producer.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() receiver.Factory

Types

type Config

type Config struct {
	Interval string `mapstructure:"interval"`
	Table    string `mapstructure:"table"`
}

type NftReceiver

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

func (*NftReceiver) Shutdown

func (r *NftReceiver) Shutdown(ctx context.Context) error

func (*NftReceiver) Start

func (r *NftReceiver) Start(ctx context.Context, host component.Host) error

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option sets producer option values.

func WithGatherer

func WithGatherer(gatherer prometheus.Gatherer) Option

WithGatherer configures which prometheus Gatherer the Bridge will gather from. If no registerer is used the prometheus DefaultGatherer is used.

func WithScope

func WithScope(scope string) Option

type Producer

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

func NewMetricProducer

func NewMetricProducer(opts ...Option) *Producer

NewMetricProducer returns a metric.Producer that fetches metrics from Prometheus. This can be used to allow Prometheus instrumentation to be added to an OpenTelemetry export pipeline.

func (*Producer) Produce

func (p *Producer) Produce(context.Context) (pmetric.Metrics, error)

Jump to

Keyboard shortcuts

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