Log rotate in unix

Log rotate in unix

Recently I've been doing some work with analytics and tracking and came across log rotation in Linux.

The problem I came across was when parsing nginx logs to build up user journeys. Because the log was set to just keep logging forever, when the logs reached the maximum capacity due to disk size, it occasionally caused nginx to return a 503 response to the caller.

I realised I had two options;

  • Increase the disk size (which would have meant decommissioning the vm in azure, taking it out of the load balancer, resizing and putting it back in) which wasn't really an option as it was a temporary fix.

  • Setup log rotate, so the vm becomes self maintaining (since we are exporting the logs to our analytics platform, keeping more than a few days of logs is pretty pointless, as long as there is sufficient time to reprocess a log if it fails for example)

I was surprised how easy it was to setup!

The Ubuntu VM I was using for nginx needed to have logrotate installed (I just used aptitude) and this automatically added it to cron.daily

cron is configured in  /etc/crontab and its possible to change the time it runs, but I was happy with the default, as long as it was run at roughly the same time daily.

The documentation is pretty good online for this, and within a few minutes I managed to get it all setup and working.
I used a basic configuration to rotate the logs each day, keeping a maximum of 5 daily back ups:

/var/log/nginx/* {
create 0644 admin admin
rotate 5

This means we don't have to worry anymore about the disk running out of space, and our analytics platform can keep on ticking without us having to stop filebeat or having the occasional 503 error being returned from nginx.
AspNetCore Brown bag slides

AspNetCore Brown bag slides

Here are the slides from the brown bag session on aspnetcore that I ran for work

Playing with analytics - Exceptions by page

Playing with analytics - Exceptions by page

Its easy to join tables such as pageViews and exceptions, which will show the amount of exceptions that have occured, on a certain page view, which means you can focus efforts to reduce the amount of unhandled exceptions on pages which get more traffic

| where timestamp > ago(1d)
| join kind=leftouter (
    | where timestamp > ago(1d)
) on operation_Id
| where success == "False"
| summarize exceptionCount=count() by tostring(parseurl(url)["Path"])
| order by exceptionCount desc
| render piechart 

Playing with analytics - Website flows

Playing with analytics - Website flows

I've been playing around with azure app insights analytics again. I focused on seeing if there is a way that i could work out a users journey through a website, using simple query. I know this is easy to do with Google analytics, but I thought I would see if I could do something similar with azure app insights offering.

Turns out its quite simple, and you can see the journey they took, on one device

Mob Programming

Mob Programming

Last night I attended a session on Mob Programming and Working well together, with guest speaker Woody Zuill, who claims to be one of the founders of the practice. The session was at the coop digital building at Federation House in Manchester city centre.

I attended with a few work friends straight after work, and was luckily only a few minutes walk away.
The evening started with networking, and people just getting to know each other before the main talk with a few beers. Woody talked his experience in the industry, and how mob programming came about, and how much more work  an be achieved working in this way, although the velocity cannot be measured so its difficult to prove. It made me realise the small amount of mobbing I have done so far in my career, is probably not as structured as it should be, and certainly not what Woody would consider mobbing!

He showed photos from all around the world, with companies he has converted to use Mob Programming, some interesting photos of companies with 3x80inch screens, looked a bit scary!
He pointed us to a github page where you can run a client that will tell you when the next person is up for being the driver, but this feels a bit too strict in my opinion.

Woody really sold it to us though, the benefits such as the whole squad constantly being up to date with the latest changes, less meetings, quicker answers, shorter feedback loops, squad engagement higher etc. One thing I thought about was that mobbing full on all the time must be really draining, mentally but he summed it up really well with this statement:
Relaxed, Sustainable
Be prepared to contribute
The right thing
At the right time
In the right way

He also spoke about how to work well together, and the basis of this is built with individuals and interactions, kindness, consideration and respect, which seems kind of obvious but it's a nice reference point. He mentioned that being too loud and overpowering takes the light off quieter individuals, and when mobbing or working in a squad, it's important to get the balance right with listening, not over thinking, including quieter members of the squad and having consideration and respect for the other squad members.

I managed to grab some of the slides, which is a good read and took away a quote he left us with which I found interesting

"The value of anothers' experience, is to give us hope. Not to tell us how, or whether to proceed"