pingcheckreceiver

package module
v0.0.0-...-473c242 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

README

Ping Receiver

Getting Started

By default, the Ping receiver will ping each configured target and report round-trip time and packet loss metrics:

receivers:
  ping:
    targets:
      - endpoint: google.com
      - endpoint: 8.8.8.8

Configuration

The following settings are available:

  • collection_interval (default: 60s): How often to ping targets
  • initial_delay (default: 1s): Time to wait before first collection
  • privileged (default: false): Whether to use raw ICMP sockets (requires privileges)
  • targets: List of endpoints to ping
    • endpoint: Hostname or IP address to ping (required)
    • count (default: 4): Number of packets to send
    • timeout (default: 5s): Timeout for the ping operation
    • interval (default: 1s): Interval between packets
Example Configuration
receivers:
  ping:
    collection_interval: 60s
    initial_delay: 1s
    privileged: false
    targets:
      - endpoint: google.com
        count: 4
        timeout: 5s
        interval: 1s
      - endpoint: 8.8.8.8
        count: 3
        timeout: 3s
      - endpoint: internal.service.local
        count: 5
        timeout: 10s
        interval: 2s

Privilege Requirements

ICMP operations may require elevated privileges depending on the platform:

Linux/Unix

For raw ICMP sockets (privileged mode):

# Grant CAP_NET_RAW capability
sudo setcap cap_net_raw+ep /path/to/collector
Windows

Windows always requires privileged mode for ICMP operations. The receiver automatically enables it on Windows platforms.

Kubernetes
securityContext:
  capabilities:
    add:
    - NET_RAW
Unprivileged Mode

When privileged: false (Linux/Unix only), the receiver uses UDP sockets which work without special privileges.

Metrics

The following metrics are emitted by this receiver:

Metric Description Unit Type Attributes
ping.duration Round-trip time for individual ping packets ms Gauge net.peer.name, net.peer.ip
ping.duration.min Minimum round-trip time ms Gauge net.peer.name, net.peer.ip
ping.duration.max Maximum round-trip time ms Gauge net.peer.name, net.peer.ip
ping.duration.avg Average round-trip time ms Gauge net.peer.name, net.peer.ip
ping.duration.stddev Standard deviation of round-trip times ms Gauge net.peer.name, net.peer.ip
ping.packet_loss Ratio of packets lost (0.0 to 1.0) 1 Gauge net.peer.name, net.peer.ip
ping.packets.sent Total number of packets sent {packet} Sum net.peer.name, net.peer.ip
ping.packets.received Total number of packets received {packet} Sum net.peer.name, net.peer.ip
ping.errors Number of errors encountered (disabled by default) {error} Sum net.peer.name, net.peer.ip, error.type
Attributes
  • net.peer.name: The hostname or endpoint as configured
  • net.peer.ip: The resolved IP address of the target
  • error.type: Type of error (when applicable): timeout, dns_failure, network_unreachable, permission_denied, unknown

Example Pipeline

receivers:
  ping:
    collection_interval: 60s
    targets:
      - endpoint: google.com
      - endpoint: cloudflare.com
      - endpoint: 8.8.8.8

processors:
  batch:
    timeout: 10s

exporters:
  prometheus:
    endpoint: "0.0.0.0:8889"
  debug:
    verbosity: detailed

service:
  pipelines:
    metrics:
      receivers: [ping]
      processors: [batch]
      exporters: [prometheus, debug]

Documentation

Overview

Package pingcheckreceiver implements a receiver that performs ICMP ping checks against configured targets and reports network connectivity metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() receiver.Factory

NewFactory creates a new factory for Ping receiver

Types

type Config

type Config struct {
	scraperhelper.ControllerConfig `mapstructure:",squash"`
	metadata.MetricsBuilderConfig  `mapstructure:",squash"`

	// Targets to ping
	Targets []Target `mapstructure:"targets"`

	// Privileged mode for raw ICMP sockets
	Privileged bool `mapstructure:"privileged"`
}

Config defines the configuration for the Ping receiver

func (*Config) Validate

func (cfg *Config) Validate() error

Validate implements component.Config

type Target

type Target struct {
	// Endpoint to ping (hostname or IP)
	Endpoint string `mapstructure:"endpoint"`

	// Number of packets to send (default: 4)
	Count int `mapstructure:"count"`

	// Timeout for ping operation (default: 5s)
	Timeout time.Duration `mapstructure:"timeout"`

	// Interval between packets (default: 1s)
	Interval time.Duration `mapstructure:"interval"`
}

Target defines a ping target configuration

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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