feat: error metrics
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Marvin Preuss 2021-11-22 12:32:42 +01:00
parent f81754b756
commit 5e75df24b1
2 changed files with 20 additions and 16 deletions

View File

@ -116,19 +116,20 @@ You can specify a port for the iperf3 server target. If its not set, it will use
## Exposed metrics ## Exposed metrics
| name | type | | name | type |
| ---------------------------------------- | ----- | | ---------------------------------------- | ------- |
| iperf3_download_sent_bits_per_second | gauge | | iperf3_download_sent_bits_per_second | gauge |
| iperf3_download_sent_seconds | gauge | | iperf3_download_sent_seconds | gauge |
| iperf3_download_sent_bytes | gauge | | iperf3_download_sent_bytes | gauge |
| iperf3_download_sent_retransmits | gauge | | iperf3_download_sent_retransmits | gauge |
| iperf3_download_received_bits_per_second | gauge | | iperf3_download_received_bits_per_second | gauge |
| iperf3_download_received_seconds | gauge | | iperf3_download_received_seconds | gauge |
| iperf3_download_received_bytes | gauge | | iperf3_download_received_bytes | gauge |
| iperf3_upload_sent_bits_per_second | gauge | | iperf3_upload_sent_bits_per_second | gauge |
| iperf3_upload_sent_seconds | gauge | | iperf3_upload_sent_seconds | gauge |
| iperf3_upload_sent_bytes | gauge | | iperf3_upload_sent_bytes | gauge |
| iperf3_upload_sent_retransmits | gauge | | iperf3_upload_sent_retransmits | gauge |
| iperf3_upload_received_bits_per_second | gauge | | iperf3_upload_received_bits_per_second | gauge |
| iperf3_upload_received_seconds | gauge | | iperf3_upload_received_seconds | gauge |
| iperf3_upload_received_bytes | gauge | | iperf3_upload_received_bytes | gauge |
| iperf3_errors | counter |

View File

@ -89,6 +89,8 @@ var (
uploadReceivedBytes = metrics.NewFloatCounter("iperf3_upload_received_bytes") uploadReceivedBytes = metrics.NewFloatCounter("iperf3_upload_received_bytes")
) )
var scrapeErrors = metrics.NewCounter("iperf3_errors")
//nolint:tagliatelle //nolint:tagliatelle
type iperfResult struct { type iperfResult struct {
End struct { End struct {
@ -255,6 +257,7 @@ func probeHandler(w http.ResponseWriter, r *http.Request) {
// Extract port and host for target. // Extract port and host for target.
t, err := NewTarget(trgt) t, err := NewTarget(trgt)
if err != nil { if err != nil {
scrapeErrors.Inc()
logger.Error().Err(err).Msg("could not determine target") logger.Error().Err(err).Msg("could not determine target")
http.Error(w, "could not determine target", http.StatusUnprocessableEntity) http.Error(w, "could not determine target", http.StatusUnprocessableEntity)
} }