# How can update logstash field value?

**URL:** <https://discuss.elastic.co/t/how-can-update-logstash-field-value/162110>\
**Category:** Logstash\
**Created:** [December 26, 2018, 7:58am UTC](https://discuss.elastic.co/t/how-can-update-logstash-field-value/162110 "2018-12-26T07:58:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abu.sayeed](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@abu.sayeed](https://discuss.elastic.co/u/abu.sayeed)\
**Post date:** [December 26, 2018, 7:58am UTC](https://discuss.elastic.co/t/how-can-update-logstash-field-value/162110/1 "2018-12-26T07:58:39Z")

</div>

Logstash field:

```
"keywords" => [
     [0] "Audit Success"
 ]

```

I wish:  
"keywords" =\> "Audit Success"

---

<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:** [December 26, 2018, 9:48pm UTC](https://discuss.elastic.co/t/how-can-update-logstash-field-value/162110/2 "2018-12-26T21:48:41Z")

</div>

How was this field created? Showing your current configuration is probably helpful.

---

<div class="post-metadata">

**Author:** ![abu.sayeed](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@abu.sayeed](https://discuss.elastic.co/u/abu.sayeed)\
**Post date:** [December 27, 2018, 4:14am UTC](https://discuss.elastic.co/t/how-can-update-logstash-field-value/162110/3 "2018-12-27T04:14:24Z")

</div>

```
filter {
if [type] == "wineventlog" {

ruby {
code => "
  event.get('event_data').each {|k, v|
    event.set(k, v)
  }
  event.remove('event_data')
"
}

mutate {
  rename => ["[host][name]", "hostname" ]
  rename => ["[user][identifier]", "user_identifier" ]
  rename => ["[user][type]", "user_type" ]
  rename => ["[user][domain]", "user_domain" ]
  rename => ["[user][name]", "user.name" ]
}
mutate {
   remove_field => ["tags", "opcode", "@version", "beat", "message", "LogonGuid", "ProcessId", "ProcessName", "SubjectLogonId", "SubjectUserSid", "TargetInfo", "TargetLogonGuid", "activity_id", "event_id", "opcode", "process_id", "provider_guid", "record_number", "param10", "param11", "param2", "param4", "param5", "param8", "thread_id", "param7", "LmPackageName", "PrivilegeList", "IpPort", "ImpersonationLevel", "KeyLength", "TransmittedServices", "TargetLogonId", "TargetUserSid", "host"]
   }
  }
 }

  available fields like:
  "keywords" => [
        [0] "Download",
        [1] "Started"
        ],

   I wish:
   keywords_Download => 0
   keywords_Download_started => 1

     How can split those fields?
    Thank You.
```

---

<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:** [January 6, 2019, 8:12pm UTC](https://discuss.elastic.co/t/how-can-update-logstash-field-value/162110/4 "2019-01-06T20:12:49Z")

</div>

Okay. And `keywords` is initially `[event_data][keywords]`? Changing `event.set(k, v)` to `event.set(k, v[0])` will extract the first element of the array, but it assumes that all values in `event_data` are arrays which might not be true. You can use a conditional to check the type of `v` and only access the first array element if `v` actually is an array.

---

<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:** [February 3, 2019, 8:12pm UTC](https://discuss.elastic.co/t/how-can-update-logstash-field-value/162110/5 "2019-02-03T20:12:51Z")

</div>

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