Skip to content

Commit

Permalink
fix: add timestamp formatting for Datadog payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziinc committed May 9, 2024
1 parent f67e661 commit 4205209
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/logflare/backends/adaptor/datadog_adaptor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Logflare.Backends.Adaptor.DatadogAdaptor do
alias Logflare.Backends.Adaptor.WebhookAdaptor

# https://docs.datadoghq.com/api/latest/logs/#send-logs
@api_url "https://http-intake.logs.datadoghq.com/api/v2/logs"
@api_url "https://http-intake.logs.us5.datadoghq.com/api/v2/logs"

typedstruct enforce: true do
field(:api_key, String.t())
Expand Down Expand Up @@ -61,11 +61,15 @@ defmodule Logflare.Backends.Adaptor.DatadogAdaptor do
end

defp translate_event(%Logflare.LogEvent{} = le) do
formatted_ts =
DateTime.from_unix!(le.body["timestamp"], :microsecond) |> DateTime.to_iso8601()

%Logflare.LogEvent{
le
| body: %{
message: Jason.encode!(le.body),
message: formatted_ts <> " " <> Jason.encode!(le.body),
ddsource: "logflare",
hostname: "logflare",
service: le.source.name
}
}
Expand Down

0 comments on commit 4205209

Please sign in to comment.