Insert data depending on match and


(Bob Monty) #1

in my logstash config, in the output section i have the following section which works fine:

if [@measurement] =~ /(CAR_.*)/ {
influxdb {
host => "hardbor001:8086"
db => "April"
retention_policy => "30days"
...

i need to add a second 'and' condition something like:

if [@measurement] =~ /(VPN_.*)/ and HOSTNAME = "joserver001"
then insert into this db.

can someone help please?
Thanks,


(Magnus B├Ąck) #2

You basically have the correct syntax already so I'm not sure I get your question.

if [@measurement] =~ /(CAR_.*)/ and [@measurement] =~ /(VPN_.*)/ and [HOSTNAME] == "joserver001" {

Other comments:

  • The parentheses in your regular expressions are pointless.
  • So are the .*.
  • Are you looking for CAR_ or VPN_ at the beginning of @measurement? Then your expressions need to start with ^.

(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.