Skip to content

Commit

Permalink
MINOR: contrib/prometheus-exporter: Rename some metrics to be more us…
Browse files Browse the repository at this point in the history
…able

Some metrics have been renamed and their type adapted to be more usable in
Prometheus:

  * haproxy_process_uptime_seconds -> haproxy_process_start_time_seconds
  * haproxy_process_max_memory -> haproxy_process_max_memory_bytes
  * haproxy_process_pool_allocated_total -> haproxy_process_pool_allocated_bytes
  * haproxy_process_pool_used_total -> haproxy_process_pool_used_bytes
  * haproxy_process_ssl_cache_lookups -> haproxy_process_ssl_cache_lookups_total
  * haproxy_process_ssl_cache_misses -> haproxy_process_ssl_cache_misses_total

No backport needed. See issue #81 on github.
  • Loading branch information
capflam committed Apr 18, 2019
1 parent c58fc0d commit 8c8e4b1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions contrib/prometheus-exporter/README
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ Exported metrics
| haproxy_process_nbthread | Configured number of threads. |
| haproxy_process_nbproc | Configured number of processes. |

This comment has been minimized.

Copy link
@brian-brazil

brian-brazil Apr 18, 2019

You can spell this out if you want.

| haproxy_process_relative_process_id | Relative process id, starting at 1. |
| haproxy_process_uptime_seconds | Uptime in seconds. |
| haproxy_process_max_memory | Per-process memory limit (in MB); 0=unset. |
| haproxy_process_pool_allocated_total | Total amount of memory allocated in pools (in MB). |
| haproxy_process_pool_used_total | Total amount of memory used in pools (in MB). |
| haproxy_process_start_time_seconds | Start time in seconds. |

This comment has been minimized.

Copy link
@brian-brazil

brian-brazil Apr 18, 2019

Just process_start_time_seconds, presuming you're following https://prometheus.io/docs/instrumenting/writing_clientlibs/#process-metrics

You can also remove process from the others, unless they're part of the standard exports above. (See HAProxy mention in https://prometheus.io/docs/instrumenting/writing_exporters/#naming)

| haproxy_process_max_memory_bytes | Per-process memory limit (in bytes); 0=unset. |

This comment has been minimized.

Copy link
@brian-brazil

brian-brazil Apr 18, 2019

haproxy_process_memory_limit_bytes would be clearer, "max" makes it sound like the highest value that has been seen

| haproxy_process_pool_allocated_bytes | Total amount of memory allocated in pools (in bytes). |
| haproxy_process_pool_used_bytes | Total amount of memory used in pools (in bytes). |
| haproxy_process_pool_failures_total | Total number of failed pool allocations. |
| haproxy_process_max_fds | Maximum number of open file descriptors; 0=unset. |
| haproxy_process_max_sockets | Maximum numer of open sockets. |
| haproxy_process_max_connections | Maximum number of concurrent connections. |

This comment has been minimized.

Copy link
@brian-brazil

brian-brazil Apr 18, 2019

connections_max (or _limit if it's a limit.)

| haproxy_process_hard_max_connections | Initial Maximum number of concurrent connections. |
| haproxy_process_current_connections | Number of active sessions. |
| haproxy_process_connections_total | Total number of terminated sessions. |
| haproxy_process_connections_total | Total number of created sessions. |
| haproxy_process_requests_total | Total number of requests (TCP or HTTP). |
| haproxy_process_max_ssl_connections | Configured maximum number of concurrent SSL connections. |
| haproxy_process_current_ssl_connections | Number of opened SSL connections. |
Expand All @@ -93,8 +93,8 @@ Exported metrics
| haproxy_process_frontent_ssl_reuse | SSL session reuse ratio (percent). |
| haproxy_process_current_backend_ssl_key_rate | Current backend SSL Key computation per second over last elapsed second. |
| haproxy_process_max_backend_ssl_key_rate | Maximum observed backend SSL Key computation per second. |
| haproxy_process_ssl_cache_lookups | Total number of SSL session cache lookups. |
| haproxy_process_ssl_cache_misses | Total number of SSL session cache misses. |
| haproxy_process_ssl_cache_lookups_total | Total number of SSL session cache lookups. |
| haproxy_process_ssl_cache_misses_total | Total number of SSL session cache misses. |
| haproxy_process_http_comp_bytes_in_total | Number of bytes per second over last elapsed second, before http compression. |

This comment has been minimized.

Copy link
@brian-brazil

brian-brazil Apr 18, 2019

in_bytes_total. The unit goes after the main metric name.

| haproxy_process_http_comp_bytes_out_total | Number of bytes per second over last elapsed second, after http compression. |
| haproxy_process_limit_http_comp | Configured maximum input compression rate in bytes. |
Expand Down
30 changes: 15 additions & 15 deletions contrib/prometheus-exporter/service-prometheus.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,10 @@ const struct ist promex_inf_metric_names[INF_TOTAL_FIELDS] = {
[INF_PROCESS_NUM] = IST("relative_process_id"),
[INF_PID] = IST("pid"),
[INF_UPTIME] = IST("uptime"),
[INF_UPTIME_SEC] = IST("uptime_seconds"),
[INF_MEMMAX_MB] = IST("max_memory"),
[INF_POOL_ALLOC_MB] = IST("pool_allocated_total"),
[INF_POOL_USED_MB] = IST("pool_used_total"),
[INF_UPTIME_SEC] = IST("start_time_seconds"),
[INF_MEMMAX_MB] = IST("max_memory_bytes"),
[INF_POOL_ALLOC_MB] = IST("pool_allocated_bytes"),
[INF_POOL_USED_MB] = IST("pool_used_bytes"),
[INF_POOL_FAILED] = IST("pool_failures_total"),
[INF_ULIMIT_N] = IST("max_fds"),
[INF_MAXSOCK] = IST("max_sockets"),
Expand Down Expand Up @@ -462,8 +462,8 @@ const struct ist promex_inf_metric_names[INF_TOTAL_FIELDS] = {
[INF_SSL_FRONTEND_SESSION_REUSE_PCT] = IST("frontent_ssl_reuse"),
[INF_SSL_BACKEND_KEY_RATE] = IST("current_backend_ssl_key_rate"),
[INF_SSL_BACKEND_MAX_KEY_RATE] = IST("max_backend_ssl_key_rate"),
[INF_SSL_CACHE_LOOKUPS] = IST("ssl_cache_lookups"),
[INF_SSL_CACHE_MISSES] = IST("ssl_cache_misses"),
[INF_SSL_CACHE_LOOKUPS] = IST("ssl_cache_lookups_total"),
[INF_SSL_CACHE_MISSES] = IST("ssl_cache_misses_total"),
[INF_COMPRESS_BPS_IN] = IST("http_comp_bytes_in_total"),
[INF_COMPRESS_BPS_OUT] = IST("http_comp_bytes_out_total"),
[INF_COMPRESS_BPS_RATE_LIM] = IST("limit_http_comp"),
Expand Down Expand Up @@ -586,17 +586,17 @@ const struct ist promex_inf_metric_desc[INF_TOTAL_FIELDS] = {
[INF_PROCESS_NUM] = IST("Relative process id, starting at 1."),
[INF_PID] = IST("HAProxy PID."),
[INF_UPTIME] = IST("Uptime in a human readable format."),
[INF_UPTIME_SEC] = IST("Uptime in seconds."),
[INF_MEMMAX_MB] = IST("Per-process memory limit (in MB); 0=unset."),
[INF_POOL_ALLOC_MB] = IST("Total amount of memory allocated in pools (in MB)."),
[INF_POOL_USED_MB] = IST("Total amount of memory used in pools (in MB)."),
[INF_UPTIME_SEC] = IST("Start time in seconds."),
[INF_MEMMAX_MB] = IST("Per-process memory limit (in bytes); 0=unset."),
[INF_POOL_ALLOC_MB] = IST("Total amount of memory allocated in pools (in bytes)."),
[INF_POOL_USED_MB] = IST("Total amount of memory used in pools (in bytes)."),
[INF_POOL_FAILED] = IST("Total number of failed pool allocations."),
[INF_ULIMIT_N] = IST("Maximum number of open file descriptors; 0=unset."),
[INF_MAXSOCK] = IST("Maximum numer of open sockets."),
[INF_MAXCONN] = IST("Maximum number of concurrent connections."),
[INF_HARD_MAXCONN] = IST("Initial Maximum number of concurrent connections."),
[INF_CURR_CONN] = IST("Number of active sessions."),
[INF_CUM_CONN] = IST("Total number of terminated sessions."),
[INF_CUM_CONN] = IST("Total number of created sessions."),
[INF_CUM_REQ] = IST("Total number of requests (TCP or HTTP)."),
[INF_MAX_SSL_CONNS] = IST("Configured maximum number of concurrent SSL connections."),
[INF_CURR_SSL_CONNS] = IST("Number of opened SSL connections."),
Expand Down Expand Up @@ -1240,16 +1240,16 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx)
metric = mkf_u32(FO_KEY, relative_pid);
break;
case INF_UPTIME_SEC:
metric = mkf_u32(FN_DURATION, (now.tv_sec - start_date.tv_sec));
metric = mkf_u32(FN_DURATION, start_date.tv_sec);
break;
case INF_MEMMAX_MB:
metric = mkf_u32(FO_CONFIG|FN_LIMIT, global.rlimit_memmax);
metric = mkf_u64(FO_CONFIG|FN_LIMIT, global.rlimit_memmax * 1048576L);
break;
case INF_POOL_ALLOC_MB:
metric = mkf_u32(0, (unsigned)(pool_total_allocated() / 1048576L));
metric = mkf_u64(0, pool_total_allocated());
break;
case INF_POOL_USED_MB:
metric = mkf_u32(0, (unsigned)(pool_total_used() / 1048576L));
metric = mkf_u64(0, pool_total_used());
break;
case INF_POOL_FAILED:
metric = mkf_u32(FN_COUNTER, pool_total_failures());
Expand Down

0 comments on commit 8c8e4b1

Please sign in to comment.