deadtrickster

deadtrickster

I’ve just released stable versions of my Prometheus Elixir libs:

Elixir client is based on Erlang client which exports dozens of metrics such as VM memory metrics, VM system info metrics, Mnesia metrics, etc.

For linux users there is also Process info collector.

I would be glad to answer any questions!

Showing Posts 21 to 12

iamMrGaurav

iamMrGaurav

@deadtrickster , does this give the same metrics as Erlang prometheus.io client?

deadtrickster

deadtrickster OP

Hi, it’s not particularly clear what library/protocol you are instrumenting

Hernan

Hernan

Hi @deadtrickster. Thanks for all replys.
I use your library, and i need to add label to all metrics. I need add ‘hostname’, and before the response, i set this value (in handler). My question is: exists one configuration for this?: add an label to all default_metrics.

Thanks!,

Hernán-

marat

marat

Hi @deadtrickster!
The problem with {:prometheus_phoenix, "~> 1.2.0"} was not only that 2 metrics were missing in docs. The problem was that until I used 1.2.1 version /metrics page wasn’t showing any data for phoenix.

marat

marat

@deadtrickster thank you for the answers!
I observe the changes on the /metrics page. Just now I left:

config :prometheus, AppWeb.PipelineInstrumenter,
  labels: [:status_class, :method, :host, :scheme, :request_path],
  duration_buckets: [10, 100, 1_000, 10_000, 100_000,
                     5_000_000, 10_000_000, 20_000_000, 30_000_000],

and the metrics still have:

 http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="10.0"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="100.0"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="1.0e3"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="1.0e4"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="1.0e5"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="3.0e5"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="5.0e5"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="7.5e5"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="1.0e6"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="1.5e6"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="2.0e6"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="3.0e6"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="5.0e6"} 0
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="1.0e7"} 1
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="2.0e7"} 1
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="3.0e7"} 1
http_request_duration_microseconds_bucket{status_class="success",method="GET",host="localhost",scheme="http",request_path="/",le="+Inf"} 1
http_request_duration_microseconds_count{status_class="success",method="GET",host="localhost",scheme="http",request_path="/"} 1

Another question, Q4:
I have a different Instrumenter which doesn’t get to /metrics page:

defmodule AppWeb.ExampleInstrumenter do
  use Prometheus.Metric

  @histogram [name: :http_request_duration_ms,
              labels: [:method],
              buckets: [100, 300, 500, 750, 1000],
              help: "Http Request execution time"]

  def instrument(%{time: time, method: method}) do
    Histogram.observe([name: :http_request_duration_ms, labels: [method]], time)
  end
end

It’s included to Endpoint Instrumenters:

config :app, AppWeb.Endpoint,
  instrumenters: [AppWeb.ExampleInstrumenter]

Where else should it go? The /metrics page doesn’t have http_request_duration_ms label.

Thanks again!

deadtrickster

deadtrickster OP

Q1: probably I forgot to update the docs, new metrics are for phoenix channels
Q2: because you can have different sets of labels for each instrumenter
Q3: where/how you observe the chnages?

marat

marat

Q1:
I’m using

      {:prometheus_ex, "~> 2.0"},
      {:prometheus_phoenix, "~> 1.2.0"},

and doc for GitHub - prometheus-erl/prometheus-phoenix at v1.2.0 · GitHub states that it has 2 metrics:

  • phoenix_controller_call_duration_microseconds - Whole controller pipeline execution time.
  • phoenix_controller_render_duration_microseconds - View rendering time.

Instead, the /metrics page shows me

# TYPE phoenix_controller_call_duration_microseconds histogram
# HELP phoenix_controller_call_duration_microseconds Whole controller pipeline execution time in microseconds.
# TYPE phoenix_controller_render_duration_microseconds histogram
# HELP phoenix_controller_render_duration_microseconds View rendering time in microseconds.
# TYPE phoenix_channel_receive_duration_microseconds histogram
# HELP phoenix_channel_receive_duration_microseconds Phoenix channel receive handler time in microseconds
# TYPE phoenix_channel_join_duration_microseconds histogram
# HELP phoenix_channel_join_duration_microseconds Phoenix channel join handler time in microseconds

Where do they come from? They have no values. After using prometheus_phoenix 1.2.1 metrics are the same but WITH values. Where does all that come from?

Q2:

my config for PhoenixInstrumenter:

config :prometheus, AppWeb.PhoenixInstrumenter,
  controller_call_labels: [:controller, :action],
  duration_buckets: [10, 25, 50, 100, 250, 500, 1000, 2500, 5000,
                     10_000, 25_000, 50_000, 100_000, 250_000, 500_000,
                     1_000_000, 2_500_000, 5_000_000, 10_000_000, 20_000_000, 30_000_000],
  registry: :default,
  duration_unit: :microseconds

Why the key is called controller_call_labels? Other sample configs have smth like

config :prometheus, AppWeb.PipelineInstrumenter,
  labels: [:status_class, :method, :host, :scheme, :request_path],

but not controller_call_labels. How is it set?

Q3:
If I add/remove values from duration_buckets: they change after a certain period of time. Are they cached somewhere?

Thanks ahead for the answers!

deadtrickster

deadtrickster OP

Starting from version 2.1 Cowboy has special metrics stream handler - cowboy/src/cowboy_metrics_h.erl at master · ninenines/cowboy · GitHub.
Prometheus cowboy integration uses this interface to directly instrument Cowboy now.

deadtrickster

deadtrickster OP

And don’t hesitate joining our prometheus channel on elixir-lang Slack team!

MartinElvar

MartinElvar

Cool thanks @orestis & @deadtrickster, appreciate it, gonna give it a try for our next project :smile:.

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
CodeSync
:microphone: ElixirConf 2026 - Call for Talks is open! We’re heading to Chicago :united_states: :round_pushpin: In person + virtual :d...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews