# Add\_process\_metadata cannot parse pid in integer

**URL:** https://discuss.elastic.co/t/add-process-metadata-cannot-parse-pid-in-integer/263380
**Category:** Beats
**Tags:** filebeat
**Created:** [February 5, 2021, 11:57am UTC](https://discuss.elastic.co/t/add-process-metadata-cannot-parse-pid-in-integer/263380 "2021-02-05T11:57:49Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Yin\_Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yin_zhang/32/78642_2.png) [@Yin\_Zhang](https://discuss.elastic.co/u/Yin_Zhang)
#### Post date: [February 5, 2021, 11:57am UTC](https://discuss.elastic.co/t/add-process-metadata-cannot-parse-pid-in-integer/263380/1 "2021-02-05T11:57:49Z")

</div>

Hi all,

I got some weird error when using **add\_process\_metadata** in filebeat 7.10.2. It doesn't seem to like integer value.

Given following json input:

```
{ "level": "info", "pid": 1, "message": "test1", "tags": ["tag1", "tag2"] }

```

and filebeat config:

```
logging.level: debug
filebeat.config:
  modules:
    path: ${path.config}/modules.d/*.yml
filebeat.inputs:
- type: log
  paths:
  - /tmp/test.log
  json.keys_under_root: false
  processors:
  - add_process_metadata:
      match_pids:
      - json.pid
      ignore_missing: false
output.console:
  pretty: true

```

I expected it to grab process information for pid 1. But filebeat actually threw following error:

> 2021-02-05T11:51:57.708Z DEBUG [processors] processing/processors.go:128 Fail to apply processor client{add\_process\_metadata=[match\_pids=[json.pid process.ppid process.parent.pid process.parent.ppid], mappings={"container.id":"container.id","process.args":"process.args","process.executable":"process.executable","process.name":"process.name","process.pid":"process.pid","process.ppid":"process.ppid","process.start\_time":"process.start\_time","process.title":"process.title"}, ignore\_missing=false, overwrite\_fields=false, restricted\_fields=false, host\_path=/, cgroup\_prefixes=[/kubepods /docker]]}: error applying add\_process\_metadata processor: cannot parse field 'json.pid' (not an integer or string)  
> 2021-02-05T11:51:57.710Z DEBUG [processors] processing/processors.go:203

If I add a convert processor to convert json.pid to string and then looks up by the new field, it actually works....

```
- convert:
    fields:
    - {from: "json.pid", to: "pr.pid", type: "string"}

```

Not sure whether this is a bug.

Thanks

---

<div class="post-metadata">

### Author: ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)
#### Post date: [February 5, 2021, 4:31pm UTC](https://discuss.elastic.co/t/add-process-metadata-cannot-parse-pid-in-integer/263380/2 "2021-02-05T16:31:04Z")

</div>

The example log you have shared misses the last closing `}`. When I tried running Filebeat with that line, I got an error. But after I fixed the log line, it was able to parse the event correctly.

Are you sure the event you are testing with is a valid new line delimited JSON?

---

<div class="post-metadata">

### Author: ![Yin\_Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yin_zhang/32/78642_2.png) [@Yin\_Zhang](https://discuss.elastic.co/u/Yin_Zhang)
#### Post date: [February 5, 2021, 6:14pm UTC](https://discuss.elastic.co/t/add-process-metadata-cannot-parse-pid-in-integer/263380/3 "2021-02-05T18:14:23Z")

</div>

Hi Noémi,

That is a copy and paste error. The log parsed fine, but it doesn't contain process metadata unless I changed the type of PID to string

---

<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: [March 5, 2021, 8:14pm UTC](https://discuss.elastic.co/t/add-process-metadata-cannot-parse-pid-in-integer/263380/4 "2021-03-05T20:14:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)
#### Post date: [July 9, 2021, 8:11pm UTC](https://discuss.elastic.co/t/add-process-metadata-cannot-parse-pid-in-integer/263380/5 "2021-07-09T20:11:47Z")

</div>



---

<div class="post-metadata">

### Author: ![adrisr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrisr/32/25423_2.png) [@adrisr](https://discuss.elastic.co/u/adrisr)
#### Post date: [July 9, 2021, 8:40pm UTC](https://discuss.elastic.co/t/add-process-metadata-cannot-parse-pid-in-integer/263380/6 "2021-07-09T20:40:03Z")

</div>

Hi @Yin_Zhang, thanks for reporting!

This is indeed a bug. I've created an issue for it: [add\_process\_metadata fails to parse pid from valid integer fields · Issue #26830 · elastic/beats · GitHub](https://github.com/elastic/beats/issues/26830)

And a fix is underway in [add\_process\_metadata: Support different integer types for pid field by adriansr · Pull Request #26829 · elastic/beats · GitHub](https://github.com/elastic/beats/pull/26829)

---

<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 4, 2022, 8:23am UTC](https://discuss.elastic.co/t/add-process-metadata-cannot-parse-pid-in-integer/263380/7 "2022-11-04T08:23:26Z")

</div>


