Log ZMQ

Name

nginxのためのZeroMQロガーモジュール

ZeroMQ, zero-em-queue, はメッセージ交換のためのプロトコルです。任意の言語あるいはプラットフォームを使ってimproc, IPC, TCP, TPIC あるいはマルチキャストを経由して通信することが簡単です。非同期で小さなライブラリのみを必要とします。

注意

このモジュールはnginxのソースと一緒に配布されません。 インストレーションの説明を見てください。

状態

このモジュールは既にプロダクションの準備ができています。

説明

これはZeroMQ ライブラリと統合されたnginxロガーモジュールです。

nginx-log-zmq は1つ以上の異なるエンドポイントに対して1つ以上のPUB/SUB購買者のためにデータを記録する非常に効果的な方法を提供します。これはデータの収集および処理にとても便利でしょう。

The message format can be the same as the tradicional log format which gives a interesting way to tail data via the network or exploring other text formats like JSON. As with the traditional log, it’s possible to use nginx variables updated each request.

All messages are sent asynchronously and do not block the normal behaviour of the nginx server. As expected, the connections are resilient to network failures.

概要

http {
    # simple message to an IPC endpoint with 4 threads and 1000 queue elements

    log_zmq_server main "/tmp/main.ipc" ipc 4 1000;
    log_zmq_endpoint  main "/topic/";

    log_zmq_format main '{"remote_addr":"$remote_addr"}'

    # send messages to a subscriber listening at 127.0.0.1:5556

    log_zmq_server secondary 127.0.0.1:5556 tcp 4 1000;

    # set secondary endpoint
    log_zmq_endpoint secondary "/endpoint/";

    # set format using multiline
    log_zmq_format secondary '{"request_uri":"$request_uri",'
                             ' "status":"$status"}';


    server {

        location /status {
            # mute all messages from log_zmq for this location

            log_zmq_off all;
        }

        location /endpoint {
            # mute main messages from log_zmq for this location

            log_zmq_off main;
        }
    }
}

ディレクティブ

log_zmq_server

構文:log_zmq_server <definition_name> <address> <ipc|tcp> <threads> <queue size>
デフォルト:no
コンテキスト:http

Configures a server (PUB/SUB subscriber) to connect to.

The following options are required:

definition_name <name> - the name that nginx will use to identify this logger instance.

address <path>|<ipaddress>:<port> - the subscriber’s address. If you are using the IPC protocol, you should specify the <path> for the unix socket. If you are using the TCP protocol, you should specify the <ipaddress> and <port> where your ZeroMQ subscriber is listening.

protocol <ipc|tcp> - the protocol to be used for communication.

threads <integer> - the number of I/O threads to be used.

queue_size <integer> - the maximum queue size for messages waiting to be sent.

log_zmq_endpoint

構文:log_zmq_endpoint <definition_name> “<topic>”
デフォルト:no
コンテキスト:http

Configures the topic for the ZeroMQ messages.

definition_name <name> - the name that nginx will use to identify this logger instance.

topic <topic> - the topic for the messages. This is a string (which can be a nginx variable) prepended to every sent message. For example, if you send the message “hello” to the “/talk:” topic, the message will end up as “/talk:hello”.

例:

http {
    log_zmq_server main "/tmp/example.ipc" 4 1000;

    # send a message for for an topic based on response status

    log_zmq_endpoint main "/remote/$status";
}

log_zmq_format

構文:log_zmq_format <definition_name> “<format>”
デフォルト:no
コンテキスト:http

Configures the ZeroMQ message format.

definition_name <name> - the name that nginx will use to identify this logger instance.

format <format> - the format for the messages. This defines the actual messages sent to the PUB/SUB subscriber. It follows the sames rules as the standard log_format directive. It is possible to use nginx variables here, and also to break it over multiple lines.

http {
    log_zmq_format main '{"line1": value,'
                        ' "line2": value}';
}

log_zmq_off

構文:log_zmq_off<definition_name>|all
デフォルト:no
コンテキスト:場所

Turn off ZeroMQ logging in the current context.

definition_name <name> the name of the logger instance to be muted. If the special all name is used, all logger instances are muted.

インストール

To build a nginx binary containting this module:

  • Download the latest version of this module from GitHub.
  • Grab the nginx source code from nginx.org, for example, version 1.6.2 (see nginx compatibility), and then build it like so:
./configure --prefix=/usr/local/nginx --add-module=/path/to/nginx-log-zmq

make
make install

NGINX 互換性

The following versions of nginx are known to work with this module:

  • 1.8.0
  • 1.6.x (最後のテスト: 1.6.2)
  • 1.5.x
  • 1.4.x (最後のテスト: 1.4.4)

バグのレポート

Bug reports, wishlists, or patches are welcome. You can submit them on our GitHub.

TOP
inserted by FC2 system