Hi guys,

I'm battling to get my head around parsing JSON on my log server.  I'm
receiving Apache events in JSON and added a few variables.

{"properties": 
{"programname":"apache_access","hostname":"foobar","environment":"dev","time":"2015-11-06T07:46:39.496405+00:00"},"message":{"raw_msg":"<182>Nov
 6 07:46:39 apache_access: 192.168.1.1 - - [06/Nov/2015:07:46:39
+0000] \"GET / HTTP/1.1\" 200 3593 \"-\" \"Mozilla/5.0 (Windows NT
6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71
Safari/537.36\""}}

Now, I want to pull out the environment variable and use it to
construct my filesystem layout.

The template I want to create is something like this:

$template 
apache_access,"/var/log/remote/$!environment/httpd/%hostname%/access_log_%$YEAR%-%$MONTH%-%$DAY%"

Then:

if $fromhost-ip !='127.0.0.1'  then -?apache_access

Any idea how I can extract "environment":"dev" from the JSON above.

Thanks,
Gareth
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to