pharos/config

User-facing configuration for pharos.start_link.

Build a Config with new/0 (sensible defaults), pipe through the with_* setters to add statistics, thresholds, and tune the alert timing knobs, then pass it to pharos.start_link.

Types

Where pharos should route firing/resolved alert events. The Log sink is wired up by default. Process and Webhook are placeholders for future routing strategies (an OS message to a registered process, an HTTP webhook).

pub type AlertSink {
  Log(level: logging.LogLevel)
}

Constructors

pub type Config {
  Config(
    statistics: List(statistic.Statistic),
    thresholds: List(Threshold),
    custom_statistics: List(probe.Probe),
    custom_thresholds: List(probe.ProbeThreshold),
    alert_sinks: List(AlertSink),
    memory_unit: measurement.MemoryUnit,
    soak_period_ms: Int,
    cool_period_ms: Int,
    default_alert_level: alert.AlertLevel,
  )
}

Constructors

  • Config(
      statistics: List(statistic.Statistic),
      thresholds: List(Threshold),
      custom_statistics: List(probe.Probe),
      custom_thresholds: List(probe.ProbeThreshold),
      alert_sinks: List(AlertSink),
      memory_unit: measurement.MemoryUnit,
      soak_period_ms: Int,
      cool_period_ms: Int,
      default_alert_level: alert.AlertLevel,
    )

    Arguments

    statistics

    Statistics to poll, each with its own interval.

    thresholds

    Thresholds to evaluate on every matching measurement tick. An empty list means “observe only, never alert”.

    custom_statistics

    Custom probes to poll alongside the built-in statistics. The pluggable lane for signals pharos has no built-in StatisticKind for.

    custom_thresholds

    Thresholds evaluated against custom probe samples.

    alert_sinks

    Where to route firing/resolved alert events.

    memory_unit

    Unit for all memory threshold comparisons and decoded measurements.

    soak_period_ms

    Milliseconds a threshold must stay breached before an alert fires. Set to 0 to fire immediately without a soak period.

    cool_period_ms

    Milliseconds recovery must hold before a firing alert resolves.

    default_alert_level

    Default severity level attached to firing alerts.

pub type Threshold {
  TotalMemory(above: Float)
  ProcessMemory(above: Float)
  SystemMemory(above: Float)
  BinaryMemory(above: Float)
  EtsMemory(above: Float)
  TotalRunQueue(above: Int)
  CpuRunQueue(above: Int)
  ProcessCount(above: Int)
  AtomCount(above: Int)
  PortCount(above: Int)
  PersistentTermCount(above: Int)
  PersistentTermMemory(above: Float)
}

Constructors

  • TotalMemory(above: Float)
  • ProcessMemory(above: Float)
  • SystemMemory(above: Float)
  • BinaryMemory(above: Float)
  • EtsMemory(above: Float)
  • TotalRunQueue(above: Int)
  • CpuRunQueue(above: Int)
  • ProcessCount(above: Int)
  • AtomCount(above: Int)
  • PortCount(above: Int)
  • PersistentTermCount(above: Int)
  • PersistentTermMemory(above: Float)

Values

pub fn new() -> Config

Sensible defaults: no statistics, no thresholds, log alerts at Warning, scale memory in Mb, 30 s soak, 60 s cool, default alert level Warning. Pipe through with_* setters to customise.

pub fn threshold_id(threshold: Threshold) -> String

Stable string id derived from a threshold variant. Used to register per-threshold alert managers under a deterministic name so they can be looked up after a restart.

pub fn with_alert_sinks(
  config: Config,
  sinks: List(AlertSink),
) -> Config

Set the alert sinks. Replaces any previously configured list.

pub fn with_cool_period(
  config: Config,
  milliseconds: Int,
) -> Config

Set the cool-down period (milliseconds recovery must hold before resolving).

pub fn with_custom_statistics(
  config: Config,
  probes: List(probe.Probe),
) -> Config

Set the custom probes to poll. Replaces any previously configured list.

pub fn with_custom_thresholds(
  config: Config,
  thresholds: List(probe.ProbeThreshold),
) -> Config

Set the custom probe thresholds. Replaces any previously configured list.

pub fn with_default_alert_level(
  config: Config,
  level: alert.AlertLevel,
) -> Config

Set the default alert level attached to firing alerts.

pub fn with_memory_unit(
  config: Config,
  unit: measurement.MemoryUnit,
) -> Config

Set the memory unit used for threshold comparisons and decoded measurements.

pub fn with_soak_period(
  config: Config,
  milliseconds: Int,
) -> Config

Set the soak period (milliseconds a threshold must stay breached before firing). Set to 0 to fire immediately.

pub fn with_statistics(
  config: Config,
  statistics: List(statistic.Statistic),
) -> Config

Set the statistics to poll. Replaces any previously configured list.

pub fn with_thresholds(
  config: Config,
  thresholds: List(Threshold),
) -> Config

Set the thresholds to evaluate. Replaces any previously configured list.

Search Document