# Logstash filter: copying values after split

**URL:** <https://discuss.elastic.co/t/logstash-filter-copying-values-after-split/170754>\
**Category:** Logstash\
**Created:** [March 4, 2019, 3:50pm UTC](https://discuss.elastic.co/t/logstash-filter-copying-values-after-split/170754 "2019-03-04T15:50:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fringeadmin](https://avatars.discourse-cdn.com/v4/letter/f/bb73d2/32.png) [@fringeadmin](https://discuss.elastic.co/u/fringeadmin)\
**Post date:** [March 4, 2019, 3:50pm UTC](https://discuss.elastic.co/t/logstash-filter-copying-values-after-split/170754/1 "2019-03-04T15:50:16Z")

</div>

I have azure event hub data coming into logstash via the eponymous plugin. I get huge junks of json that contain multiple events which I then have to split into distinct events. Here is a simplified example:

```
{"records": [
{ "LogicalServerName": "myservername", "SubscriptionId": "mysubid-uuid", "ResourceGroup": "Prod", "time": "2019-02-15T17:44:23.3870000Z", "resourceId": "/SUBSCRIPTIONS/mysubid-uuid/RESOURCEGROUPS/PROD/PROVIDERS/MICROSOFT.SQL/SERVERS/myservername/DATABASES/MASTER", "category": "SQLSecurityAuditEvents", "operationName": "AuditEvent"},
{ "LogicalServerName": "myservername", "SubscriptionId": "mysubid-uuid", "ResourceGroup": "Prod", "time": "2019-02-15T17:44:23.3870000Z", "resourceId": "/SUBSCRIPTIONS/mysubid-uuid/RESOURCEGROUPS/PROD/PROVIDERS/MICROSOFT.SQL/SERVERS/myservername/DATABASES/MASTER", "category": "SQLSecurityAuditEvents", "operationName": "AuditEvent"}
]}

```

After the split I'm trying to copy the key LogicalServerName into a custom field called sourceHost. This is to normalize the input from a variety of services. Unfortunately, it doesn't seem to work. Records.LogicalServerName has the correct value, but the sourceHost field is just blank.

Here's the filter I'm trying to use:

```
filter {
    if [type] == "azure_event_hub" {
        json {
            source => "message"
        }
        split {
            field => ["records"]
        }
        mutate {
            # Map the requestHost to a standard hostname field
            copy => { "records.LogicalServerName" => "sourceHost" }
        }
    }
}

```

What am I missing here?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [March 4, 2019, 4:17pm UTC](https://discuss.elastic.co/t/logstash-filter-copying-values-after-split/170754/2 "2019-03-04T16:17:40Z")

</div>

Try

```
 copy => { "[records][LogicalServerName]" => "sourceHost" }
```

---

<div class="post-metadata">

**Author:** ![fringeadmin](https://avatars.discourse-cdn.com/v4/letter/f/bb73d2/32.png) [@fringeadmin](https://discuss.elastic.co/u/fringeadmin)\
**Post date:** [March 4, 2019, 5:14pm UTC](https://discuss.elastic.co/t/logstash-filter-copying-values-after-split/170754/3 "2019-03-04T17:14:11Z")

</div>

That was the magic! Thank you very much. I must not have been googling the right things, because that never came up as one of the dozen or so things I tried.

---

<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:** [April 1, 2019, 5:27pm UTC](https://discuss.elastic.co/t/logstash-filter-copying-values-after-split/170754/4 "2019-04-01T17:27:34Z")

</div>

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