However, now that it’s been running for a little bit, I think it might be skipping messages from some containers. For example I don’t see any messages from either NodeRed or Zigbee2mqtt since I added multiline pattern in. Zwave2mqtt logs are still there, but they are also duplicated, same as Home Assistant Core logs.
And yes, I can confirm that the patter above doesn’t work for all containers. Mosquitto logs are getting over aggregated, since they don’t start with the timestamp.
I guess it’s just too tricky to get the default multiline adapter to work. Instead of trying I better spend time on a proper adapter that works well for HA and comes preconfigured for at least the core containers. I hope you can be patient, it might take a few weeks or a little more but I promise it will come.
Sounds good. I’ve waited for years to be able to get HA logs out, so waiting a few more weeks isn’t really an issue.
One thing to note, even once I removed all of the multiline patterns from the config, I’m still getting duplicated messages for all containers. And I think it started after the latest update to the addon. Is it possible that something changed in the addon itself that duplicates messages?
I can’t think of anything. Do you also get duplicate lines without using multiline on your route? Maybe it’s a bug in that adaper.
Other things you might want to look at:
Does the log from logspout show anything weird
Check the configuration as yaml (the GUI editor fooled me more than once)
Set the Debug variable:
- name: DEBUG
value: "true"
for me it doesn’t show much extra but it does show 16 pump.getLogs() messages and I have 16 containers running
If nothing helps I would like to know if exactly each message is duplicated or if it seems to be more random.
Also just an FYI, Z2M actually logs to a file in its config folder by default (probably either /config/zigbee2mqtt or /share/zigbee2mqtt depending on when you set it up). Once you have an easy way to review the docker logs for addons you should disable that so it stops chewing up extra disk cycles. You can do this by changing “Log Output” to console and blanking out the “Log File” and “Log Directory” fields in advanced settings.
I don’t use Zwave at all so I don’t know that one. That’s pretty weird though, why would they be duplicated?
I actually didn’t find any need to do multiline for mosquitto. The only thing I have for that one is this:
It pops that line in the log all the time so I just drop it. I don’t have to review the logs of this addon much but its not really helpful to have pages and pages of that message in grafana when I do.
EDIT: I just realized looking at my post that Z2M also uses the terminal color code character. So it looks like that pattern mostly works for that addon as well. If memory serves its a bit more then that there because of exceptions. I believe uncaught exceptions just start with node: and then dump a stack trace. Something like that.
The match code form @CentralCommand refers to the configuration of promptail. Logspout does not have such a configuration. I still have it on my todo list to add something like that in a simplified form but didn’t find the time yet.
Logspout can filter logs based on container labels (GitHub - gliderlabs/logspout: Log routing for Docker container logs). Unfortunately with HA we don’t have much control over those, but fortunately home assistant does assign some labels by itself, in particular the label io.has.name might be useful. In your case you might try:
Hoi Bert, since my hass server randomly crashes, I tried to find a way to send logs outside home assistant. I stumbled on your add after figuring out the original Loki addon doesn’t work and unfortunately isn’t maintained anymore.
I first tried to send logs to my grafana account. This didn’t work due to me not understanding how to configure a user name and password env variable. I could find it in the documentation or comments on GitHub.
I now use papertrail. Works fine! But I’d like to use Loki/grafana since I then can use my existing account. Could you maybe help out? How can I configure username and password?
From what I see Loki by itself does not use any authentication. I guess the instance you are using adds this by a reverse proxy or something. Do you know the authentication method? Is it Basic Authentication or some other method?
Logspout does not have an option to add authentication headers as far as I know but I can have a look into the code this weekend to see if I can add some support.
the instance I am using is the free environment grafana offers on their website. Looking at the settings I see it is named basic auth with a user and a password. Where the user has 6 digits and the password is a token like this:
I just had a look into the code and this is debug logging. Looking into the code I figured that logspout interprets any non-empty value for the DEBUG variable as true:
if os.Getenv("DEBUG") != "" {
log.Println(v...)
}
So I guess these messages will go away when you set the DEBUG variable explicitly to an empty string ("") (not tested) or leave it out.
Hi Harry, just an update: I had a look at authentication support and it looks quite good. I managed to get it working with a free account on grafana.com. I need to shape the implementation and add documentation but it should be available soon.