Paul Em

Nogger 2.0 is out!

Update: This post covers Nogger 2.0 - the new version 3 was just released. I will post an update here soon.

Last year I created a monitoring tool with node.js to view log files and metrics from a server. I did this as a project for my university and made it open source. The name of this baby is Nogger - an acronym for "nodejs log reader". Oh and the ice cream is also pretty tasty.

The old stuff

The idea was to have a nodejs or basically any server running and hook so called adapters in there. These adapter would talk to a redis database located on the same or a remote server. Nogger itself is nothing more than a website that accesses this database and displays the data on a dashboard.

The data sent to the database would consist of log information and some proprietary metrics data (provided with an api via the adapter). Also a new log level "debug" would only send data to Nogger as soon as someone is connected to the dashboard.

The new stuff

In theory this all sounds amazing, but then there is the practice... it turned out setting up a redis database and configuring everything to play together perfectly is not an easy task and even I struggled in setting it up from time to time. Then there where a lot of minor bugs and performance issues, so I decided to dump the whole project and create a much more simple solution.

Nogger 2.0 reads existing log files of any format and offers two options: search and live log.

search page

As you can see you have search box (if you leave it empty you get all) and the option to limit the result to a certain size and where to start in the logfile.

On the left you see the navigation with shortlinks to other running instances (they run on other ports and can have different passwords, etc)

live logs page

The live logs work exactly like the tail command on linux. The list gets automatically updated and you can manipulate the stream by grepping or highlighting lines. Via the buffer input you can tell nogger how many lines should be displayed and with the update button you can stop the update to look something in detail. Disabling follow tail stops scrolling to the bottom whenever a new lines arrives.

The command line interface

After installing nogger via npm install nogger -g you have the nogger command available in your terminal.

  $ nogger --help

|                                                              |
| usage: nogger [action]                                       |
|                                                              |
|                                                              |
| actions:                                                     |
|                                                              |
|  start [path]       Starts nogger with logfile path          |
|   -w, --pw <key>)   Optional. Set password for dashboard.    |
|                       If not set a password is generated.    |
|   -i, --id <id>)    Optional. A identifier that can be used  |
|                      instead of a generated one              |
|   -p, --port <port> Optional. Port for dashboard.            |
|   -c, --cert <cert> Optional. Provide SSL certificate in     |
|                      order to avoid having to manually       |
|                      confirm the certificate in the browser  |
|   -k, --key <key>   Optional. Provide SSL key in order to    |
|                      avoid having to manually confirm the    |
|                      certificate in the browser              |
|  restart <id>       Restarts an available instance           |
|  restartall         Restarts all available instances         |
|  stop <id>          Stops the nogger daemon                  |
|  stopall            Stops all nogger daemons                 |
|  remove <id>        Removes an instance from the list        |
|  removeall          Removes all instances from the list      |
|  list               Returns list of nogger instances running |
|                                                              |
|  setpw <pw> (<id>)    Updates the password for the dashboard |
|  showblocked        Displays blocked list(s)                 |
|  block <ip>         Add ip to blocked list(s)                |
|  unblock <ip>       Unblocks an ip from blocked list(s)      |
|                                                              |
|  -v, --version      Shows current nogger version             |
|  -h, --help         Shows help menu                          |
|                                                              |

A sample command to start watching a file would be:

nogger start /var/log/nginx/access.log -w supersecretpw -i nginx -p 1337 --cert /etc/nginx/ssl/server.crt --key /etc/nginx/ssl/server.key  

Interested? Just give it a try! No configuration is needed and you are up and running in 1 minute (assuming you got node installed)

Link to Github page
Link to npm page