Written by

Here’s our last blog post about new fea­tures in our reverse-proxy engine. Previously, we talked about WAF and HTTP Cache. Now it’s time to intro­duce you to cus­tom logs.

Log GIF @Giphy

Upstreams logs

At always­da­ta, an upstream is an HTTP serv­er our proxy use as a back­end to serve pages to your vis­i­tors. An upstream can be a built-in HTTP serv­er embed in your appli­ca­tion, or a ded­i­cat­ed HTTP serv­er like Apache or uWSGI.

Now, we write all out­put mes­sages on stan­dard streams1) to a ded­i­cat­ed file. This one is avail­able in the ~/admin/logs/sites/ direc­to­ry. Those logs allow devel­op­ers and DevOps peo­ple to mon­i­tor and debug their appli­ca­tions run­ning on our plat­form. When you rely on a cus­tom upstream (like a Node.js ser­vice), you can get your appli­ca­tion out­puts. It allows you to find the glitch when a ser­vice refus­es to start properly.

The same file hosts all writ­ten mes­sages from all upstreams which belongs to the same always­da­ta account. Each upstream uses its PID2) to mark a line in the log file. PIDs allow you to retrieve which process (a.k.a. which upstream) cur­rent­ly out­put a line. This iden­ti­fi­er is avail­able between brack­ets after the date: [14/Jul/2018:10:04:21 +0200] [PID]. When an upstream end — e.g., when it stays idle for a long time — the giv­en PID can be dif­fer­ent when it restarts. Two lines are out­put in the log file each time an upstream wakes up. It allows you to match PID and upstream:

Access logs

Now, you can choose the name giv­en to the access log files. To cus­tomize this entry, go to Sites → Edit → Logs.

Screenshot of website's logs customization view

You can also edit the out­put for­mats. If you need to parse your log files using a pars­er or a script, the cus­tom out­put for­mats allow your log files to be suit­able with your work­flow. This field allows vari­able names between brack­ets {}. Their val­ues sub­sti­tute them at writ­ing time. You can also free char­ac­ters string. The syn­tax and vari­ables avail­able are doc­u­ment­ed in our logs page.

The default for­mat is:

It returns this string:

To cus­tomize the out­put to pro­vide the pro­to­col, request dura­tion and some char­ac­ters strings, you may use the fol­low­ing syntax:

Which outputs:

With ful­ly cus­tomiz­able access logs and an eas­i­er upstream debug, we design a more com­fort­able host­ing plat­form. Monitoring and observ­ing ser­vices on pro­duc­tion at always­da­ta becomes painless.

This blog post is the last one about our new prox­y’s fea­tures. We built our ser­vice for you and with you. Please help us again to improve it by giv­ing us some feed­back in com­ments to explain which fea­tures are miss­ing for you!

jin yang handshake GIF by Silicon Valley @Giphy


1 stdout and stderr
2 Process IDentifier