-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mtr_runs_total metric and track failed runs
The new metric `mtr_runs_total` keeps track of how often a certain job of `mtr` was launched / returned. To allow detecting issues in the network (for which `mtr` returns "only" an error message), the error message of `mtr` is used as "error" label. A successful run is lacking the "error" label. Thus: * `sum by(mtr_exporter_job)(mtr_runs_total{})` provides the absolute total number of `mtr` runs * `sum by(mtr_exporter, error)(mtr_runs_total{error!=""})` provides the failed runs * the diff between the previous queries are the amount of successful runs The error message of `mtr` is "normalized": all chars in the original `mtr` message are lower cased, only [0-9,a-z,- ] are kept, everything else is mapped to `-`. Also, when no job has returned something yet, the metric exporter would not report uninitialized values.
- Loading branch information
Showing
6 changed files
with
111 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package job | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_NormalizeMtrErrorMsg(t *testing.T) { | ||
|
||
fixtures := []struct { | ||
msg string | ||
normalized string | ||
}{ | ||
{"mtr: Unexpected mtr-packet error", "mtr: unexpected mtr-packet error"}, | ||
} | ||
|
||
for i := range fixtures { | ||
normalized := normalizeMtrErrorMsg(fixtures[i].msg) | ||
if normalized != fixtures[i].normalized { | ||
t.Fatalf("expected %q for %q, got %q", fixtures[i].normalized, fixtures[i].msg, normalized) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters