# Insert data depending on match and

**URL:** <https://discuss.elastic.co/t/insert-data-depending-on-match-and/83457>\
**Category:** Logstash\
**Created:** [April 24, 2017, 8:50pm UTC](https://discuss.elastic.co/t/insert-data-depending-on-match-and/83457 "2017-04-24T20:50:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bob\_monty](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bob_monty/32/102434_2.png) [@bob\_monty](https://discuss.elastic.co/u/bob_monty)\
**Post date:** [April 24, 2017, 8:50pm UTC](https://discuss.elastic.co/t/insert-data-depending-on-match-and/83457/1 "2017-04-24T20:50:20Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 25, 2017, 7:23am UTC](https://discuss.elastic.co/t/insert-data-depending-on-match-and/83457/2 "2017-04-25T07:23:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 23, 2017, 7:30am UTC](https://discuss.elastic.co/t/insert-data-depending-on-match-and/83457/3 "2017-05-23T07:30:18Z")

</div>

Closed on May 23, 2017, 7:30am UTC

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