Re: [syslog-ng] Injecting environment variables?
Ok sorry, but still struggling a bit with this: Running with the following version syslog-ng 3.2.5 Installer-Version: 3.2.5 Revision: ssh+git://bazsi@git.balabit//var/scm/git/syslog-ng/syslog-ng-ose--mainline--3.2#master#9d4bea28198bd731df1a61e980a2af5b88d81116 Compile-Date: Jan 15 2012 19:47:30 Enable-Threads: on Enable-Debug: off Enable-GProf: off Enable-Memtrace: off Enable-Sun-STREAMS: off Enable-IPv6: on Enable-Spoof-Source: on Enable-TCP-Wrapper: on Enable-SSL: off Enable-SQL: on Enable-Linux-Caps: off Enable-Pcre: on Enable-Pacct: off I've attempted a number of variations - all have made me sad..... template t_cust { template("CUST $CUST"); }; destination d_web_call { file("/var/log/web_call" template("<$PRI> $DATE $HOST $MSG template($t_cust) \n") template_escape(no)); }; or 'backtick'.... destination d_web_call { file("/var/log/web_call" template("<$PRI> $DATE $HOST $MSG `$CUST` \n") template_escape(no)); }; or... destination d_web_call { file("/var/log/web_call" template("<$PRI> $DATE $HOST $MSG Template("template $CUST")` \n") template_escape(no)); }; $CUST is definitely defined in the environment but the logs don't have any value appended.... Any further guidance appreciated.... On Sep 23, 2014, at 6:00 AM, syslog-ng-request@lists.balabit.hu wrote:
----------------------
Message: 1 Date: Mon, 22 Sep 2014 20:10:17 +0200 From: Balazs Scheidler <bazsi77@gmail.com> Subject: Re: [syslog-ng] Injecting environment variables? To: "Syslog-ng users' and developers' mailing list" <syslog-ng@lists.balabit.hu> Message-ID: <CAKcfE+a8ohm9rbAjyiBbHSs37iyE_mdP=SRU_Cgz_BSAccFFBg@mail.gmail.com> Content-Type: text/plain; charset="utf-8"
It came in with blocks and scl support. So if your version has support for the system driver it will support this as well. My memories are vague with 3.2.
Environment variables are resolved at parsing time and should work like this:
Template("template ?envvar?")
It works as if the environment variable was right there in the config file. On Sep 21, 2014 3:14 PM, <jetjnkr@gmail.com> wrote:
Balazs,
Thanks, do you have any examples in using the backtick it in a message template? Do you have to assign it to a config variable in a "define" first?
How much 'earlier' versions of syslog-ng will this work (e.g. before 3.2 ?)
Jim.
From: Balazs Scheidler <bazsi77@gmail.com> Subject: Re: [syslog-ng] Injecting environment variables? To: "Syslog-ng users' and developers' mailing list" <syslog-ng@lists.balabit.hu>, wernli@in2p3.fr Message-ID: <
CAKcfE+ZKqqPnPOOSJek81eq_EPa7y3jUrPyKYH94jc3mxvPsmg@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Earlier you could use the backtick env variable format.
This one is substituted at config parsing. On Sep 18, 2014 5:26 PM, "Fabien Wernli" <wernli@in2p3.fr> wrote:
Hi Jim,
As of version 3.5 you can use the `env` template function:
template("<$PRI> $DATE $HOST $MSG $(env <environment-variable>) \n") template_escape(no));
Cheers
Member info: https://lists.balabit.hu/mailman/listinfo/syslog-ng Documentation: http://www.balabit.com/support/documentation/?product=syslog-ng FAQ: http://www.balabit.com/wiki/syslog-ng-faq
You don't need the dollar sign within backticks. On Sep 23, 2014 6:58 PM, <jetjnkr@gmail.com> wrote:
Ok sorry, but still struggling a bit with this:
Running with the following version
syslog-ng 3.2.5 Installer-Version: 3.2.5 Revision: ssh+git://bazsi@git.balabit //var/scm/git/syslog-ng/syslog-ng-ose--mainline--3.2#master#9d4bea28198bd731df1a61e980a2af5b88d81116 Compile-Date: Jan 15 2012 19:47:30 Enable-Threads: on Enable-Debug: off Enable-GProf: off Enable-Memtrace: off Enable-Sun-STREAMS: off Enable-IPv6: on Enable-Spoof-Source: on Enable-TCP-Wrapper: on Enable-SSL: off Enable-SQL: on Enable-Linux-Caps: off Enable-Pcre: on Enable-Pacct: off
I've attempted a number of variations - all have made me sad.....
template t_cust { template("CUST $CUST"); }; destination d_web_call { file("/var/log/web_call" template("<$PRI> $DATE $HOST $MSG template($t_cust) \n") template_escape(no)); };
or 'backtick'....
destination d_web_call { file("/var/log/web_call" template("<$PRI> $DATE $HOST $MSG `$CUST` \n") template_escape(no)); };
or...
destination d_web_call { file("/var/log/web_call" template("<$PRI> $DATE $HOST $MSG Template("template $CUST")` \n") template_escape(no)); };
$CUST is definitely defined in the environment but the logs don't have any value appended....
Any further guidance appreciated....
On Sep 23, 2014, at 6:00 AM, syslog-ng-request@lists.balabit.hu wrote:
----------------------
Message: 1 Date: Mon, 22 Sep 2014 20:10:17 +0200 From: Balazs Scheidler <bazsi77@gmail.com> Subject: Re: [syslog-ng] Injecting environment variables? To: "Syslog-ng users' and developers' mailing list" <syslog-ng@lists.balabit.hu> Message-ID: <CAKcfE+a8ohm9rbAjyiBbHSs37iyE_mdP= SRU_Cgz_BSAccFFBg@mail.gmail.com> Content-Type: text/plain; charset="utf-8"
It came in with blocks and scl support. So if your version has support for the system driver it will support this as well. My memories are vague with 3.2.
Environment variables are resolved at parsing time and should work like this:
Template("template ?envvar?")
It works as if the environment variable was right there in the config file. On Sep 21, 2014 3:14 PM, <jetjnkr@gmail.com> wrote:
Balazs,
Thanks, do you have any examples in using the backtick it in a message template? Do you have to assign it to a config variable in a "define" first?
How much 'earlier' versions of syslog-ng will this work (e.g. before 3.2 ?)
Jim.
From: Balazs Scheidler <bazsi77@gmail.com> Subject: Re: [syslog-ng] Injecting environment variables? To: "Syslog-ng users' and developers' mailing list" <syslog-ng@lists.balabit.hu>, wernli@in2p3.fr Message-ID: <
CAKcfE+ZKqqPnPOOSJek81eq_EPa7y3jUrPyKYH94jc3mxvPsmg@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Earlier you could use the backtick env variable format.
This one is substituted at config parsing. On Sep 18, 2014 5:26 PM, "Fabien Wernli" <wernli@in2p3.fr> wrote:
Hi Jim,
As of version 3.5 you can use the `env` template function:
template("<$PRI> $DATE $HOST $MSG $(env <environment-variable>) \n") template_escape(no));
Cheers
Member info: https://lists.balabit.hu/mailman/listinfo/syslog-ng Documentation: http://www.balabit.com/support/documentation/?product=syslog-ng FAQ: http://www.balabit.com/wiki/syslog-ng-faq
participants (2)
-
Balazs Scheidler
-
jetjnkr@gmail.com