# Add field from ECS field (winlogbeats)

**URL:** https://discuss.elastic.co/t/add-field-from-ecs-field-winlogbeats/253507
**Category:** Logstash
**Created:** [October 28, 2020, 1:17am UTC](https://discuss.elastic.co/t/add-field-from-ecs-field-winlogbeats/253507 "2020-10-28T01:17:10Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Camilo\_Diaz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/camilo_diaz/32/46512_2.png) [@Camilo\_Diaz](https://discuss.elastic.co/u/Camilo_Diaz)
#### Post date: [October 28, 2020, 1:17am UTC](https://discuss.elastic.co/t/add-field-from-ecs-field-winlogbeats/253507/1 "2020-10-28T01:17:10Z")

</div>

I am trying to add some fields to the logs coming from wingbeat 7.9 to Logstash.

I need to extract the value from either user.name or related.user and add a new 'username' field.

I was doing something like this but this just adds the text '%related.user' to the logs. Is this possible at all?

```auto
      if [type] == "winlogbeat" and [user][name] {
          mutate {
                    add_field => ["username", "%[user][name]" ]
                 }
       }

```

Thanks,  
Camilo

---

<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: [October 28, 2020, 3:46pm UTC](https://discuss.elastic.co/t/add-field-from-ecs-field-winlogbeats/253507/2 "2020-10-28T15:46:04Z")

</div>

> [@Camilo\_Diaz](#):
>
> `"%[user][name]"`

A sprintf reference should look like

```
"%{[user][name]}"

```

---

<div class="post-metadata">

### Author: ![Camilo\_Diaz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/camilo_diaz/32/46512_2.png) [@Camilo\_Diaz](https://discuss.elastic.co/u/Camilo_Diaz)
#### Post date: [October 28, 2020, 8:25pm UTC](https://discuss.elastic.co/t/add-field-from-ecs-field-winlogbeats/253507/3 "2020-10-28T20:25:45Z")

</div>

Thanks @Badger. Dunno how I missed that 🙂

Working as expected now.

---

<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 25, 2020, 8:25pm UTC](https://discuss.elastic.co/t/add-field-from-ecs-field-winlogbeats/253507/4 "2020-11-25T20:25:52Z")

</div>

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