# How to set the \[id\] field to value of \[path\] field (input-file)

**URL:** <https://discuss.elastic.co/t/how-to-set-the-id-field-to-value-of-path-field-input-file/69547>\
**Category:** Logstash\
**Created:** [December 20, 2016, 9:53am UTC](https://discuss.elastic.co/t/how-to-set-the-id-field-to-value-of-path-field-input-file/69547 "2016-12-20T09:53:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tao\_Zhang](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@Tao\_Zhang](https://discuss.elastic.co/u/Tao_Zhang)\
**Post date:** [December 20, 2016, 9:53am UTC](https://discuss.elastic.co/t/how-to-set-the-id-field-to-value-of-path-field-input-file/69547/1 "2016-12-20T09:53:48Z")

</div>

My GOAL:  
I want set id to managementID like below when input a file:

> Ex.  
> input-file-path: \servername\*\managementID\*\input-file.txt

The managementID is a unique value and I want update the file by this ID.  
Maybe set id to (the part of) input-file-path is a way to Achieve my goal. Is it possible?

If there is a better way to do it , please teach me.

Best regards.

---

<div class="post-metadata">

**Author:** ![jakommo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jakommo/32/6716_2.png) [@jakommo](https://discuss.elastic.co/u/jakommo)\
**Post date:** [December 20, 2016, 2:30pm UTC](https://discuss.elastic.co/t/how-to-set-the-id-field-to-value-of-path-field-input-file/69547/2 "2016-12-20T14:30:02Z")

</div>

Hi @Tao_Zhang,

my understanding is that you want to parse out the managementID from the path of the files, correct?

You could use a grok filter like the following, to just parse the ID and create a new field with that ID.  
E.g.  
LS config:

```
input {
  file {
path => "/logs/managementID*/*.log"
  }
}

filter {
  grok {
match => ["path", "%{NOTSPACE}/managementID%{INT:managementID}/%{NOTSPACE}"]
  }
}

output {
  stdout { codec => rubydebug }
}

```

This would create events like:

```
{
            "path" => "/logs/managementID123/example.log",
      "@timestamp" => 2016-12-20T14:21:30.131Z,
    "managementID" => "123",
        "@version" => "1",
            "host" => "es-jre",
         "message" => "test2",
            "tags" => []
}
{
            "path" => "/logs/managementID456/example.log",
      "@timestamp" => 2016-12-20T14:21:30.154Z,
    "managementID" => "456",
        "@version" => "1",
            "host" => "es-jre",
         "message" => "test1",
            "tags" => []
}

```

With "managementID" =\> "123" and "managementID" =\> "456" parsed from the files path.

> and I want update the file by this ID.

I'm just not sure what you mean by that? Can you provide more details?

/jakob

---

<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:** [January 17, 2017, 2:30pm UTC](https://discuss.elastic.co/t/how-to-set-the-id-field-to-value-of-path-field-input-file/69547/3 "2017-01-17T14:30:11Z")

</div>

Closed on January 17, 2017, 2:30pm UTC

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