Get Started

Start making better decisions with Luameter's metrics.

Requirements

You will need Nginx compiled with Nginx Lua module at least version 0.5. The nginx-extras package from Ubuntu or Debian is the simplest way to get that.

We provide a 64-bit built package of Nginx 1.7.9 and Lua module 0.9.13 for Ubuntu 12.04 and 14.04 here. It depends on the nginx-common and libluajit-5.1-2 packages, so you will need to install them first.

The Nginx Lua module document also contains a section on how to compile Nginx with it.

Start recording metrics

To start recording stats, you need to add below block into the http section of your Nginx config.

http {
    ...

    lua_shared_dict luameter 1m;
    lua_package_path "{CHANGE_ME}?.luac";
    init_by_lua "luameter = require 'luameter'";
    log_by_lua "luameter.mark_by_host(); luameter.mark_by_path(1)";

    ...
}            

Different builds of Luameter are provided for different version of Lua interpreter. Assume that you extract the downloaded Luameter zip file to /opt/luameter, you will have to change the part marked above as CHANGE_ME with:

  • /opt/luamter/luac/ for normal Lua interpreter
  • /opt/luamter/luajit/ for Luajit 2.0
  • /opt/luamter/luacjit2.1/ for Luajit 2.1 alpha

The nginx-extras package uses normal Lua interpreter while our pre-built pacakge use Luajit 2.0. So depends on your Lua version you will need to change line #2 of the configuration above to match yours.

Add the API end-point and live dashboard

To setup the JSON API and view the live dashboard you can use the below server config.

server {
    listen 127.0.0.1:8001;

    location / {
        root /opt/luameter;
    }

    location /stats {
        content_by_lua "luameter.get_stats('/stats');";
        expires -1;
    }
}

Your server metrics can contain sensitive data so we recommend to create a separated server block with proper access control for it. The configuration above does that by only allows access to the API and live dashboard from localhost.

And that's it. You can now go here to start observing your server metrics.