We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
prom_ex
1 parent 468b821 commit 9d4afc7Copy full SHA for 9d4afc7
config/runtime.exs
@@ -358,6 +358,18 @@ if System.get_env("SENTRY_DSN_URL") do
358
before_send: {NervesHubWeb.SentryEventFilter, :filter_non_500}
359
end
360
361
+if System.get_env("GRAFANA_HOST") do
362
+ config :nerves_hub, NervesHub.PromEx,
363
+ manual_metrics_start_delay: :no_delay,
364
+ grafana: [
365
+ host: System.get_env("GRAFANA_HOST"),
366
+ auth_token: System.get_env("GRAFANA_TOKEN") || raise("GRAFANA_TOKEN is required"),
367
+ upload_dashboards_on_start: true,
368
+ folder_name: "NervesHub App Dashboards",
369
+ annotate_app_lifecycle: true
370
+ ]
371
+end
372
+
373
config :nerves_hub, :statsd,
374
host: System.get_env("STATSD_HOST", "localhost"),
375
port: String.to_integer(System.get_env("STATSD_PORT", "8125"))
lib/nerves_hub/application.ex
@@ -39,7 +39,10 @@ defmodule NervesHub.Application do
39
{Oban, Application.fetch_env!(:nerves_hub, Oban)}
40
] ++
41
deployments_supervisor(deploy_env()) ++
42
- endpoints(deploy_env())
+ endpoints(deploy_env()) ++
43
+ [
44
+ NervesHub.PromEx
45
46
47
opts = [strategy: :one_for_one, name: NervesHub.Supervisor]
48
Supervisor.start_link(children, opts)
lib/nerves_hub/prom_ex.ex
@@ -0,0 +1,38 @@
1
+defmodule NervesHub.PromEx do
2
+ use PromEx, otp_app: :nerves_hub
3
4
+ alias PromEx.Plugins
5
6
+ @impl true
7
+ def plugins do
8
9
+ # PromEx built in plugins
10
+ Plugins.Application,
11
+ Plugins.Beam,
12
+ {Plugins.Phoenix, router: NervesHubWeb.Router},
13
+ Plugins.PhoenixLiveView,
14
+ Plugins.Ecto,
15
+ Plugins.Oban
16
17
+ end
18
19
20
+ def dashboard_assigns do
21
22
+ datasource_id: "prometheus"
23
24
25
26
27
+ def dashboards do
28
29
+ # PromEx built in Grafana dashboards
30
+ {:prom_ex, "application.json"},
31
+ {:prom_ex, "beam.json"},
32
+ {:prom_ex, "phoenix.json"},
33
+ {:prom_ex, "phoenix_live_view.json"},
34
+ {:prom_ex, "ecto.json"},
35
+ {:prom_ex, "oban.json"}
36
37
38
lib/nerves_hub_web/device_endpoint.ex
@@ -33,6 +33,8 @@ defmodule NervesHubWeb.DeviceEndpoint do
plug(NervesHubWeb.Plugs.ImAlive)
+ plug(PromEx.Plug, prom_ex_module: NervesHub.PromEx)
plug(Sentry.PlugContext)
plug(NervesHubWeb.Plugs.Logger)
lib/nerves_hub_web/endpoint.ex
@@ -60,6 +60,8 @@ defmodule NervesHubWeb.Endpoint do
60
cookie_key: "request_logger"
61
)
62
63
64
65
plug(Plug.RequestId)
66
plug(Plug.Telemetry, event_prefix: [:phoenix, :endpoint])
67
mix.exs
@@ -95,16 +95,17 @@ defmodule NervesHub.MixProject do
95
{:phoenix_pubsub, "~> 2.0"},
96
{:phoenix_swoosh, "~> 1.0"},
97
{:phoenix_view, "~> 2.0"},
98
- {:phoenix_test, "~> 0.3.0", only: :test, runtime: false},
+ {:phoenix_test, "0.3.1", only: :test, runtime: false},
99
{:plug, "~> 1.7"},
100
{:postgrex, "~> 0.14"},
101
+ {:prom_ex, "~> 1.10"},
102
{:scrivener_ecto, "~> 2.7"},
103
{:scrivener_html, git: "https://github.com/nerves-hub/scrivener_html", branch: "phx-1.5"},
104
{:sentry, "~> 10.0"},
105
{:slipstream, "~> 1.0", only: [:test, :dev]},
106
{:sweet_xml, "~> 0.6"},
107
{:swoosh, "~> 1.12"},
- {:telemetry_metrics, "~> 0.4"},
108
+ {:telemetry_metrics, "~> 1.0"},
109
{:telemetry_metrics_statsd, "~> 0.7.0"},
110
{:telemetry_poller, "~> 1.0"},
111
{:timex, "~> 3.1"},
mix.lock
0 commit comments