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

@ -117,7 +117,7 @@ You can specify a port for the iperf3 server target. If its not set, it will use
## Exposed metrics
| name | type |
| ---------------------------------------- | ----- |
| ---------------------------------------- | ------- |
| iperf3_download_sent_bits_per_second | gauge |
| iperf3_download_sent_seconds | gauge |
| iperf3_download_sent_bytes | gauge |
@ -132,3 +132,4 @@ You can specify a port for the iperf3 server target. If its not set, it will use
| iperf3_upload_received_bits_per_second | gauge |
| iperf3_upload_received_seconds | gauge |
| iperf3_upload_received_bytes | gauge |
| iperf3_errors | counter |

View File

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