From 721fece9ba79a9e2d16984400afc976ab8a7cac0 Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Thu, 9 Jan 2025 11:36:18 -0800 Subject: [PATCH] Added basic prometheus config --- config/config.exs | 12 ++---------- config/dev.exs | 2 ++ config/runtime.exs | 3 +++ lib/pinchflat/prom_ex.ex | 4 ++-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/config/config.exs b/config/config.exs index 94282c4..7b8d29a 100644 --- a/config/config.exs +++ b/config/config.exs @@ -100,18 +100,10 @@ config :logger, :default_formatter, config :phoenix, :json_library, Jason config :pinchflat, Pinchflat.PromEx, - disabled: false, + disabled: true, manual_metrics_start_delay: :no_delay, drop_metrics_groups: [], - metrics_server: :disabled, - grafana: [ - host: System.get_env("GRAFANA_CLOUD_URL", "http://192.168.1.170:3033"), - username: System.get_env("GRAFANA_USERNAME", "admin"), - password: System.get_env("GRAFANA_PASSWORD", "admin"), - # This is an optional setting and will default to `true` - folder_name: "zero-to-graphql-using-elixir", - upload_dashboards_on_start: true - ] + metrics_server: :disabled # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. diff --git a/config/dev.exs b/config/dev.exs index 771f5c1..8b9b793 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -81,3 +81,5 @@ config :phoenix_live_view, :debug_heex_annotations, true # Disable swoosh api client as it is only required for production adapters. config :swoosh, :api_client, false + +config :pinchflat, Pinchflat.PromEx, disabled: false diff --git a/config/runtime.exs b/config/runtime.exs index afce572..df8ef50 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -72,6 +72,7 @@ if config_env() == :prod do # For running PF in a subdirectory via a reverse proxy base_route_path = System.get_env("BASE_ROUTE_PATH", "/") enable_ipv6 = String.length(System.get_env("ENABLE_IPV6", "")) > 0 + enable_prometheus = String.length(System.get_env("ENABLE_PROMETHEUS", "")) > 0 config :logger, level: String.to_existing_atom(System.get_env("LOG_LEVEL", "debug")) @@ -95,6 +96,8 @@ if config_env() == :prod do database: db_path, journal_mode: journal_mode + config :pinchflat, Pinchflat.PromEx, disabled: !enable_prometheus + # The secret key base is used to sign/encrypt cookies and other secrets. # A default value is used in config/dev.exs and config/test.exs but you # want to use a different value for prod and you most likely don't want diff --git a/lib/pinchflat/prom_ex.ex b/lib/pinchflat/prom_ex.ex index 2dd65a4..fd7bcba 100644 --- a/lib/pinchflat/prom_ex.ex +++ b/lib/pinchflat/prom_ex.ex @@ -21,7 +21,7 @@ defmodule Pinchflat.PromEx do ``` def start(_type, _args) do children = [ - Pinchflat.PromEx, + Pinchflat.PromEx,P ... ] @@ -71,7 +71,7 @@ defmodule Pinchflat.PromEx do @impl true def dashboard_assigns do [ - datasource_id: "prometheus", + # datasource_id: "prometheus", default_selected_interval: "30s" ] end