Insert data depending on match and

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,

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 ^.

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