Anyone running (or wanting to run) Live Dashboard in prod, I'd like to help you with custom metrics/history!

So I did some work on getting metrics/telemetry history into Live Dashboard (here) and I have it working well locally for my company’s production app, but I don’t have any internal use case or mandate for some of the more complex charting that LiveDashboard can provide.

I’ve already made code changes based on the feedback (passing entire metric instead of just metric name to the hook), but José has also asked for more real world data/example implementation to improve this PR, and unless I’m missing something or one of you would like to help me gather it from your applications, I’m not sure what to do next! One idea I have is PRing some telemetry and my LiveDashboard fork into https://github.com/thechangelog/changelog.com (if anyone knows Jerod Santo or Cody James or others involved in it, I know of it but am not involved in the community), or maybe @doomspork is interested in me helping to add it to https://elixir-companies.com/ (It’s alwesome you guys opened up your LiveDashboard to anyone logged in Sean!). Currently they don’t have any custom metrics up there, but the hook will work for any Metrics, including Ecto, Phoenix or VM metrics, so that a visitor would have some data load in the charts immediately! I think since that’s already public facing that might be one of the best use cases if Sean is open to it, and since it’s already open source at https://github.com/beam-community/elixir-companies I could just hop in and open a PR, but want someone to be open to it first, and this seemed like the best place to find someone interested in helping to prove it out with me!

Let me know if interested, or share alternative thoughts/ideas. I can also demo running historical_data fork dashboard running from my computer for anyone who wants to see what I mean via an ngrok link if there’s any confusion. Thanks!

8 Likes

Howdy @bglusman! Heck yeah you can implement custom metrics within the project. I want this to be a production playground for the community to explore LiveDashboard. It’s even cooler that you’ll be doing this to help improve the functionality for everyone too :tada:

What can I do to help? @SophieDeBenedetto and @gemantzu are both the LiveView gurus that help me with these projects, I’m sure they too would be happy to help.

1 Like

Awesome, mostly wanted buy in before I started a PR. And to be clear, though I’m happy to add some custom metrics, I’d need someone who knows the project to suggest what custom metrics you might like, or direction to explore/suggest in… My first change would be to use my forked version of LiveDashboard so we can send history on any new or existing metrics on initial dashboard load, probably just a few minutes/a few hundred ticks of history. I think one of José’s big concerns is practical memory consumption of any historical storage solution, so I’ll play a bit with trying to minimize the size of what we store perhaps, not sure.

I don’t know anything about existing telemetry emitted by LiveView itself (quick look makes me think all telemetry emission in Phx and LiveView is happening via the generated/user modified Telemetry.Metrics and/or :telemetry_poller as I don’t see any literal :telemetry.execute calls in Phoenix or LiveView, but maybe I’m missing something) perhaps that’s a good use case for some custom metrics (maybe even let the dashboard give some insight into itself!), I know LiveDashboard itself isn’t emitting any telemetry, but assume LiveView might be. Glad you’re on board, and would love any input from Sophie and/or George!

I forked the elixir-companies repo and have the app running locally… will generally try and update here I suppose for anyone following along etc. Never used ueberauth before so not sure best way to use fake or real github login locally, but may just hack around it for dev purposes, TBD.

1 Like

OK, I did some work on my lunch break and I have functional (but also wrong) historical repo stats “working” in my elixir-companies fork here https://github.com/bglusman/elixir-companies

I think the next step is to save metadata/config of the telemetry events for when replaying them, and I guess support driving multiple metrics from a single telemetry event. As for custom metrics, my guess is maybe just some simple stats on numbers of visitors on different pages or something, but open to other ideas. If anyone wants to play around or help out/make suggestions, always welcome!

By the way, locally I’m just removing :auth from the pipe_through in router.ex so that no auth is required for dashboard, and clicking around to generate Repo queries. As I said, it’s storing and playing back real data at the moment, but it’s losing the unit type data at least. I’m also curious if anyone has ideas for how to do this without having to sort of alias/rewire the original events through a kind of alias, I have one thought but it’s half-baked, so, dunno.

1 Like

Had a great NYC Elixir Meetup last night with a lot of folks interested in the history feature (and it was a perfect presentation from @SophieDeBenedetto talking about telemety and LiveDashboard which was really great, and a great lead in to talking about it this stuff with everyone else afterards, thanks again Sophie! She shared her slides after but I’ll let her decide if she wants to share here/elsewhere in the forum).

I tried to simplify my first attempt at history for the companies repo in elixir-companies today and I think this is much closer to a workable v1, with some light logic living inside the hook for interpreting data sent from history source. Right now it’s not erroring, and the history is being stored, though something seems to have broken the JS chart receiving/updating the initial history properly, though live metrics are coming in fine… both repos are updated, so I’m taking a break but if anyone want to help me rubber duck it love to schedule some time soon! cc @fhunleth @doomspork

2 Likes

Quick update that the PR to elixir-companies master is open here https://github.com/beam-community/elixir-companies/pull/613 for anyone interested in giving feedback!

(Note, I have not updated docs yet in my phx_live_dashboard fork, so the implementations in elixir-companies PR are more current/correct and at some point when this is stabilized I’ll update docs in my fork before PR to phx_live_dashboard upstream)

1 Like

Feel a little silly/funny updating here without anyone else commenting, but https://github.com/bglusman/phoenix_live_dashboard/tree/historical_data has updated code and docs, including integration with dev version of dahsboard I hadn’t noticed initially, so if you checkout my fork on git, and check out the historical_data branch, you can try out live_history feature by starting HISTORICAL_DATA=true mix dev and the VM metrics page will show you history for up to 50 events when navigating to the page. Hopefully this also helps address José’s concern over memory increase from the feature. The PR is still sitting in review at elixir-companies but I’ll update it so that one has memory history also later today.

4 Likes

Forgot to post here, the PR is merged into github.com/beam-community/elixir-companies and anyone willing to auth via github at https://elixir-companies.com/en and then visit https://elixir-companies.com/dashboard can go to metrics tab and see history on 3 of the 4 tabs… there is one small issue pending where the chart doesn’t render right until the first datapoint comes in AFTER the history, which on VM and Companies tab happens almost right away, but on PageViews tab you may need to go hit the indexes they measure once or something to see proper rendering… I suspect some kind of JS race condition or timing sensitivity, but if anyone has ideas/wants to help chase that down help would be welcome!

1 Like