[syslog-ng] Setting and using variables

Faine, Mark R. (MSFC-IS40)[NICS] mark.faine at nasa.gov
Mon Mar 25 13:39:43 UTC 2019


I see.  That actually clears up a lot of questions.  I did see the global variables option and was thinking about using it for part of my path in the template.   From what I've read environment variables are available as global variables.  Part of my path should only exist if running on a backup (secondary) server.  

On the primary servers I have:
/var/log/remote

and the backups have:
/var/log/remote/backup

I was thinking that I could determine which server we are on in root's .bashrc or in the startup script for syslog-ng and set an environment variable, and then in the template, I could use the variable:

template log_path {
	template("`BASEPATH`/$location/$HOST/$app/${HOST}_$app.log");
};

Do you think that would work?

Thanks,
-Mark


-----Original Message-----
From: syslog-ng <syslog-ng-bounces at lists.balabit.hu> On Behalf Of Fabien Wernli
Sent: Monday, March 25, 2019 8:24 AM
To: Syslog-ng users' and developers' mailing list <syslog-ng at lists.balabit.hu>
Subject: Re: [syslog-ng] Setting and using variables

On Mon, Mar 25, 2019 at 01:07:17PM +0000, Faine, Mark R. (MSFC-IS40)[NICS] wrote:
> Thank you both, this is very helpful.  I can use this.  Is it only possible to set variables by adding to the message?  Can variables exist outside of the message?

The whole message routing logic is message-scoped, so variables are attached to a message. 
You can set global variables using 'define' directives.

______________________________________________________________________________
Member info: https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.balabit.hu_mailman_listinfo_syslog-2Dng&d=DwIGaQ&c=ApwzowJNAKKw3xye91w7BE1XMRKi2LN9kiMk5Csz9Zk&r=zMyZvtxRXMBKZZYKVMke9zplWK320p3d51BzuU4jwWo&m=NRfb1MJwkrBjNFN2JsVch1xeEx1gcRcCHVUCfaP6qdk&s=55v2jebnRtdtzA2196WpOC8EirvhvwdhP4RA8T_H3cU&e=
Documentation: https://urldefense.proofpoint.com/v2/url?u=http-3A__www.balabit.com_support_documentation_-3Fproduct-3Dsyslog-2Dng&d=DwIGaQ&c=ApwzowJNAKKw3xye91w7BE1XMRKi2LN9kiMk5Csz9Zk&r=zMyZvtxRXMBKZZYKVMke9zplWK320p3d51BzuU4jwWo&m=NRfb1MJwkrBjNFN2JsVch1xeEx1gcRcCHVUCfaP6qdk&s=ir1_RaakPFQYlaVJyEhoMTn9beQ_WQw8CkF0OxI1GxY&e=
FAQ: https://urldefense.proofpoint.com/v2/url?u=http-3A__www.balabit.com_wiki_syslog-2Dng-2Dfaq&d=DwIGaQ&c=ApwzowJNAKKw3xye91w7BE1XMRKi2LN9kiMk5Csz9Zk&r=zMyZvtxRXMBKZZYKVMke9zplWK320p3d51BzuU4jwWo&m=NRfb1MJwkrBjNFN2JsVch1xeEx1gcRcCHVUCfaP6qdk&s=GO3NlZOi-4kCdd7axS3j7oNF92ekrkRcRZwMgBuXaIs&e=



More information about the syslog-ng mailing list