Browse Source

Prometheus exporter

pull/7/head
Victor Roest 2 years ago
parent
commit
38848a7e10
Signed by: 0x76 GPG Key ID: A3923C699D1A3BDA
  1. 1
      k8s/deployment.yml
  2. 2
      k8s/svc.yml
  3. 6
      lib/dps_web/router.ex
  4. 7
      lib/dps_web/telemetry.ex
  5. 1
      mix.exs
  6. 2
      mix.lock

1
k8s/deployment.yml

@ -26,6 +26,7 @@ spec:
image: dps:latest
ports:
- containerPort: 4000
- containerPort: 9568
env:
- name: LANG
value: C.UTF-8

2
k8s/svc.yml

@ -18,5 +18,7 @@ spec:
ports:
- name: http
port: 4000
- name: metrics
port: 9568
selector:
app: dps

6
lib/dps_web/router.ex

@ -20,8 +20,7 @@ defmodule DpsWeb.Router do
# Authenticated Browser pages
scope "/", DpsWeb do
pipe_through :browser
pipe_through :auth
pipe_through [:browser, :auth]
get "/authors/new", AuthorPageController, :new
post "/authors/new", AuthorPageController, :create
@ -57,8 +56,7 @@ defmodule DpsWeb.Router do
# Authenticated api
scope "/api", DpsWeb do
pipe_through :api
pipe_through :auth
pipe_through [:api, :auth]
post "/authors", AuthorController, :create
post "/poems", PoemController, :create

7
lib/dps_web/telemetry.ex

@ -11,9 +11,10 @@ defmodule DpsWeb.Telemetry do
children = [
# Telemetry poller will execute the given period measurements
# every 10_000ms. Learn more here: https://hexdocs.pm/telemetry_metrics
{:telemetry_poller, measurements: periodic_measurements(), period: 10_000}
# Add reporters as children of your supervision tree.
# {Telemetry.Metrics.ConsoleReporter, metrics: custom_metrics()}
{:telemetry_poller, measurements: periodic_measurements(), period: 10_000},
# Add reporters as children of your supervision tree
{TelemetryMetricsPrometheus, [metrics: metrics()]},
# {Telemetry.Metrics.ConsoleReporter, metrics: custom_metrics()},
]
Supervisor.init(children, strategy: :one_for_one)

1
mix.exs

@ -43,6 +43,7 @@ defmodule Dps.MixProject do
{:phoenix_live_dashboard, "~> 0.4"},
{:telemetry_metrics, "~> 0.4"},
{:telemetry_poller, "~> 0.4"},
{:telemetry_metrics_prometheus, "~> 0.6.0"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},
{:peerage, "~> 1.0"},

2
mix.lock

@ -30,5 +30,7 @@
"table_rex": {:hex, :table_rex, "3.0.0", "5189b71b3b92ed461358f40f7b7b630dc37716bf6c8ab3e934b2bc63a99028bd", [:mix], [], "hexpm", "582776d24cbe6a4d30a39a7f02035b1bc979b6cd64923d7234dd2f0ad21a18c7"},
"telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.0", "da9d49ee7e6bb1c259d36ce6539cd45ae14d81247a2b0c90edf55e2b50507f7b", [:mix], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5cfe67ad464b243835512aa44321cee91faed6ea868d7fb761d7016e02915c3d"},
"telemetry_metrics_prometheus": {:hex, :telemetry_metrics_prometheus, "0.6.0", "04148a77a1ab1d46d899627f6ecca8005477ae620b1a81116dce2eaeb4a3bff8", [:mix], [{:plug_cowboy, "~> 2.1", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:telemetry_metrics_prometheus_core, "~> 0.4", [hex: :telemetry_metrics_prometheus_core, repo: "hexpm", optional: false]}], "hexpm", "b26be99ee4f977635f4b7f8a0c9be27672a0d6b22057ab3d48fbd1d5738346d8"},
"telemetry_metrics_prometheus_core": {:hex, :telemetry_metrics_prometheus_core, "0.4.2", "9c5b2cce20222f3c16256dcd6cfaf59d05a84dc664060ab938c6ac40e91d05e0", [:mix], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.5", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "9cd707328a1971c886993f3e4b22c68835153efa674bf31a957b30439de9b258"},
"telemetry_poller": {:hex, :telemetry_poller, "0.5.1", "21071cc2e536810bac5628b935521ff3e28f0303e770951158c73eaaa01e962a", [:rebar3], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4cab72069210bc6e7a080cec9afffad1b33370149ed5d379b81c7c5f0c663fd4"},
}

Loading…
Cancel
Save