All Projects → gmtprime → extatus

gmtprime / extatus

Licence: MIT license
App to report metrics to Prometheus from Elixir GenServers

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to extatus

Exporter exporter
A reverse proxy designed for Prometheus exporters
Stars: ✭ 194 (+977.78%)
Mutual labels:  prometheus-exporter
Php Fpm exporter
A prometheus exporter for PHP-FPM.
Stars: ✭ 251 (+1294.44%)
Mutual labels:  prometheus-exporter
ha cluster exporter
Prometheus exporter for Pacemaker based Linux HA clusters
Stars: ✭ 63 (+250%)
Mutual labels:  prometheus-exporter
Aliyun Exporter
Prometheus exporter for Alibaba Cloud Monitor
Stars: ✭ 210 (+1066.67%)
Mutual labels:  prometheus-exporter
Collectd
The system statistics collection daemon. Please send Pull Requests here!
Stars: ✭ 2,700 (+14900%)
Mutual labels:  prometheus-exporter
mongodb-query-exporter
Prometheus MongoDB aggregation query exporter
Stars: ✭ 74 (+311.11%)
Mutual labels:  prometheus-exporter
Blackbox exporter
Blackbox prober exporter
Stars: ✭ 2,633 (+14527.78%)
Mutual labels:  prometheus-exporter
lustre exporter
Prometheus exporter for use with the Lustre parallel filesystem
Stars: ✭ 25 (+38.89%)
Mutual labels:  prometheus-exporter
Mikrotik Exporter
prometheus mikrotik device(s) exporter
Stars: ✭ 248 (+1277.78%)
Mutual labels:  prometheus-exporter
domain exporter
Prometheus WHOIS domain details exporter.
Stars: ✭ 73 (+305.56%)
Mutual labels:  prometheus-exporter
Ssl exporter
Exports Prometheus metrics for SSL certificates
Stars: ✭ 211 (+1072.22%)
Mutual labels:  prometheus-exporter
Github Exporter
Prometheus exporter for github metrics
Stars: ✭ 231 (+1183.33%)
Mutual labels:  prometheus-exporter
github releases exporter
Exports GitHub release metrics to the Prometheus format
Stars: ✭ 21 (+16.67%)
Mutual labels:  prometheus-exporter
Oracledb exporter
Prometheus Oracle database exporter.
Stars: ✭ 209 (+1061.11%)
Mutual labels:  prometheus-exporter
fortigate exporter
Prometheus exporter for Fortigate firewalls
Stars: ✭ 133 (+638.89%)
Mutual labels:  prometheus-exporter
Sql exporter
Flexible SQL Exporter for Prometheus
Stars: ✭ 194 (+977.78%)
Mutual labels:  prometheus-exporter
ansible-snmp-exporter
Provision SNMP metrics exporter for prometheus monitoring
Stars: ✭ 18 (+0%)
Mutual labels:  prometheus-exporter
enviroplus exporter
Prometheus exporter for enviroplus module by Pimoroni
Stars: ✭ 70 (+288.89%)
Mutual labels:  prometheus-exporter
ansitheus
Ansible playbook - Containerize, configure and deploy Prometheus ecosystem
Stars: ✭ 19 (+5.56%)
Mutual labels:  prometheus-exporter
OctoPrint-Prometheus-Exporter
An octoprint plugin for prometheus compatible metrics endpoint
Stars: ✭ 36 (+100%)
Mutual labels:  prometheus-exporter

Extatus

Build Status Hex pm hex.pm downloads

Extatus is an application that reports metrics to Prometheus via the HTTP endpoint /metrics from an instrumented GenServer.

Small Example

The following is an uninstrumented GenServer that tracks its uptime.

defmodule Uninstrumented do
  use GenServer

  def start_link do
    GenServer.start_link(__MODULE__, nil)
  end

  def get_uptime(pid) do
    GenServer.call(pid, :uptime)
  end

  def init(_) do
    start_time = :os.system_time(:seconds)
    {:ok, seconds}
  end

  def handle_call(:uptime, _from, start_time) do
    uptime = :os.system_time(:seconds) - start_time
    {:reply, uptime, start_time}
  end
end

If we would want to track the uptime of this process in Prometheus with Extatus, we would need:

  1. use Extatus.Process behaviour.
  2. Declare a gauge metric to track the uptime e.g. a metric called :uptime with a label for the module name.
  3. Implement the function get_name/1 that receives the GenServer process state and returns the name of the process. This name must be unique.
  4. Implement the function report/1 that receives the GenServer process state. In this function, you can report the metrics.
  5. Start the Extatus watchdog for your process in the init/1 function by adding the function add_extatus_watchdog/0 (included by use Extatus.Process).
defmodule Instrumented do
  use GenServer
  use Extatus.Process # Extatus behaviour

  def start_link do
    GenServer.start_link(__MODULE__, nil)
  end

  # Metric declaration
  defmetrics do
    gauge :uptime do
      label :module
      help "Uptime gauge"
    end
  end

  # Name of the process. This must be unique.
  def get_name(_state) do
    {:ok, Atom.to_string(__MODULE__)}
  end

  # Report function
  def report(start_time) do
    uptime = :os.system_time(:seconds) - start_time
    Gauge.set(:uptime, [module: Atom.to_string(__MODULE__)], uptime)
  end

  def init(_) do
    :ok = add_extatus_watchdog() # Add extatus watchdog
    {:ok, :os.system_time(:seconds)}
  end
end

The HTTP /metric endpoint is implemented in :cowboy and the output is provided by the library :prometheus_ex. If you start this process, you will see the metric :uptime being reported.

Additionally, for every instrumented GenServer process, extatus reports the metric :extatus_process_activity (gauge). This metric indicates that a process is up (2), down (0) or idle (1) depending on its value.

Extatus uses Yggdrasil to report the status of the processes in the following channel:

%Yggdrasil.Channel{name: :extatus}

This can be used to get the updates on the current state of the processes in a subscriber e.g:

iex> chan = %Yggdrasil.Channel{name: :extatus}
iex> Yggdrasil.subscribe(chan)
iex> flush()
{:Y_CONNECTED, (...)}
iex> {:ok, _} = Instrumented.start_link()
{:ok, #PID<0.603.0>}
iex> flush()
{:Y_EVENT, _, %Extatus.Message{name: "instrumented_process", state: :up}}

Configuration

The following are the configuration arguments available:

  • :timeout - Frequency the handlers get the metrics from the processes.
  • :port - Port where cowboy is listening to request coming from Prometheus.
  • :prometheus_registry - Prometheus registry. By default is :default.

e.g:

config :extatus,
  timeout: 5000,
  port: 1337,
  prometheus_registry: :test

Installation

If available in Hex, the package can be installed as:

  1. Add extatus to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:extatus, "~> 0.2"}]
end
```
  1. Ensure extatus is started before your application:
```elixir
def application do
  [applications: [:extatus]]
end
```
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].