MINOR: contrib/prometheus-exporter: Report metrics about max times for sessions

Now, for the sessions, the maximum times (queue, connect, response, total) are
reported in addition of the averages over the last 1024 connections. These
metrics are reported per backend and per server. Here are the metrics name :

  * haproxy_backend_max_queue_time_seconds
  * haproxy_backend_max_connect_time_seconds
  * haproxy_backend_max_response_time_seconds
  * haproxy_backend_max_total_time_seconds

and

  * haproxy_server_max_queue_time_seconds
  * haproxy_server_max_connect_time_seconds
  * haproxy_server_max_response_time_seconds
  * haproxy_server_max_total_time_seconds

This patch is related to #272.
This commit is contained in:
Christopher Faulet 2019-11-08 15:05:31 +01:00
parent 0d1c2a65e8
commit 8fc027d468
2 changed files with 66 additions and 2 deletions

View File

@ -170,6 +170,10 @@ Exported metrics
| haproxy_backend_http_connect_time_average_seconds | Avg. connect time for last 1024 successful connections. |
| haproxy_backend_http_response_time_average_seconds | Avg. response time for last 1024 successful connections. |
| haproxy_backend_http_total_time_average_seconds | Avg. total time for last 1024 successful connections. |
| haproxy_backend_max_queue_time_seconds | Maximum observed queue time. |
| haproxy_backend_max_connect_time_seconds | Maximum observed connect time. |
| haproxy_backend_max_response_time_seconds | Maximum observed response time. |
| haproxy_backend_max_total_time_seconds | Maximum observed total time. |
| haproxy_backend_requests_denied_total | Total number of denied requests. |
| haproxy_backend_responses_denied_total | Total number of denied responses. |
| haproxy_backend_connection_errors_total | Total number of connection errors. |
@ -217,6 +221,10 @@ Exported metrics
| haproxy_server_http_connect_time_average_seconds | Avg. connect time for last 1024 successful connections. |
| haproxy_server_http_response_time_average_seconds | Avg. response time for last 1024 successful connections. |
| haproxy_server_http_total_time_average_seconds | Avg. total time for last 1024 successful connections. |
| haproxy_server_max_queue_time_seconds | Maximum observed queue time. |
| haproxy_server_max_connect_time_seconds | Maximum observed connect time. |
| haproxy_server_max_response_time_seconds | Maximum observed response time. |
| haproxy_server_max_total_time_seconds | Maximum observed total time. |
| haproxy_server_connection_attempts_total | Total number of connection establishment attempts. |
| haproxy_server_connection_reuses_total | Total number of connection reuses. |
| haproxy_server_responses_denied_total | Total number of denied responses. |

View File

@ -232,6 +232,10 @@ const int promex_front_metrics[ST_F_TOTAL_FIELDS] = {
[ST_F_REUSE] = 0,
[ST_F_CACHE_LOOKUPS] = ST_F_CACHE_HITS,
[ST_F_CACHE_HITS] = ST_F_COMP_IN,
[ST_F_QT_MAX] = 0,
[ST_F_CT_MAX] = 0,
[ST_F_RT_MAX] = 0,
[ST_F_TT_MAX] = 0,
};
/* Matrix used to dump backend metrics. Each metric points to the next one to be
@ -298,7 +302,7 @@ const int promex_back_metrics[ST_F_TOTAL_FIELDS] = {
[ST_F_QTIME] = ST_F_CTIME,
[ST_F_CTIME] = ST_F_RTIME,
[ST_F_RTIME] = ST_F_TTIME,
[ST_F_TTIME] = ST_F_DREQ,
[ST_F_TTIME] = ST_F_QT_MAX,
[ST_F_AGENT_STATUS] = 0,
[ST_F_AGENT_CODE] = 0,
[ST_F_AGENT_DURATION] = 0,
@ -325,6 +329,10 @@ const int promex_back_metrics[ST_F_TOTAL_FIELDS] = {
[ST_F_REUSE] = ST_F_BIN,
[ST_F_CACHE_LOOKUPS] = ST_F_CACHE_HITS,
[ST_F_CACHE_HITS] = ST_F_COMP_IN,
[ST_F_QT_MAX] = ST_F_CT_MAX,
[ST_F_CT_MAX] = ST_F_RT_MAX,
[ST_F_RT_MAX] = ST_F_TT_MAX,
[ST_F_TT_MAX] = ST_F_DREQ,
};
/* Matrix used to dump server metrics. Each metric points to the next one to be
@ -391,7 +399,7 @@ const int promex_srv_metrics[ST_F_TOTAL_FIELDS] = {
[ST_F_QTIME] = ST_F_CTIME,
[ST_F_CTIME] = ST_F_RTIME,
[ST_F_RTIME] = ST_F_TTIME,
[ST_F_TTIME] = ST_F_CONNECT,
[ST_F_TTIME] = ST_F_QT_MAX,
[ST_F_AGENT_STATUS] = 0,
[ST_F_AGENT_CODE] = 0,
[ST_F_AGENT_DURATION] = 0,
@ -418,6 +426,10 @@ const int promex_srv_metrics[ST_F_TOTAL_FIELDS] = {
[ST_F_REUSE] = ST_F_DRESP,
[ST_F_CACHE_LOOKUPS] = 0,
[ST_F_CACHE_HITS] = 0,
[ST_F_QT_MAX] = ST_F_CT_MAX,
[ST_F_CT_MAX] = ST_F_RT_MAX,
[ST_F_RT_MAX] = ST_F_TT_MAX,
[ST_F_TT_MAX] = ST_F_CONNECT,
};
/* Name of all info fields */
@ -574,6 +586,10 @@ const struct ist promex_st_metric_names[ST_F_TOTAL_FIELDS] = {
[ST_F_REUSE] = IST("connection_reuses_total"),
[ST_F_CACHE_LOOKUPS] = IST("http_cache_lookups_total"),
[ST_F_CACHE_HITS] = IST("http_cache_hits_total"),
[ST_F_QT_MAX] = IST("max_queue_time_seconds"),
[ST_F_CT_MAX] = IST("max_connect_time_seconds"),
[ST_F_RT_MAX] = IST("max_response_time_seconds"),
[ST_F_TT_MAX] = IST("max_total_time_seconds"),
};
/* Description of all info fields */
@ -730,6 +746,10 @@ const struct ist promex_st_metric_desc[ST_F_TOTAL_FIELDS] = {
[ST_F_REUSE] = IST("Total number of connection reuses."),
[ST_F_CACHE_LOOKUPS] = IST("Total number of HTTP cache lookups."),
[ST_F_CACHE_HITS] = IST("Total number of HTTP cache hits."),
[ST_F_QT_MAX] = IST("Maximum observed time spent in the queue"),
[ST_F_CT_MAX] = IST("Maximum observed time spent waiting for a connection to complete"),
[ST_F_RT_MAX] = IST("Maximum observed time spent waiting for a server response"),
[ST_F_TT_MAX] = IST("Maximum observed total request+response time (request+queue+connect+response+processing)"),
};
/* Specific labels for all info fields. Empty by default. */
@ -1042,6 +1062,10 @@ const struct ist promex_st_metric_types[ST_F_TOTAL_FIELDS] = {
[ST_F_REUSE] = IST("counter"),
[ST_F_CACHE_LOOKUPS] = IST("counter"),
[ST_F_CACHE_HITS] = IST("counter"),
[ST_F_QT_MAX] = IST("gauge"),
[ST_F_CT_MAX] = IST("gauge"),
[ST_F_RT_MAX] = IST("gauge"),
[ST_F_TT_MAX] = IST("gauge"),
};
/* Return the server status: 0=DOWN, 1=UP, 2=MAINT, 3=DRAIN, 4=NOLB. */
@ -1674,6 +1698,22 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
secs = (double)swrate_avg(px->be_counters.t_time, TIME_STATS_SAMPLES) / 1000.0;
metric = mkf_flt(FN_AVG, secs);
break;
case ST_F_QT_MAX:
secs = (double)px->be_counters.qtime_max / 1000.0;
metric = mkf_flt(FN_MAX, secs);
break;
case ST_F_CT_MAX:
secs = (double)px->be_counters.ctime_max / 1000.0;
metric = mkf_flt(FN_MAX, secs);
break;
case ST_F_RT_MAX:
secs = (double)px->be_counters.dtime_max / 1000.0;
metric = mkf_flt(FN_MAX, secs);
break;
case ST_F_TT_MAX:
secs = (double)px->be_counters.ttime_max / 1000.0;
metric = mkf_flt(FN_MAX, secs);
break;
case ST_F_DREQ:
metric = mkf_u64(FN_COUNTER, px->be_counters.denied_req);
break;
@ -1900,6 +1940,22 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
secs = (double)swrate_avg(sv->counters.t_time, TIME_STATS_SAMPLES) / 1000.0;
metric = mkf_flt(FN_AVG, secs);
break;
case ST_F_QT_MAX:
secs = (double)sv->counters.qtime_max / 1000.0;
metric = mkf_flt(FN_MAX, secs);
break;
case ST_F_CT_MAX:
secs = (double)sv->counters.ctime_max / 1000.0;
metric = mkf_flt(FN_MAX, secs);
break;
case ST_F_RT_MAX:
secs = (double)sv->counters.dtime_max / 1000.0;
metric = mkf_flt(FN_MAX, secs);
break;
case ST_F_TT_MAX:
secs = (double)sv->counters.ttime_max / 1000.0;
metric = mkf_flt(FN_MAX, secs);
break;
case ST_F_CONNECT:
metric = mkf_u64(FN_COUNTER, sv->counters.connect);
break;