add flag to explicitly enable per-peer metrics
This commit is contained in:
parent
c08b4202c9
commit
39b21226c4
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2017 Martin Weinelt
|
Copyright (c) 2017-2018 Martin Weinelt
|
||||||
Copyright (c) 2017 Andreas Rammhold
|
Copyright (c) 2017 Andreas Rammhold
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# fastd-exporter
|
# fastd-exporter
|
||||||
|
|
||||||
We are building a prometheus exporter for the [fastd](https://projects.universe-factory.net/projects/fastd/wiki) vpn daemon.
|
We are building a prometheus exporter for the [fastd](https://projects.universe-factory.net/projects/fastd/wiki) vpn daemon.
|
||||||
|
|
||||||
We have a working version, but the metrics, and by extension their labels, are not stable yet.
|
We have a working version, but the metrics, and by extension their labels, are not stable yet.
|
||||||
When they are we will very likely be tagging our first release.
|
When they are we will very likely be tagging our first release.
|
||||||
|
@ -16,7 +16,7 @@ $ go get github.com/freifunk-darmstadt/fastd-exporter
|
||||||
and
|
and
|
||||||
|
|
||||||
```
|
```
|
||||||
$ ./fastd-exporter --instance ffda
|
$ ./fastd-exporter --instance ffda --metrics.perpeer
|
||||||
```
|
```
|
||||||
|
|
||||||
The exporter will need read access to both the instances `fastd.conf` and `status socket`, keep that in mind.
|
The exporter will need read access to both the instances `fastd.conf` and `status socket`, keep that in mind.
|
||||||
|
|
|
@ -21,6 +21,7 @@ var (
|
||||||
address = flag.String("web.listen-address", ":9281", "Address on which to expose metrics and web interface.")
|
address = flag.String("web.listen-address", ":9281", "Address on which to expose metrics and web interface.")
|
||||||
metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
|
metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
|
||||||
instances = flag.String("instances", "", "Fastd instances to report metrics on, comma separated.")
|
instances = flag.String("instances", "", "Fastd instances to report metrics on, comma separated.")
|
||||||
|
peerMetrics = flag.Bool("metrics.perpeer", false, "Expose detailed metrics on each peer.")
|
||||||
)
|
)
|
||||||
|
|
||||||
// These are the structs necessary for unmarshalling the data that is being received on fastds unix socket.
|
// These are the structs necessary for unmarshalling the data that is being received on fastds unix socket.
|
||||||
|
@ -192,24 +193,26 @@ func (e PrometheusExporter) Collect(c chan<- prometheus.Metric) {
|
||||||
c <- prometheus.MustNewConstMetric(e.txDroppedPackets, prometheus.CounterValue, float64(data.Statistics.TX.Count))
|
c <- prometheus.MustNewConstMetric(e.txDroppedPackets, prometheus.CounterValue, float64(data.Statistics.TX.Count))
|
||||||
c <- prometheus.MustNewConstMetric(e.txDroppedBytes, prometheus.CounterValue, float64(data.Statistics.TX_Dropped.Bytes))
|
c <- prometheus.MustNewConstMetric(e.txDroppedBytes, prometheus.CounterValue, float64(data.Statistics.TX_Dropped.Bytes))
|
||||||
|
|
||||||
for publicKey, peer := range data.Peers {
|
if *peerMetrics {
|
||||||
if peer.Connection == nil {
|
for publicKey, peer := range data.Peers {
|
||||||
c <- prometheus.MustNewConstMetric(e.peerUp, prometheus.GaugeValue, float64(0), publicKey, peer.Name)
|
if peer.Connection == nil {
|
||||||
} else {
|
c <- prometheus.MustNewConstMetric(e.peerUp, prometheus.GaugeValue, float64(0), publicKey, peer.Name)
|
||||||
c <- prometheus.MustNewConstMetric(e.peerUp, prometheus.GaugeValue, float64(1), publicKey, peer.Name)
|
} else {
|
||||||
c <- prometheus.MustNewConstMetric(e.peerUptime, prometheus.GaugeValue, peer.Connection.Established/1000, publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerUp, prometheus.GaugeValue, float64(1), publicKey, peer.Name)
|
||||||
|
c <- prometheus.MustNewConstMetric(e.peerUptime, prometheus.GaugeValue, peer.Connection.Established/1000, publicKey, peer.Name)
|
||||||
|
|
||||||
c <- prometheus.MustNewConstMetric(e.peerRxPackets, prometheus.CounterValue, float64(peer.Connection.Statistics.RX.Count), publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerRxPackets, prometheus.CounterValue, float64(peer.Connection.Statistics.RX.Count), publicKey, peer.Name)
|
||||||
c <- prometheus.MustNewConstMetric(e.peerRxBytes, prometheus.CounterValue, float64(peer.Connection.Statistics.RX.Bytes), publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerRxBytes, prometheus.CounterValue, float64(peer.Connection.Statistics.RX.Bytes), publicKey, peer.Name)
|
||||||
c <- prometheus.MustNewConstMetric(e.peerRxReorderedPackets, prometheus.CounterValue, float64(peer.Connection.Statistics.RX_Reordered.Count), publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerRxReorderedPackets, prometheus.CounterValue, float64(peer.Connection.Statistics.RX_Reordered.Count), publicKey, peer.Name)
|
||||||
c <- prometheus.MustNewConstMetric(e.peerRxReorderedBytes, prometheus.CounterValue, float64(peer.Connection.Statistics.RX_Reordered.Bytes), publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerRxReorderedBytes, prometheus.CounterValue, float64(peer.Connection.Statistics.RX_Reordered.Bytes), publicKey, peer.Name)
|
||||||
|
|
||||||
c <- prometheus.MustNewConstMetric(e.peerTxPackets, prometheus.CounterValue, float64(peer.Connection.Statistics.TX.Count), publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerTxPackets, prometheus.CounterValue, float64(peer.Connection.Statistics.TX.Count), publicKey, peer.Name)
|
||||||
c <- prometheus.MustNewConstMetric(e.peerTxBytes, prometheus.CounterValue, float64(peer.Connection.Statistics.TX.Bytes), publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerTxBytes, prometheus.CounterValue, float64(peer.Connection.Statistics.TX.Bytes), publicKey, peer.Name)
|
||||||
c <- prometheus.MustNewConstMetric(e.peerTxDroppedPackets, prometheus.CounterValue, float64(peer.Connection.Statistics.TX_Dropped.Count), publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerTxDroppedPackets, prometheus.CounterValue, float64(peer.Connection.Statistics.TX_Dropped.Count), publicKey, peer.Name)
|
||||||
c <- prometheus.MustNewConstMetric(e.peerTxDroppedBytes, prometheus.CounterValue, float64(peer.Connection.Statistics.TX_Dropped.Bytes), publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerTxDroppedBytes, prometheus.CounterValue, float64(peer.Connection.Statistics.TX_Dropped.Bytes), publicKey, peer.Name)
|
||||||
c <- prometheus.MustNewConstMetric(e.peerTxErrorPackets, prometheus.CounterValue, float64(peer.Connection.Statistics.TX_Error.Count), publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerTxErrorPackets, prometheus.CounterValue, float64(peer.Connection.Statistics.TX_Error.Count), publicKey, peer.Name)
|
||||||
c <- prometheus.MustNewConstMetric(e.peerTxErrorBytes, prometheus.CounterValue, float64(peer.Connection.Statistics.TX_Error.Bytes), publicKey, peer.Name)
|
c <- prometheus.MustNewConstMetric(e.peerTxErrorBytes, prometheus.CounterValue, float64(peer.Connection.Statistics.TX_Error.Bytes), publicKey, peer.Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue