-
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.
Implement pluggable log aggregation drivers
Starting w/ victoria metrics, and will also implement elastic. Support authz against main plural objects, eg services, clusters, projects, and query constructs that would work with a fully fledged log agg ui.
- Loading branch information
1 parent
55a80fb
commit 99ede8f
Showing
19 changed files
with
488 additions
and
1 deletion.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,9 @@ | ||
defmodule Console.Logs.Line do | ||
@type t :: %__MODULE__{facets: [%{key: binary, value: binary}]} | ||
|
||
defstruct [:timestamp, :log, :facets] | ||
|
||
def new(map) do | ||
%__MODULE__{log: map[:log], timestamp: map[:timestamp], facets: map[:facets]} | ||
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,27 @@ | ||
defmodule Console.Logs.Provider do | ||
alias Console.Logs.{Query, Line} | ||
alias Console.Logs.Provider.{Victoria} | ||
alias Console.Schema.{User, DeploymentSettings} | ||
|
||
@type error :: Console.error | ||
|
||
@callback query(struct, Query.t) :: {:ok, [Line.t]} | error | ||
|
||
@spec query(Query.t) :: {:ok, [Line.t]} | error | ||
def query(%Query{} = q) do | ||
with {:ok, %{__struct__: provider} = prov} <- client(), | ||
do: provider.query(prov, q) | ||
end | ||
|
||
@spec accessible(Query.t, User.t) :: {:ok, Query.t} | error | ||
def accessible(%Query{} = query, %User{} = user), do: Query.accessible(query, user) | ||
|
||
defp client() do | ||
Console.Deployments.Settings.cached() | ||
|> client() | ||
end | ||
|
||
def client(%DeploymentSettings{logging: %{enabled: true, driver: :victoria, victoria: %{} = victoria}}), | ||
do: {:ok, Victoria.new(victoria)} | ||
def client(_), do: {:error, "Plural logging integration not yet configured"} | ||
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,6 @@ | ||
defmodule Console.Logs.Provider.Utils do | ||
def facets(%{} = map) do | ||
Enum.map(map, fn {k, v} -> %{key: k, value: v} end) | ||
end | ||
def facets(_), do: nil | ||
end |
Oops, something went wrong.