Track HTTP bandwidth


In the context of an embedded Elixir project (with a raspberry plugged to a 4G router), I’d like my application to track HTTP upload and download traffic (and then break it down regarding of my business).

Do you folks have any idea of how I should proceed?



You could start by parsing /proc/net/dev to get some simple information about the entire system.

After that you could possibly look at /proc/$PID/net/dev for information about a specific operating system process.

1 Like

Thanks for this idea!
Any idea involving only elixir code? such as tweaking my HTTP client (HTTPotion, Tesla or whatever …)


:hackney comes with some metrics which are disabled by default, but even then they only show request count / time spent. You might be able to wrap the http functions and read the size of request and response bodies there … but that wouldn’t account for headers.

defmodule MeteredHTTP do
  use HTTPoison.Base

  def process_request_body(body) do

  def process_response_body(body) do

  # etc, maybe for headers as well

Thanks, it the best lead I have for now.
Maybe I should track data at the TCP level to get something even more accurate

1 Like