-
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.
- Loading branch information
1 parent
f941814
commit 0989d18
Showing
31 changed files
with
626 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
defimpl Console.AI.Evidence, for: Console.Schema.Alert do | ||
use Console.AI.Evidence.Base | ||
alias Console.AI.Evidence.{Logs, Context} | ||
alias Console.Schema.{Alert, Service, Cluster} | ||
alias Console.Repo | ||
|
||
def generate(%Alert{state: :firing, service: %Service{} = service} = alert) do | ||
[{:user, alert_prompt(alert)}] | ||
|> Logs.with_logging(service, force: true, lines: 100) | ||
|> Context.prompt({:user, "Please use the data I've listed above to give a clear root cause analysis of this issue."}) | ||
|> Context.result() | ||
end | ||
def generate(%Alert{state: :resolved}), do: {:error, "alert is already resolved"} | ||
def generate(_), do: {:error, "insights only supported for service bound alerts"} | ||
|
||
def preload(%Alert{} = alert), do: Repo.preload(alert, [:insight, service: :cluster]) | ||
|
||
def insight(%Alert{insight: insight}), do: insight | ||
|
||
def custom(_), do: false | ||
|
||
defp alert_prompt(%Alert{title: t, message: msg, service: %Service{name: s, cluster: %Cluster{name: n, distro: d}}}) do | ||
""" | ||
There is an alert firing on a workload within the #{distro(d)} kubernetes cluster named: #{n}. The workload itself | ||
is deployed using the Plural service #{s}. | ||
The title of the alert is: #{t} | ||
The message of the alert is: | ||
#{msg} | ||
I'll list some of the logs related to this workload to help analyze the root cause. | ||
""" | ||
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,15 @@ | ||
defmodule Console.AI.Evidence.Component.Certificate do | ||
use Console.AI.Evidence.Base | ||
|
||
def hydrate(%Kube.Certificate{metadata: %MetaV1.ObjectMeta{namespace: ns, name: n}}) when is_binary(ns) do | ||
Kube.Client.list_certificate_requests(ns) | ||
|> default_empty(fn %Kube.CertificateRequest.List{items: requests} -> | ||
Enum.filter(requests, fn | ||
%Kube.CertificateRequest{metadata: %MetaV1.ObjectMeta{owner_references: [%{name: ^n} | _]}} -> true | ||
_ -> false | ||
end) | ||
|> Enum.map(& {:user, "the certificate manages a set of certificate requests #{component(&1)} with current state:\n#{encode(&1)}"}) | ||
end) | ||
end | ||
def hydrate(_), do: {:ok, []} | ||
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
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
Oops, something went wrong.