Liking cljdoc? Tell your friends :D

lb.metrics

Prometheus metrics export for the load balancer.

Provides an HTTP endpoint for Prometheus scraping with metrics:

  • lb_connections_active - Current active connections
  • lb_bytes_total - Bytes transferred (forward/reverse)
  • lb_packets_total - Packets transferred
  • lb_backend_health - Backend health status (0/1)
  • lb_health_check_latency_seconds - Health check latency histogram
  • lb_dns_resolution_status - DNS resolution status

Usage: ;; In configuration :settings {:metrics {:enabled true :port 9090 :path "/metrics"}}

;; Programmatic usage (metrics/start! {:port 9090}) (metrics/register-data-sources! {...}) (metrics/stop!)

Prometheus metrics export for the load balancer.

Provides an HTTP endpoint for Prometheus scraping with metrics:
- lb_connections_active - Current active connections
- lb_bytes_total - Bytes transferred (forward/reverse)
- lb_packets_total - Packets transferred
- lb_backend_health - Backend health status (0/1)
- lb_health_check_latency_seconds - Health check latency histogram
- lb_dns_resolution_status - DNS resolution status

Usage:
  ;; In configuration
  :settings {:metrics {:enabled true :port 9090 :path "/metrics"}}

  ;; Programmatic usage
  (metrics/start! {:port 9090})
  (metrics/register-data-sources! {...})
  (metrics/stop!)
raw docstring

clear-data-sources!clj

(clear-data-sources!)

Clear all registered data sources.

Clear all registered data sources.
sourceraw docstring

collect-metricsclj

(collect-metrics)

Collect all metrics and return as Prometheus text format.

This is what the /metrics endpoint returns.

Collect all metrics and return as Prometheus text format.

This is what the /metrics endpoint returns.
sourceraw docstring

get-statusclj

(get-status)

Get metrics server status.

Returns nil if not running, or map with :port, :path, :url if running.

Get metrics server status.

Returns nil if not running, or map with :port, :path, :url if running.
sourceraw docstring

histogram-statsclj

source

new-histogramclj

source

observe-histogramclj

source

record-health-check-latency!clj

(record-health-check-latency! proxy-name target-id latency-seconds)

Record a health check latency observation.

This should be called after each successful health check to build the latency histogram.

proxy-name: name of the proxy target-id: target identifier (e.g., "10.0.0.1:8080") latency-seconds: latency in seconds (NOT milliseconds)

Record a health check latency observation.

This should be called after each successful health check
to build the latency histogram.

proxy-name: name of the proxy
target-id: target identifier (e.g., "10.0.0.1:8080")
latency-seconds: latency in seconds (NOT milliseconds)
sourceraw docstring

register-data-sources!clj

(register-data-sources! sources)

Register data source functions for metric collection.

sources is a map with optional keys: :conntrack-fn - (fn [] connections) returns seq of Connection records :health-fn - (fn [] health-status) returns health status for all proxies :stats-fn - (fn [] stats) returns aggregated stats map :dns-fn - (fn [] dns-status) returns DNS status for all proxies

Example: (register-data-sources! {:conntrack-fn #(conntrack/get-all-connections conntrack-map) :health-fn #(health/get-all-status) :dns-fn #(dns/get-all-status)})

Register data source functions for metric collection.

sources is a map with optional keys:
  :conntrack-fn - (fn [] connections) returns seq of Connection records
  :health-fn    - (fn [] health-status) returns health status for all proxies
  :stats-fn     - (fn [] stats) returns aggregated stats map
  :dns-fn       - (fn [] dns-status) returns DNS status for all proxies

Example:
  (register-data-sources!
    {:conntrack-fn #(conntrack/get-all-connections conntrack-map)
     :health-fn #(health/get-all-status)
     :dns-fn #(dns/get-all-status)})
sourceraw docstring

reset-histograms!clj

(reset-histograms!)

Reset all histogram data.

Useful for testing or periodic reset if needed.

Reset all histogram data.

Useful for testing or periodic reset if needed.
sourceraw docstring

running?clj

(running?)

Check if metrics server is running.

Check if metrics server is running.
sourceraw docstring

start!clj

(start! config)

Start the metrics HTTP server.

config is a map with: :port - Port to listen on (default 9090) :path - Path for metrics endpoint (default "/metrics")

Returns true if started successfully.

Start the metrics HTTP server.

config is a map with:
  :port - Port to listen on (default 9090)
  :path - Path for metrics endpoint (default "/metrics")

Returns true if started successfully.
sourceraw docstring

stop!clj

(stop!)

Stop the metrics HTTP server.

Stop the metrics HTTP server.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close