Expose Port IO stats via Prometheus
This commit is contained in:
parent
ad92e504d7
commit
fb3de8045a
1 changed files with 12 additions and 2 deletions
|
@ -208,8 +208,10 @@ defp summary_fallback_metrics(byte_unit \\ :byte) do
|
||||||
dist_metrics ++ vm_metrics
|
dist_metrics ++ vm_metrics
|
||||||
end
|
end
|
||||||
|
|
||||||
defp common_metrics do
|
defp common_metrics(byte_unit \\ :byte) do
|
||||||
[
|
[
|
||||||
|
last_value("vm.portio.in.total", unit: {:byte, byte_unit}),
|
||||||
|
last_value("vm.portio.out.total", unit: {:byte, byte_unit}),
|
||||||
last_value("pleroma.local_users.total"),
|
last_value("pleroma.local_users.total"),
|
||||||
last_value("pleroma.domains.total"),
|
last_value("pleroma.domains.total"),
|
||||||
last_value("pleroma.local_statuses.total"),
|
last_value("pleroma.local_statuses.total"),
|
||||||
|
@ -220,14 +222,22 @@ defp common_metrics do
|
||||||
def prometheus_metrics,
|
def prometheus_metrics,
|
||||||
do: common_metrics() ++ distribution_metrics() ++ summary_fallback_metrics()
|
do: common_metrics() ++ distribution_metrics() ++ summary_fallback_metrics()
|
||||||
|
|
||||||
def live_dashboard_metrics, do: common_metrics() ++ summary_metrics(:megabyte)
|
def live_dashboard_metrics, do: common_metrics(:megabyte) ++ summary_metrics(:megabyte)
|
||||||
|
|
||||||
defp periodic_measurements do
|
defp periodic_measurements do
|
||||||
[
|
[
|
||||||
|
{__MODULE__, :io_stats, []},
|
||||||
{__MODULE__, :instance_stats, []}
|
{__MODULE__, :instance_stats, []}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def io_stats do
|
||||||
|
# All IO done via erlang ports, i.e. mostly network but also e.g. fasthtml_workers. NOT disk IO!
|
||||||
|
{{:input, input}, {:output, output}} = :erlang.statistics(:io)
|
||||||
|
:telemetry.execute([:vm, :portio, :in], %{total: input}, %{})
|
||||||
|
:telemetry.execute([:vm, :portio, :out], %{total: output}, %{})
|
||||||
|
end
|
||||||
|
|
||||||
def instance_stats do
|
def instance_stats do
|
||||||
stats = Stats.get_stats()
|
stats = Stats.get_stats()
|
||||||
:telemetry.execute([:pleroma, :local_users], %{total: stats.user_count}, %{})
|
:telemetry.execute([:pleroma, :local_users], %{total: stats.user_count}, %{})
|
||||||
|
|
Loading…
Reference in a new issue