Open chasers opened 3 years ago
If you're trying to log headers you'll want to handle them, basically turning each of those tuples into a key value pair and logging them as a map. This way you can query them like m.headers.user_agent:~"Postman"
for instance (this will return all requests with user agents with Postman
in the string).
We're replacing dashes with underscores as BigQuery doesn't like dashes in column names. Logflare will handle this for you but it will also prepend an underscore before modified field name so you know Logflare modified that field name.
h = [
{"accept", "*/*"},
{"accept-encoding", "gzip, deflate, br"},
{"connection", "keep-alive"},
{"host", "localhost:4320"},
{"postman-token", "128bdbd8-3780-4a89-8b51-2a3781db6e91"},
{"user-agent", "PostmanRuntime/7.26.5"}
]
|> Enum.map(fn {key, value} -> {String.replace(key, "-", "_"), value} end)
|> Enum.into(%{})
LogflareLogger.info("Request!", headers: h)