-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pod monitor configuration to standalone console chart (#771)
- Loading branch information
1 parent
521753e
commit d620515
Showing
21 changed files
with
241 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{{ if .Values.monitoring.enabled }} | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PodMonitor | ||
metadata: | ||
name: {{ include "console.fullname" . }} | ||
labels: | ||
{{ include "console.labels" . | indent 4 }} | ||
spec: | ||
podMetricsEndpoints: | ||
- port: http | ||
path: '/metrics' | ||
namespaceSelector: | ||
matchNames: | ||
- {{ .Release.Namespace }} | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: console | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
podTargetLabels: | ||
- app.kubernetes.io/name | ||
- app.kubernetes.io/instance | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
defmodule Console.Deployments.Git.Statistics do | ||
alias Console.Prom.Metrics | ||
|
||
def disk() do | ||
{count, size} = | ||
:ets.tab2list(Briefly.Entry.Dir) | ||
|> Enum.map(fn {_pid, dir} -> dir end) | ||
|> Enum.reduce({0, 0}, fn dir, {count, size} -> | ||
{dc, ds} = Console.df(dir) | ||
{count + dc, size + ds} | ||
end) | ||
|
||
Metrics.filecache(count, size) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
defmodule Console.Prom.Ecto do | ||
use Prometheus.EctoInstrumenter | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
defmodule Console.Prom.Metrics do | ||
use Prometheus.Metric | ||
|
||
defmacrop metric_name(name), do: :"plural_console_#{name}" | ||
|
||
def setup() do | ||
Gauge.declare([name: metric_name(:git_agent_count), | ||
labels: [:url], | ||
help: "Count of active git agents in this Console node"]) | ||
|
||
Gauge.declare([name: metric_name(:local_cache_file_count), | ||
help: "Count of the number of files w/in local caches at the moment"]) | ||
|
||
Gauge.declare([name: metric_name(:local_cache_filesize), | ||
help: "Count of the number of files w/in local caches at the moment"]) | ||
end | ||
|
||
def inc(:git_agent, label) do | ||
Gauge.inc([name: metric_name(:git_agent_count), labels: [label]]) | ||
end | ||
|
||
def dec(:git_agent, label) do | ||
Gauge.dec([name: metric_name(:git_agent_count), labels: [label]]) | ||
end | ||
|
||
def filecache(count, size) do | ||
Gauge.set([name: metric_name(:local_cache_file_count)], count) | ||
Gauge.set([name: metric_name(:local_cache_filesize)], size) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule Console.Prom.Scraper do | ||
use GenServer | ||
|
||
@scrape_interval :timer.minutes(10) | ||
|
||
def start_link(opts \\ :ok) do | ||
GenServer.start_link(__MODULE__, opts, name: __MODULE__) | ||
end | ||
|
||
def init(_) do | ||
:timer.send_interval(@scrape_interval, :scrape) | ||
{:ok, %{}} | ||
end | ||
|
||
def handle_info(:scrape, state) do | ||
Console.Deployments.Git.Statistics.disk() | ||
{:noreply, state} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule Console.Prom.Setup do | ||
alias Console.Prom.{Ecto, Metrics} | ||
alias ConsoleWeb.Plugs.MetricsExporter | ||
|
||
def setup() do | ||
Ecto.setup() | ||
Metrics.setup() | ||
MetricsExporter.setup() | ||
end | ||
|
||
def attach() do | ||
:ok = :telemetry.attach( | ||
"prometheus-ecto", | ||
[:console, :repo, :query], | ||
&Ecto.handle_event/4, | ||
%{} | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.