# Grok pattern matching from MAC access

**URL:** <https://discuss.elastic.co/t/grok-pattern-matching-from-mac-access/104387>\
**Category:** Logstash\
**Created:** [October 18, 2017, 12:15pm UTC](https://discuss.elastic.co/t/grok-pattern-matching-from-mac-access/104387 "2017-10-18T12:15:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mussa572](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@mussa572](https://discuss.elastic.co/u/mussa572)\
**Post date:** [October 18, 2017, 12:15pm UTC](https://discuss.elastic.co/t/grok-pattern-matching-from-mac-access/104387/1 "2017-10-18T12:15:51Z")

</div>

Hi

wondering if some one can help . We are ingesting some of the Linux Inventory in Elastic Search . One of the field is MAC address (00:50:56:a9:2c:51) .

We are looking for the if condition where if 4 charter of MAC address are 00:50 then we want to add the new field with Hardware = Virtual .

is there a way extract the value to using regex in Logstash .

regards

---

<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:** [October 18, 2017, 8:29pm UTC](https://discuss.elastic.co/t/grok-pattern-matching-from-mac-access/104387/2 "2017-10-18T20:29:12Z")

</div>

```nohighlight
if [name-of-field] =~ /^00:50:/ {
  mutate {
    add_field => {
      "Hardware" => "Virtual"
    }
  }
}

```

---

<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:** [November 15, 2017, 8:29pm UTC](https://discuss.elastic.co/t/grok-pattern-matching-from-mac-access/104387/3 "2017-11-15T20:29:46Z")

</div>

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