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
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










Showing Posts 1 to 1- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (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