Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This driver implements an AMQP destination (based on the rabbitmq-c library), supporting persistence, all the exchange types, and uses a creative way to get messages accross: all the name-value pairs selected with the value-pairs() syntax will be sent as headers, while the message payload can be set with the body() option (empty by default). Most settings have sensible defaults, except for a few, noted below: @module afamqp destination d_amqp { amqp( vhost("/") host("127.0.0.1") port(5672) username("guest") # mandatory, no default password("guest") # mandatory, no default exchange("syslog") exchange_type("fanout") #routing_key("") #body("") persistent(yes) value-pairs( scope("selected-macros" "nv-pairs" "sdata") ) ); }; Publishing the name-value pairs as headers makes it possible to use a headers exchange type and subscribe only to interesting log streams, in a much more flexible way than using the routing_key() option. The routing_key() and body() options can contain any template, they will be expanded before publication. Signed-off-by: Attila Nagy <bra@fsn.hu> Signed-off-by: Gergely Nagy <algernon@balabit.hu>
- Loading branch information
Showing
13 changed files
with
1,066 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,6 +383,8 @@ const gchar *source_names[SCS_MAX] = | |
"severity", | ||
"facility", | ||
"sender", | ||
"smtp", | ||
"amqp", | ||
}; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SUBDIRS = afsocket afsql afstreams affile afprog afuser afmongodb afsmtp csvparser confgen system-source syslogformat pacctformat basicfuncs cryptofuncs dbparser json | ||
SUBDIRS = afsocket afsql afstreams affile afprog afuser afamqp afmongodb afsmtp csvparser confgen system-source syslogformat pacctformat basicfuncs cryptofuncs dbparser json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
SUBDIRS = @LIBRABBITMQ_SUBDIRS@ | ||
DIST_SUBDIRS = rabbitmq-c | ||
|
||
moduledir = @moduledir@ | ||
AM_CPPFLAGS = -I$(top_srcdir)/lib -I../../lib | ||
module_LTLIBRARIES = libafamqp.la | ||
|
||
export top_srcdir | ||
|
||
if ENABLE_AMQP | ||
|
||
libafamqp_la_CFLAGS = $(LIBRABBITMQ_CFLAGS) | ||
libafamqp_la_SOURCES = afamqp-grammar.y afamqp.c afamqp.h afamqp-parser.c afamqp-parser.h | ||
libafamqp_la_LIBADD = $(MODULE_DEPS_LIBS) $(LIBRABBITMQ_LIBS) | ||
libafamqp_la_LDFLAGS = $(MODULE_LDFLAGS) | ||
|
||
endif | ||
|
||
BUILT_SOURCES = afamqp-grammar.y afamqp-grammar.c afamqp-grammar.h | ||
EXTRA_DIST = $(BUILT_SOURCES) afamqp-grammar.ym | ||
|
||
include $(top_srcdir)/build/lex-rules.am | ||
|
||
# divert install/uninstall targets to avoid recursing into $(SUBDIRS) | ||
|
||
install: | ||
$(MAKE) $(AM_MAKEFLAGS) all | ||
$(MAKE) $(AM_MAKEFLAGS) install-am | ||
|
||
uninstall: | ||
$(MAKE) $(AM_MAKEFLAGS) uninstall-am | ||
|
||
check: | ||
echo "Make check disabled, since it requires a newer glib" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) 2012 Nagy, Attila <bra@fsn.hu> | ||
* Copyright (c) 2012 BalaBit IT Ltd, Budapest, Hungary | ||
* Copyright (c) 2012 Gergely Nagy <algernon@balabit.hu> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published | ||
* by the Free Software Foundation, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
%code requires { | ||
|
||
#include "afamqp-parser.h" | ||
|
||
} | ||
|
||
%code { | ||
|
||
#include "cfg-parser.h" | ||
#include "afamqp-grammar.h" | ||
#include "plugin.h" | ||
#include "vptransform.h" | ||
|
||
extern LogDriver *last_driver; | ||
extern ValuePairs *last_value_pairs; | ||
extern ValuePairsTransformSet *last_vp_transset; | ||
} | ||
|
||
%name-prefix "afamqp_" | ||
%lex-param {CfgLexer *lexer} | ||
%parse-param {CfgLexer *lexer} | ||
%parse-param {LogDriver **instance} | ||
%parse-param {gpointer arg} | ||
|
||
|
||
/* INCLUDE_DECLS */ | ||
|
||
%token KW_AMQP | ||
%token KW_EXCHANGE | ||
%token KW_EXCHANGE_TYPE | ||
%token KW_PERSISTENT | ||
%token KW_VHOST | ||
%token KW_ROUTING_KEY | ||
%token KW_BODY | ||
|
||
%% | ||
|
||
start | ||
: LL_CONTEXT_DESTINATION KW_AMQP | ||
{ | ||
last_driver = *instance = afamqp_dd_new(); | ||
} | ||
'(' afamqp_options ')' { YYACCEPT; } | ||
; | ||
|
||
afamqp_options | ||
: afamqp_option afamqp_options | ||
| | ||
; | ||
|
||
afamqp_option | ||
: KW_HOST '(' string ')' { afamqp_dd_set_host(last_driver, $3); free($3); } | ||
| KW_PORT '(' LL_NUMBER ')' { afamqp_dd_set_port(last_driver, $3); } | ||
| KW_VHOST '(' string ')' { afamqp_dd_set_vhost(last_driver, $3); free($3); } | ||
| KW_EXCHANGE '(' string ')' { afamqp_dd_set_exchange(last_driver, $3); free($3); } | ||
| KW_EXCHANGE_TYPE '(' string ')' { afamqp_dd_set_exchange_type(last_driver, $3); free($3); } | ||
| KW_ROUTING_KEY '(' string ')' { afamqp_dd_set_routing_key(last_driver, $3); free($3); } | ||
| KW_BODY '(' string ')' { afamqp_dd_set_body(last_driver, $3); free($3); } | ||
| KW_PERSISTENT '(' yesno ')' { afamqp_dd_set_persistent(last_driver, $3); } | ||
| KW_USERNAME '(' string ')' { afamqp_dd_set_user(last_driver, $3); free($3); } | ||
| KW_PASSWORD '(' string ')' { afamqp_dd_set_password(last_driver, $3); free($3); } | ||
| value_pair_option { afamqp_dd_set_value_pairs(last_driver, $1); } | ||
| dest_driver_option | ||
; | ||
|
||
/* INCLUDE_RULES */ | ||
|
||
%% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2012 Nagy, Attila <bra@fsn.hu> | ||
* Copyright (c) 2012 BalaBit IT Ltd, Budapest, Hungary | ||
* Copyright (c) 2012 Gergely Nagy <algernon@balabit.hu> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published | ||
* by the Free Software Foundation, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#include "afamqp.h" | ||
#include "cfg-parser.h" | ||
#include "afamqp-grammar.h" | ||
|
||
extern int afamqp_debug; | ||
int afamqp_parse(CfgLexer *lexer, LogDriver **instance, gpointer arg); | ||
|
||
static CfgLexerKeyword afamqp_keywords[] = { | ||
{ "amqp", KW_AMQP }, | ||
{ "vhost", KW_VHOST }, | ||
{ "host", KW_HOST }, | ||
{ "port", KW_PORT }, | ||
{ "exchange", KW_EXCHANGE }, | ||
{ "exchange_type", KW_EXCHANGE_TYPE }, | ||
{ "routing_key", KW_ROUTING_KEY }, | ||
{ "persistent", KW_PERSISTENT }, | ||
{ "username", KW_USERNAME }, | ||
{ "password", KW_PASSWORD }, | ||
{ "log_fifo_size", KW_LOG_FIFO_SIZE }, | ||
{ "body", KW_BODY }, | ||
{ NULL } | ||
}; | ||
|
||
CfgParser afamqp_parser = | ||
{ | ||
#if ENABLE_DEBUG | ||
.debug_flag = &afamqp_debug, | ||
#endif | ||
.name = "afamqp", | ||
.keywords = afamqp_keywords, | ||
.parse = (int (*)(CfgLexer *lexer, gpointer *instance, gpointer)) afamqp_parse, | ||
.cleanup = (void (*)(gpointer)) log_pipe_unref, | ||
}; | ||
|
||
CFG_PARSER_IMPLEMENT_LEXER_BINDING(afamqp_, LogDriver **) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2012 Nagy, Attila <bra@fsn.hu> | ||
* Copyright (c) 2012 BalaBit IT Ltd, Budapest, Hungary | ||
* Copyright (c) 2012 Gergely Nagy <algernon@balabit.hu> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published | ||
* by the Free Software Foundation, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#ifndef AFAMQP_PARSER_H_INCLUDED | ||
#define AFAMQP_PARSER_H_INCLUDED | ||
|
||
#include "cfg-parser.h" | ||
#include "cfg-lexer.h" | ||
#include "afamqp.h" | ||
|
||
extern CfgParser afamqp_parser; | ||
|
||
CFG_PARSER_DECLARE_LEXER_BINDING(afamqp_, LogDriver **) | ||
|
||
#endif |
Oops, something went wrong.