Skip to content

Commit

Permalink
Log prometheus queries (#1417)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Sep 26, 2024
1 parent eb8d62d commit f676ad2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/console/deployments/observability.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ defmodule Console.Deployments.Observability do
end

defp component_args(%ServiceComponent{group: "apps", version: "v1", kind: "Deployment", name: name, namespace: ns} = comp),
do: {:ok, %{name: name, namespace: ns, cluster: comp.service.cluster.handle, regex: "-[a-z0-9]+-[a-z0-9]+"}}
do: {:ok, [namespace: ns, name: name, cluster: comp.service.cluster.handle, regex: "-[a-z0-9]+-[a-z0-9]+"]}
defp component_args(%ServiceComponent{group: "apps", version: "v1", kind: "StatefulSet", name: name, namespace: ns} = comp),
do: {:ok, %{name: name, namespace: ns, cluster: comp.service.cluster.handle, regex: "-[0-9]+"}}
do: {:ok, [namespace: ns, name: name, cluster: comp.service.cluster.handle, regex: "-[0-9]+"]}
defp component_args(%ServiceComponent{group: g, kind: k}), do: {:error, "unsupported component kind #{g}/#{k}"}

defp bulk_query(queries, ctx, start, stop, step) do
Expand Down
2 changes: 2 additions & 0 deletions lib/prometheus/client.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Prometheus.Client do
alias Console.Schema.DeploymentSettings.Connection
alias Prometheus.{Response, Data, Result}
require Logger
@headers [{"content-type", "application/x-www-form-urlencoded"}]

defstruct [:host, :user, :password]
Expand All @@ -17,6 +18,7 @@ defmodule Prometheus.Client do

def query(client \\ nil, query, start, end_t, step, variables) do
query = variable_subst(query, variables)
Logger.info "Issuing prometheus query: #{query}"
HTTPoison.post(
Path.join(host(client), "/api/v1/query_range"),
{:form, [
Expand Down

0 comments on commit f676ad2

Please sign in to comment.