Hacker News new | past | comments | ask | show | jobs | submit login

On the topic of Nginx, does anyone know if it's possible/how one could fire off a http request (GET or POST) to an external service to log requests in real time (rather than say logging to a text file then processing that)?



It's undocumented, but you can do that with post_action:

   location /foo/ {
      ...
      post_action @mirror_request;
   }
   location @mirror_request {
      proxy_pass ...;
   }


Thank you so much! That looks perfect.


You can do it using the nginx-lua module, something like:

`local response = ngx.location.capture("/some/api/endpoint" )`

I would not recommend doing this, though. Nginx internals are rather complicated in my experience.


Thanks!

So better off to just log to a file and monitor the tail of that and send the data off with a seperate script?


Syslog


But you really don't want to do that if you need accurate log collection and aggregation. Having a local log file is essential to coping with backpressure from the log consumers. Consider what might happen if the remote syslog server goes down or is overburdened.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: