Closed tsloughter closed 3 years ago
I mean if you don't understand it, I'm wondering if I'll be able to figure it out :)
But this will give me a chance to play with Nerves today! I have a few PIs laying around so let me see what I can do.
I'm thinking we can merge in system env variables also, so people can set them there as a fallback no matter what.
@tsloughter can you try this one?
https://github.com/Logflare/logflare_logger_backend/releases/tag/v0.10.1
Try setting these via your system envs:
export LOGFLARE_URL="https://api.logflare.app"
export LOGFLARE_API_KEY="..."
export LOGFLARE_SOURCE_ID="..."
Yup, will give it a try in a bit.
Woo, that worked! Well, almost :). I no longer get the source id error but logs return a 406 status, something about source name.
Can you confirm you exported the source_id
?
export LOGFLARE_SOURCE_ID="..."
The source ID is the UUID so it'll look like this, and you can copy it from your Logflare dashboard. I will improve that error message a bit.
export LOGFLARE_SOURCE_ID=UUID
Yes, it must be being set, the error messages I got when it wasn't have gone away. I even at first had been setting OGFLARE_SOURCE_ID
and got an error about source id not being set. And the source id works fine when I am using it by setting the usual way in config.exs and running iex.
So is the error that the source id must be wrong? Maybe it is an issue with how I'm setting it through erlinit
:
config :nerves, :erlinit,
hang_on_exit: true,
env: "LOGFLARE_URL=https://api.logflare.app;LOGFLARE_API_KEY=...;LOGFLARE_SOURCE_ID=..."
I guess I'll try putting escaped quotes around the value.
Darn, still get "Source or source_name is nil, empty or not found".
Try to copy it again from your Logflare dashboard and make sure that source_id is in your account?
I verified that it's pulling correctly from the system env on my machine here.
Yes, it works fine for me from the system env too.. It only fails when I run the nerves release with it being set as shown in the above config.
If that error message means the source_id is wrong then I can be fairly certain it is an issue of how erlinit is parsing this key/value pair.
Alright, I finally got it :) thanks for all the help and the release.
I did it by overriding the erlinit config file with one that uses -e
to set the environment variables https://hexdocs.pm/nerves/advanced-configuration.html#overwriting-files-in-the-root-filesystem
Don't now why it didn't work when I was setting them in erlinit
section of config.exs
, or when setting the config directly in the logflare_logger_backend
section of config.exs
, but atleast it is working now :)
I'm not sure if this is exactly #42 or not, and one issue is that with nerves I can't yet use
runtime.exs
, so the fix found there isn't usable.But it is essentially the same error, running locally with
iex
everything works fine but when I burn firmware to an sd card and boot it on the device I get crashes on boot because it sayssource_id
isn't configured.The generated
sys.config
in the release thatnerves
creates appears fine, I see thelogflare_logger_backend
section with thesource_id
as I 'd expect when it translatesconfig.exs
tosys.config
.I'm new to nerves and still get confused by how Elixir's does configuration (at least seems reasonable now with
runtime.exs
, but not an option in this case because of the use of nerves).The configuration done when the backend boots looke reasonable, it reads it in from the application env in
init
, so I'm curious why was it necessary in the other case to move it toruntime.exs
instead ofconfig.exs
. Aren't they both going to result in application env variables insys.config
? Maybe that'll lead me down the path to figuring out what is going on :)