diff --git a/.woodpecker/.release.yml b/.woodpecker/.release.yml index 18f206a6b..535cdd65b 100644 --- a/.woodpecker/.release.yml +++ b/.woodpecker/.release.yml @@ -37,8 +37,8 @@ pipeline: - *tag-build - mix deps.get --only prod - mix release --path release - - zip akkoma-${tag}.zip -r release - - rclone copyto akkoma-${tag}.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-${tag}.zip + - zip akkoma-amd64.zip -r release + - rclone copyto akkoma-amd64.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-amd64.zip musl: image: elixir:1.13-alpine @@ -55,5 +55,5 @@ pipeline: - *tag-build - mix deps.get --only prod - mix release --path release - - zip akkoma-${tag}.zip -r release - - rclone copyto akkoma-${tag}.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-${tag}-musl.zip + - zip akkoma-amd64.zip -r release + - rclone copyto akkoma-amd64.zip scaleway:akkoma-updates/$BUILD_TAG/akkoma-amd64-musl.zip diff --git a/CHANGELOG.md b/CHANGELOG.md index e3209cfcc..22644b03c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `/api/v1/statuses/{id}/card` - LDAP authenticator - Chats, they were half-baked. Just use PMs. +- Prometheus, it causes massive slowdown ## 2022.07 diff --git a/config/config.exs b/config/config.exs index 21247bbe5..0f0daf796 100644 --- a/config/config.exs +++ b/config/config.exs @@ -623,13 +623,6 @@ config :pleroma, Pleroma.Emails.UserEmail, config :pleroma, Pleroma.Emails.NewUsersDigestEmail, enabled: false -config :prometheus, Pleroma.Web.Endpoint.MetricsExporter, - enabled: false, - auth: false, - ip_whitelist: [], - path: "/api/pleroma/app_metrics", - format: :text - config :pleroma, Pleroma.ScheduledActivity, daily_user_limit: 25, total_user_limit: 300, diff --git a/config/description.exs b/config/description.exs index 910953a91..1eb0a4161 100644 --- a/config/description.exs +++ b/config/description.exs @@ -3024,43 +3024,6 @@ config :pleroma, :config_description, [ } ] }, - %{ - group: :prometheus, - key: Pleroma.Web.Endpoint.MetricsExporter, - type: :group, - description: "Prometheus app metrics endpoint configuration", - children: [ - %{ - key: :enabled, - type: :boolean, - description: "[Pleroma extension] Enables app metrics endpoint." - }, - %{ - key: :ip_whitelist, - label: "IP Whitelist", - type: [{:list, :string}, {:list, :charlist}, {:list, :tuple}], - description: "Restrict access of app metrics endpoint to the specified IP addresses." - }, - %{ - key: :auth, - type: [:boolean, :tuple], - description: "Enables HTTP Basic Auth for app metrics endpoint.", - suggestion: [false, {:basic, "myusername", "mypassword"}] - }, - %{ - key: :path, - type: :string, - description: "App metrics endpoint URI path.", - suggestions: ["/api/pleroma/app_metrics"] - }, - %{ - key: :format, - type: :atom, - description: "App metrics endpoint output format.", - suggestions: [:text, :protobuf] - } - ] - }, %{ group: :pleroma, key: ConcurrentLimiter, diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 6bda2e1d9..e29bf3ca3 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -53,7 +53,6 @@ defmodule Pleroma.Application do Config.DeprecationWarnings.warn() Pleroma.Web.Plugs.HTTPSecurityPlug.warn_if_disabled() Pleroma.ApplicationRequirements.verify!() - setup_instrumenters() load_custom_modules() Pleroma.Docs.JSON.compile() limiters_setup() @@ -143,29 +142,6 @@ defmodule Pleroma.Application do end end - defp setup_instrumenters do - require Prometheus.Registry - - if Application.get_env(:prometheus, Pleroma.Repo.Instrumenter) do - :ok = - :telemetry.attach( - "prometheus-ecto", - [:pleroma, :repo, :query], - &Pleroma.Repo.Instrumenter.handle_event/4, - %{} - ) - - Pleroma.Repo.Instrumenter.setup() - end - - Pleroma.Web.Endpoint.MetricsExporter.setup() - Pleroma.Web.Endpoint.PipelineInstrumenter.setup() - - # Note: disabled until prometheus-phx is integrated into prometheus-phoenix: - # Pleroma.Web.Endpoint.Instrumenter.setup() - PrometheusPhx.setup() - end - defp cachex_children do [ build_cachex("used_captcha", ttl_interval: seconds_valid_interval()), diff --git a/lib/pleroma/config/transfer_task.ex b/lib/pleroma/config/transfer_task.ex index a4dc92ee0..6a3184e6c 100644 --- a/lib/pleroma/config/transfer_task.ex +++ b/lib/pleroma/config/transfer_task.ex @@ -50,8 +50,7 @@ defmodule Pleroma.Config.TransferTask do started_applications = Application.started_applications() - # TODO: some problem with prometheus after restart! - reject = [nil, :prometheus, :postgrex] + reject = [nil, :postgrex] reject = if restart_pleroma? do diff --git a/lib/pleroma/repo.ex b/lib/pleroma/repo.ex index 61b64ed3e..1fca0fccb 100644 --- a/lib/pleroma/repo.ex +++ b/lib/pleroma/repo.ex @@ -11,8 +11,6 @@ defmodule Pleroma.Repo do import Ecto.Query require Logger - defmodule Instrumenter, do: use(Prometheus.EctoInstrumenter) - @doc """ Dynamically loads the repository url from the DATABASE_URL environment variable. diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index 2e7e9692e..6dd66a424 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -161,47 +161,6 @@ defmodule Pleroma.Web.Endpoint do plug(Pleroma.Web.Plugs.RemoteIp) - defmodule Instrumenter do - use Prometheus.PhoenixInstrumenter - end - - defmodule PipelineInstrumenter do - use Prometheus.PlugPipelineInstrumenter - end - - defmodule MetricsExporter do - use Prometheus.PlugExporter - end - - defmodule MetricsExporterCaller do - @behaviour Plug - - def init(opts), do: opts - - def call(conn, opts) do - prometheus_config = Application.get_env(:prometheus, MetricsExporter, []) - ip_whitelist = List.wrap(prometheus_config[:ip_whitelist]) - - cond do - !prometheus_config[:enabled] -> - conn - - ip_whitelist != [] and - !Enum.find(ip_whitelist, fn ip -> - Pleroma.Helpers.InetHelper.parse_address(ip) == {:ok, conn.remote_ip} - end) -> - conn - - true -> - MetricsExporter.call(conn, opts) - end - end - end - - plug(PipelineInstrumenter) - - plug(MetricsExporterCaller) - plug(Pleroma.Web.Router) @doc """ diff --git a/mix.exs b/mix.exs index a0eef4f1d..1e1c06b7b 100644 --- a/mix.exs +++ b/mix.exs @@ -163,18 +163,6 @@ defmodule Pleroma.Mixfile do {:http_signatures, "~> 0.1.1"}, {:telemetry, "~> 0.3"}, {:poolboy, "~> 1.5"}, - {:prometheus, "~> 4.6"}, - {:prometheus_ex, - git: "https://git.pleroma.social/pleroma/elixir-libraries/prometheus.ex.git", - ref: "a4e9beb3c1c479d14b352fd9d6dd7b1f6d7deee5", - override: true}, - {:prometheus_plugs, "~> 1.1"}, - {:prometheus_phoenix, "~> 1.3"}, - # Note: once `prometheus_phx` is integrated into `prometheus_phoenix`, remove the former: - {:prometheus_phx, - git: "https://git.pleroma.social/pleroma/elixir-libraries/prometheus-phx.git", - branch: "no-logging"}, - {:prometheus_ecto, "~> 1.4"}, {:recon, "~> 2.5"}, {:quack, "~> 0.1.1"}, {:joken, "~> 2.0"}, diff --git a/test/pleroma/web/endpoint/metrics_exporter_test.exs b/test/pleroma/web/endpoint/metrics_exporter_test.exs deleted file mode 100644 index 376e82149..000000000 --- a/test/pleroma/web/endpoint/metrics_exporter_test.exs +++ /dev/null @@ -1,69 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Pleroma.Web.Endpoint.MetricsExporterTest do - # Modifies AppEnv, has to stay synchronous - use Pleroma.Web.ConnCase - - alias Pleroma.Web.Endpoint.MetricsExporter - - defp config do - Application.get_env(:prometheus, MetricsExporter) - end - - describe "with default config" do - test "does NOT expose app metrics", %{conn: conn} do - conn - |> get(config()[:path]) - |> json_response(404) - end - end - - describe "when enabled" do - setup do - initial_config = config() - on_exit(fn -> Application.put_env(:prometheus, MetricsExporter, initial_config) end) - - Application.put_env( - :prometheus, - MetricsExporter, - Keyword.put(initial_config, :enabled, true) - ) - end - - test "serves app metrics", %{conn: conn} do - conn = get(conn, config()[:path]) - assert response = response(conn, 200) - - for metric <- [ - "http_requests_total", - "http_request_duration_microseconds", - "phoenix_controller_call_duration", - "telemetry_scrape_duration", - "erlang_vm_memory_atom_bytes_total" - ] do - assert response =~ ~r/#{metric}/ - end - end - - test "when IP whitelist configured, " <> - "serves app metrics only if client IP is whitelisted", - %{conn: conn} do - Application.put_env( - :prometheus, - MetricsExporter, - Keyword.put(config(), :ip_whitelist, ["127.127.127.127", {1, 1, 1, 1}, '255.255.255.255']) - ) - - conn - |> get(config()[:path]) - |> json_response(404) - - conn - |> Map.put(:remote_ip, {127, 127, 127, 127}) - |> get(config()[:path]) - |> response(200) - end - end -end