Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rsyslog request.log.gz problem #324

Closed
mafiu opened this issue Jan 12, 2017 · 4 comments
Closed

rsyslog request.log.gz problem #324

mafiu opened this issue Jan 12, 2017 · 4 comments
Milestone

Comments

@mafiu
Copy link

mafiu commented Jan 12, 2017

Dear @GUI,

Some day I had a problem with my instance of ES, so I looked at the backup of the request log sended to ES in /opt/api-umbrella/var/log/rsyslog/requests.log.gz

But this file is unreadeable... or I don't know how to read it...

[api-02 rsyslog]$ file requests.log.gz
requests.log.gz: data
[api-02 rsyslog]$ gzip -d requests.log.gz
gzip: requests.log.gz: not in gzip format

I'm using API-Umbrella v0.13

Thanks

@GUI
Copy link
Member

GUI commented Jan 13, 2017

I've unfortunately seen the same problem on our servers, which makes this requests.log.gz file fairly useless in the current v0.13 release. The intention of this extra log file was exactly for this purpose--to try and make restoring data into Elasticsearch easier if something goes wrong with Elasticsearch, but unfortunately the file seems corrupted somehow.

I haven't had a chance to figure where the issue lies, but I suspect it's somehow related to rsyslog and log rotation (the file starts out as valid gzip, but after log rotation kicks in, it seems to become corrupted). But I'm planning to look into this to try and make sure we can resolve it before the next v0.14 release.

In the mean time, it should be possible to restore some of the missing data based on the nginx access logs (which shouldn't have this corruption problem). The nginx logs won't have all the normal detail (it's missing various timing information, and request/response headers), but it should give you the basic request analytics. However, restoring from the nginx logs will require some custom scripts to parse the nginx access log format and load it into elasticsearch. I have some scripts somewhere that I've used to do this previously that I'm happy to dig up and share. I'm actually needing to do a similar restore task for one of our API Umbrella instances, so hopefully I'll be tackling this sometime in the next week and I can share the scripts when I get to that task.

@mafiu
Copy link
Author

mafiu commented Jan 13, 2017

Thanks @GUI,

I'm gonna take a look too, and if I found the solution I'm gonna push it.

@GUI
Copy link
Member

GUI commented Jan 25, 2017

@mafiu: I've added some scripts to restore missing analytics based on the nginx logs. Details on how to use the scripts (and caveats) are here: https://github.com/NREL/api-umbrella/tree/master/scripts/import_access_logs Hope that helps!

More generally, I still do want to make sure we get the corrupt gzip files from rsyslog fixed for the next API Umbrella release. Having those log files would make restoring the analytics much easier and more complete in the event things go awry. I think the gzip corruption issue is a bug with rsyslog and log rotation, since some other people seem to be reporting similar issues with rsyslog here: rsyslog/rsyslog#933

GUI added a commit that referenced this issue Feb 3, 2017
See #324

This fixes the issue by sending the SIGHUP signal to rsyslog after
rotation.

In order to send the SIGHUP signal, we needed to disable the runtrap
handling around rsyslog that was intercepting signals. However, I don't
think runtrap is needed anymore, since I think the shutdown bug has
since been fixed with rsyslog.

Also turn on async writing for the rsyslog request.log.gz file and align
the buffer, flush, and gzip settings with our nginx access.log output
settings.

Also update the logrotate scripts to account for the nginx access logs
now being gzipped.
@GUI GUI added this to the v0.14.0 milestone Feb 5, 2017
@GUI
Copy link
Member

GUI commented Feb 23, 2017

These corrupt files request.log.gz files should be fixed in v0.14.0.

@GUI GUI closed this as completed Feb 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants