ambareesha7
i need help on implementing metric-dashboard for distribution metrics,
checked live_dashboard but live_dashboard not supporting distribution at the movement
i’m a new joinee to my team and fairly new to Elixir
i tasked to develop distribution metric-dashboard
data coming from TelemetryMetricsPrometheus.Core at /metrics endpoint
i’m thinking to parse metrics data into maps or list and use some UI library to represent
- what is the best UI library to represent distribution metrics?
- what type of data structure these libraries need? if i wanted to parse data into some structure(maps, list, keyword-list)
- are there any examples to take references?
currently i’m trying this to parse data its half baked code though ![]()
i’m doing this on livebbok
defmodule P do
def data_within_curl(labels) do
labels
|> remove_string(~r/"/)
|> String.split(",")
|> Enum.reduce(%{}, fn match, acc ->
[key, val] = String.split(match, "=")
Map.put(acc, key, val)
end)
end
def remove_string(str, regex, replacement \\ "") do
Regex.replace(regex, str, replacement)
end
def check_for_help?(content), do: String.match?(content, ~r/HELP/)
def check_for_type?(content), do: String.match?(content, ~r/TYPE/)
def check_for_curly?(content), do: String.match?(content, ~r/{|}/)
def check_for_no_curly?(content), do: !String.match?(content, ~r/{|}/)
end
"""
# HELP app_name_self_repair_duration
# TYPE app_name_self_repair_duration gauge
app_name_self_repair_duration 0.15916584
# HELP app_name_db_duration
# TYPE app_name_db_duration histogram
app_name_db_duration_bucket{query="get_transaction",le="0.01"} 179807
app_name_db_duration_bucket{query="get_transaction",le="0.025"} 180397
app_name_db_duration_bucket{query="get_transaction",le="0.05"} 183557
app_name_db_duration_bucket{query="get_transaction",le="0.1"} 188560
app_name_db_duration_bucket{query="get_transaction",le="0.3"} 188692
app_name_db_duration_bucket{query="get_transaction",le="0.5"} 188695
app_name_db_duration_bucket{query="get_transaction",le="0.8"} 188695
app_name_db_duration_bucket{query="get_transaction",le="1"} 188695
app_name_db_duration_bucket{query="get_transaction",le="1.5"} 188695
app_name_db_duration_bucket{query="get_transaction",le="+Inf"} 188695
app_name_db_duration_sum{query="get_transaction"} 555.663747302
app_name_db_duration_count{query="get_transaction"} 188695
"""
|> String.split("\n")
|> Enum.reduce(%{}, fn line, acc ->
IO.puts(line)
IO.inspect(acc, label: "acc-map")
cond do
P.check_for_help?(line) ->
acc
P.check_for_type?(line) ->
[_, _, metric_name, type] = Regex.run(~r/(.*\s)(.*\s)(.*)/, line)
trim_trailing = String.trim_trailing(metric_name)
new_metric = Enum.join([trim_trailing, type], "_")
IO.puts(new_metric)
Map.update(acc, new_metric, [], fn val -> IO.puts(val) end)
P.check_for_curly?(line) ->
[_, metric_name, labels, value] = Regex.run(~r/(.*){(.*)}(.*)/, line)
labels_data = P.data_within_curl(labels)
IO.inspect(labels_data, label: "labels_data")
bucket_map = Map.merge(labels_data, %{"value" => value})
IO.inspect(bucket_map, label: "with curly")
Map.put_new(acc, metric_name, bucket_map)
P.check_for_no_curly?(line) ->
[_, metric_name, value] = Regex.run(~r/(.*\s)(.*)/, line)
Map.put_new(acc, metric_name, %{"value" => value})
IO.inspect(value, label: "no curly")
end
end)
any help or suggestions are greatly appreciated
thank you
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New
Other Trending Topics
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
ambareesha7
i came up with suitable solution after doing some research
parse the data and convert into JSON structure then use some charting libraries(EChart, Vega-lite) to present the data.
JSON structure:
so far i have coded this functions:
i’m trying these functions:
this is the output:
# HELP app_name_db_duration acc-map: [] acc-size: 0 # TYPE app_name_db_duration histogram acc-map: [%{"help" => "app_name_db_duration"}] acc-size: 1 app_name_db_duration_bucket{query="get_transaction",le="0.01"} 443481 acc-map: [%{"type" => "histogram"}, %{"help" => "app_name_db_duration"}] acc-size: 2 app_name_db_duration_bucket{query="get_transaction",le="0.025"} 447919 acc-map: [ %{ "metrics" => [ {%{"labels" => %{"handler" => "get_transaction", "method" => "query"}}, %{"buckets" => %{"0.01" => "443481"}}} ] }, %{"type" => "histogram"}, %{"help" => "app_name_db_duration"} ] acc-size: 3 app_name_db_duration_bucket{query="get_transaction",le="0.05"} 456449 acc-map: [ %{ "metrics" => [ {%{"labels" => %{"handler" => "get_transaction", "method" => "query"}}, %{"buckets" => %{"0.025" => "447919"}}} ] }, %{ "metrics" => [ {%{"labels" => %{"handler" => "get_transaction", "method" => "query"}}, %{"buckets" => %{"0.01" => "443481"}}} ] }, %{"type" => "histogram"}, %{"help" => "app_name_db_duration"} ]but the problem now is the label names and metrics names are repeating in every map
how can i tell to my functions, label names and metrics name not to take more than once
how can i take bucket numbers every time? and ignore labels