Powered by AppSignal & Oban Pro

Grafana Traffic Anomalies

grafana_traffic_anomalies.livemd

Grafana Traffic Anomalies

Mix.install([
  {:req, "~> 0.5"},
  {:jason, "~> 1.4"},
  {:kino, "~> 0.17.0"},
  :httpoison
])

Load images

image   = "#{File.cwd!()}/Desktop/test2.png" |> File.read!()
image_b64 = image |> Base.encode64()

# Kino.Image.new(image, :png)
:ok

Test qwen/qwen2.5-vl-7b (LMStudio server)

base_url = "http://localhost:1234/v1"
# model = "qwen/qwen2.5-vl-7b"
model = "google/gemma-3-12b"

prompt = """
Analyze this HTTP status code graph (Sydney Served Statuses).

Provide brief analysis with bullet points:
- What's the normal baseline traffic pattern?
- Are there any anomalous spikes or drops?
- Which status codes caused the anomalies?
- What time did incidents occur?

Keep it short and actionable for an SRE.
"""

body = %{
  "model" => model,
  "messages" => [
    %{
      "role" => "user",
      "content" => [
        %{"type" => "text", "text" => prompt},
        %{"type" => "image_url", "image_url" => %{"url" => "data:image/png;base64,#{image_b64}"}}
      ]
    }
  ],
  "max_tokens" => 4000,
  "temperature" => 0.3
}

resp = Req.post!("#{base_url}/chat/completions", 
  json: body, 
  receive_timeout: 300_000
)

content = resp.body["choices"] |> List.first() |> get_in(["message", "content"])
# IO.puts(content)
:ok