Reputation: 81
I need to seperate the output log files based on path, so I need to make a regex condition like this:
if [path] =~ "/var/log/nginx/json_access/live.json.log" {
file {path => /home/user/output.live.txt} }
if [path] =~ "/var/log/nginx/json_access/video.json.log" { file {path => /home/user/output.video.txt} }
but it does not worked, how to write a exactly regex with the if condition logstash
Upvotes: 0
Views: 530
Reputation: 1651
I think there is a syntax error in your regex. You need to escape the slashes and more importantly the .
Try these regex's:
if [path] =~ "\/var\/log\/nginx\/json_access\/live\.json\.log" {
file {path => /home/user/output.live.txt} }
if [path] =~ "\/var\/log\/nginx\/json_access\/video\.json\.log" { file {path => /home/user/output.video.txt} }
Before creating your logstash config, simply check your regex with an online checker such as http://regexr.com
Upvotes: 1