项目作者: knsd

项目描述 :
Prometheus ICMP ping exporter
高级语言: Rust
项目地址: git://github.com/knsd/ping-exporter.git
创建时间: 2018-06-06T11:03:50Z
项目社区:https://github.com/knsd/ping-exporter

开源协议:

下载


ping-exporter

Build Status

Building and running

Local Build

  1. make
  2. ./ping-exporter

Visiting http://localhost:9346/ping?target=google.com will return metrics for an ICMP ping against google.com.

Building with Docker

  1. docker build -t ping-exporter .
  2. docker run -d -p 9346:9346 --name=ping-exporter ping-exporter

Settings

Environment variable Default Value
PING_EXPORTER_LISTEN [::]:9346
PING_EXPORTER_DEFAULT_PROTOCOL v4
PING_EXPORTER_RESOLVER system
PING_EXPORTER_DEFAULT_COUNT 5
PING_EXPORTER_MAX_COUNT 30
PING_EXPORTER_DEFAULT_PING_TIMEOUT 1000
PING_EXPORTER_MAX_PING_TIMEOUT 10000
PING_EXPORTER_DEFAULT_RESOLVE_TIMEOUT 1000
PING_EXPORTER_MAX_RESOLVE_TIMEOUT 10000

Available metrics

/ping endpoint

Metric name Type Description
ping_resolve_error gauge Boolean metric if there’s an error during the resolve (error message will be in “error” label)
ping_resolve_time gauge Time it take to resolve domain to an IP address
ping_packets_total gauge Total number of sent pings
ping_packets_success gauge Total number of success pings
ping_packets_failed gauge Total number of failed pings
ping_packets_loss gauge A percentage of failed pings from the total pings
ping_times histogram A histogram of round-trip times

/metrics endpoint

Metric name Type Description
http_ping counter Number of requests to /ping endpoint

Prometheus Configuration

This exporter needs to be passed the target as a parameter, this can be done with relabelling.

Example config:

  1. scrape_configs:
  2. - job_name: 'ping'
  3. metrics_path: /ping
  4. static_configs:
  5. - targets:
  6. - google.com # Target to ping
  7. relabel_configs:
  8. - source_labels: [__address__]
  9. target_label: __param_target
  10. - source_labels: [__param_target]
  11. target_label: instance
  12. - target_label: __address__
  13. replacement: 127.0.0.1:9346 # This exporter's real hostname:port

In addition to that you can scrape the /metrics endpoint to be able to monitor exporter’s own statistics.

Example config:

  1. scrape_configs:
  2. - job_name: 'ping_exporter'
  3. static_configs:
  4. - targets:
  5. - 127.0.0.1:9346 # This exporter's real hostname:port