Ferricstore.Metrics (ferricstore v0.3.7)

Copy Markdown View Source

Prometheus-compatible metrics exposition for FerricStore.

Collects server statistics from Ferricstore.Stats, Ferricstore.MemoryGuard, Ferricstore.SlowLog, and BEAM runtime sources, then formats them in the Prometheus text exposition format (version 0.0.4).

No external dependencies are required -- the module produces a plain UTF-8 string that any Prometheus-compatible scraper can consume.

Exposed metrics

Metric nameTypeSource
ferricstore_connected_clientsgaugeRanch listener connection count
ferricstore_total_connections_receivedcounterStats.total_connections/0
ferricstore_total_commands_processedcounterStats.total_commands/0
ferricstore_hot_reads_totalcounterStats.total_hot_reads/0
ferricstore_cold_reads_totalcounterStats.total_cold_reads/0
ferricstore_used_memory_bytesgauge:erlang.memory(:total)
ferricstore_keydir_used_bytesgaugeshard ETS table memory
ferricstore_uptime_secondsgaugeStats.uptime_seconds/0
ferricstore_blocked_clientsgaugewaiters ETS table size
ferricstore_tracking_clientsgaugetracking connections ETS size
ferricstore_slowlog_entriesgaugeSlowLog.len/0
ferricstore_namespace_window_msgaugeNamespaceConfig.get_all/0
ferricstore_namespace_durabilitygaugeNamespaceConfig.get_all/0

Usage

iex> text = Ferricstore.Metrics.scrape()
iex> String.contains?(text, "ferricstore_uptime_seconds")
true

The FERRICSTORE.METRICS Redis command returns this text as a bulk string.

Summary

Functions

Handles the FERRICSTORE.METRICS Redis command.

Produces a Prometheus text exposition format string containing all FerricStore metrics.

Types

metric_type()

@type metric_type() :: :counter | :gauge

Functions

handle(binary, arg2)

@spec handle(binary(), [binary()]) :: binary() | {:error, binary()}

Handles the FERRICSTORE.METRICS Redis command.

Returns the Prometheus text exposition as a bulk string. Accepts no arguments.

Parameters

  • cmd -- the uppercased command name ("FERRICSTORE.METRICS")
  • args -- argument list (must be empty)

Returns

The scrape text on success, or {:error, message} for wrong arguments.

scrape()

@spec scrape() :: binary()

Produces a Prometheus text exposition format string containing all FerricStore metrics.

Each metric includes a # HELP line describing its purpose, a # TYPE line declaring its Prometheus type, and a sample line with the current value.

Returns

A UTF-8 binary string in Prometheus text exposition format.

Examples

iex> text = Ferricstore.Metrics.scrape()
iex> text |> String.split("\n") |> Enum.count(&String.starts_with?(&1, "# HELP")) >= 11
true