add additional stats that were already being collected

and rearrange the order to match the index order from the CSV endpoint

add test coverage. add back wretr.  remove check_status from recently added column

closes #445
This commit is contained in:
chrispeterson 2015-12-15 15:46:41 -08:00 committed by Cameron Sparr
parent 97ebcc2af1
commit 34f0c593ad
2 changed files with 107 additions and 47 deletions

View File

@ -190,6 +190,11 @@ func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) ([][]str
if err == nil { if err == nil {
acc.Add("smax", ival, tags) acc.Add("smax", ival, tags)
} }
case HF_STOT:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("stot", ival, tags)
}
case HF_BIN: case HF_BIN:
ival, err := strconv.ParseUint(v, 10, 64) ival, err := strconv.ParseUint(v, 10, 64)
if err == nil { if err == nil {
@ -210,6 +215,56 @@ func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) ([][]str
if err == nil { if err == nil {
acc.Add("dresp", ival, tags) acc.Add("dresp", ival, tags)
} }
case HF_EREQ:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("ereq", ival, tags)
}
case HF_ECON:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("econ", ival, tags)
}
case HF_ERESP:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("eresp", ival, tags)
}
case HF_WRETR:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("wretr", ival, tags)
}
case HF_WREDIS:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("wredis", ival, tags)
}
case HF_ACT:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("active_servers", ival, tags)
}
case HF_BCK:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("backup_servers", ival, tags)
}
case HF_DOWNTIME:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("downtime", ival, tags)
}
case HF_THROTTLE:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("throttle", ival, tags)
}
case HF_LBTOT:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("lbtot", ival, tags)
}
case HF_RATE: case HF_RATE:
ival, err := strconv.ParseUint(v, 10, 64) ival, err := strconv.ParseUint(v, 10, 64)
if err == nil { if err == nil {
@ -220,10 +275,10 @@ func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) ([][]str
if err == nil { if err == nil {
acc.Add("rate_max", ival, tags) acc.Add("rate_max", ival, tags)
} }
case HF_STOT: case HF_CHECK_DURATION:
ival, err := strconv.ParseUint(v, 10, 64) ival, err := strconv.ParseUint(v, 10, 64)
if err == nil { if err == nil {
acc.Add("stot", ival, tags) acc.Add("check_duration", ival, tags)
} }
case HF_HRSP_1xx: case HF_HRSP_1xx:
ival, err := strconv.ParseUint(v, 10, 64) ival, err := strconv.ParseUint(v, 10, 64)
@ -250,31 +305,6 @@ func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) ([][]str
if err == nil { if err == nil {
acc.Add("http_response.5xx", ival, tags) acc.Add("http_response.5xx", ival, tags)
} }
case HF_EREQ:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("ereq", ival, tags)
}
case HF_ERESP:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("eresp", ival, tags)
}
case HF_ECON:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("econ", ival, tags)
}
case HF_WRETR:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("wretr", ival, tags)
}
case HF_WREDIS:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("wredis", ival, tags)
}
case HF_REQ_RATE: case HF_REQ_RATE:
ival, err := strconv.ParseUint(v, 10, 64) ival, err := strconv.ParseUint(v, 10, 64)
if err == nil { if err == nil {
@ -290,15 +320,35 @@ func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) ([][]str
if err == nil { if err == nil {
acc.Add("req_tot", ival, tags) acc.Add("req_tot", ival, tags)
} }
case HF_THROTTLE: case HF_CLI_ABRT:
ival, err := strconv.ParseUint(v, 10, 64) ival, err := strconv.ParseUint(v, 10, 64)
if err == nil { if err == nil {
acc.Add("throttle", ival, tags) acc.Add("cli_abort", ival, tags)
} }
case HF_LBTOT: case HF_SRV_ABRT:
ival, err := strconv.ParseUint(v, 10, 64) ival, err := strconv.ParseUint(v, 10, 64)
if err == nil { if err == nil {
acc.Add("lbtot", ival, tags) acc.Add("srv_abort", ival, tags)
}
case HF_QTIME:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("qtime", ival, tags)
}
case HF_CTIME:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("ctime", ival, tags)
}
case HF_RTIME:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("rtime", ival, tags)
}
case HF_TTIME:
ival, err := strconv.ParseUint(v, 10, 64)
if err == nil {
acc.Add("ttime", ival, tags)
} }
} }

View File

@ -53,31 +53,41 @@ func TestHaproxyGeneratesMetricsWithAuthentication(t *testing.T) {
name string name string
value uint64 value uint64
}{ }{
{"bin", 5557055817},
{"scur", 288},
{"qmax", 81}, {"qmax", 81},
{"scur", 288},
{"smax", 713},
{"bin", 5557055817},
{"bout", 24096715169},
{"dreq", 1102},
{"dresp", 80},
{"ereq", 95740},
{"econ", 0},
{"eresp", 0},
{"wretr", 17},
{"wredis", 19},
{"active_servers", 1},
{"backup_servers", 0},
{"downtime", 0},
{"throttle", 13},
{"lbtot", 114},
{"rate", 18},
{"rate_max", 102},
{"check_duration", 1},
{"http_response.1xx", 0}, {"http_response.1xx", 0},
{"http_response.2xx", 1314093}, {"http_response.2xx", 1314093},
{"http_response.3xx", 537036}, {"http_response.3xx", 537036},
{"http_response.4xx", 123452}, {"http_response.4xx", 123452},
{"http_response.5xx", 11966}, {"http_response.5xx", 11966},
{"dreq", 1102},
{"dresp", 80},
{"wretr", 17},
{"wredis", 19},
{"ereq", 95740},
{"econ", 0},
{"eresp", 0},
{"req_rate", 35}, {"req_rate", 35},
{"req_rate_max", 140}, {"req_rate_max", 140},
{"req_tot", 1987928}, {"req_tot", 1987928},
{"bin", 5557055817}, {"cli_abort", 0},
{"bout", 24096715169}, {"srv_abort", 0},
{"rate", 18}, {"qtime", 0},
{"rate_max", 102}, {"ctime", 2},
{"rtime", 23},
{"throttle", 13}, {"ttime", 545},
{"lbtot", 114},
} }
for _, c := range checkInt { for _, c := range checkInt {