# Limiting number of CPU usage in filebeat

**URL:** https://discuss.elastic.co/t/limiting-number-of-cpu-usage-in-filebeat/161490
**Category:** Beats
**Tags:** filebeat
**Created:** [December 19, 2018, 10:30am UTC](https://discuss.elastic.co/t/limiting-number-of-cpu-usage-in-filebeat/161490 "2018-12-19T10:30:37Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Rishav\_Anand](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Rishav\_Anand](https://discuss.elastic.co/u/Rishav_Anand)
#### Post date: [December 19, 2018, 10:30am UTC](https://discuss.elastic.co/t/limiting-number-of-cpu-usage-in-filebeat/161490/1 "2018-12-19T10:30:37Z")

</div>

I want to limit the CPU usage by filebeat . I have tried using "max\_procs" but it doesn't seem to work . This high CPU usage may affect the performance of my app in production .  
My filebeat.yml is same as this link but i have made the changes as specified in the solution, And it doesn't seem to solve the issue.  
([Filebeat CPU usage 400%+](https://discuss.elastic.co/t/filebeat-cpu-usage-400/116095))

filebeat.yml

```
filebeat.inputs:
- type: log 

enabled: true
  max_procs: 2

# Paths that should be crawled and fetched. Glob based paths.
  paths:
       - /var/log/nx/access.log
       - /var/log/nx/error.log
       - /var/log/xyz/web.log

scan_frequency: 5m
close_renamed: true

output.logstash:
# The Logstash hosts
hosts: ["127.0.0.1:8000"] #Not real IP
protocol: "http"

processors:
- add_host_metadata: ~
- add_cloud_metadata: ~

```

Can you suggest some solution ?

Thank You.

---

<div class="post-metadata">

### Author: ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)
#### Post date: [December 21, 2018, 12:43pm UTC](https://discuss.elastic.co/t/limiting-number-of-cpu-usage-in-filebeat/161490/2 "2018-12-21T12:43:31Z")

</div>

Indentation in your configuration file looks off. Can you share your properly formatted config? (See [The configuration file format documentation](https://www.elastic.co/guide/en/beats/libbeat/current/config-file-format.html)).

Also `max_procs` is no per input setting, but a global setting. It similar to setting the GOMAXPROCS environment variable:

I guess your config should look more like this:

```auto
filebeat.inputs:
- type: log 
  paths:
    - /var/log/nginx/access.log
    - /var/log/nginx/error.log
    - /var/log/nferx/web.log
  scan_frequency: 5m
  close_renamed: true

max_procs: 2

processors:
- add_host_metadata: ~
- add_cloud_metadata: ~

output.logstash:
  hosts: ["127.0.0.1:8000"] #Not real IP

```

---

<div class="post-metadata">

### Author: ![Rishav\_Anand](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Rishav\_Anand](https://discuss.elastic.co/u/Rishav_Anand)
#### Post date: [December 27, 2018, 12:45pm UTC](https://discuss.elastic.co/t/limiting-number-of-cpu-usage-in-filebeat/161490/3 "2018-12-27T12:45:29Z")

</div>

I tried placing max\_procs as global setting it is not working for me will share the screenshot with you

 ![Screenshot%20from%202018-12-27%2018-13-39](https://us1.discourse-cdn.com/elastic/original/3X/d/6/d68703a92a17fdb839b9a20e20c54f41a0b16a62.png)

the filebeat process is using more than two CPU

---

<div class="post-metadata">

### Author: ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)
#### Post date: [December 27, 2018, 1:01pm UTC](https://discuss.elastic.co/t/limiting-number-of-cpu-usage-in-filebeat/161490/4 "2018-12-27T13:01:46Z")

</div>

What is CPU usage saying?

How do you start your beat?

`max_procs` sets the `GOMAXPROCS` environment variable. This configures the maximum number of active OS threads. If an OS thread is blocked, the runtime might start another thread. But with `max_procs: 2` CPU usage should (almost never) pass the 200% mark. If it is still at 400% check how filebeat is started and if filebeat is not started with another configuration file by accident.

---

<div class="post-metadata">

### Author: ![Rishav\_Anand](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Rishav\_Anand](https://discuss.elastic.co/u/Rishav_Anand)
#### Post date: [December 28, 2018, 6:10am UTC](https://discuss.elastic.co/t/limiting-number-of-cpu-usage-in-filebeat/161490/5 "2018-12-28T06:10:27Z")

</div>

sudo service filebeat start  
sudo filebeat -e -c /etc/filebeat/filebeat.yml

i am using htop to see the number of cores its using.  
According to me it should not use more than two cores. Am i wrong ?

> `max_procs` sets the `GOMAXPROCS` environment variable. This configures the maximum number of active OS threads. If an OS thread is blocked, the runtime might start another thread. But with `max_procs: 2` CPU usage should (almost never) pass the 200% mark. If it is still at 400% check how filebeat is started and if filebeat is not started with another configuration file by accident.

I have not sent logs in large number so for me its giving me 0.0% usage

---

<div class="post-metadata">

### Author: ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)
#### Post date: [January 2, 2019, 12:39pm UTC](https://discuss.elastic.co/t/limiting-number-of-cpu-usage-in-filebeat/161490/6 "2019-01-02T12:39:09Z")

</div>

> i am using htop to see the number of cores its using.  
> According to me it should not use more than two cores. Am i wrong ?

The runtime might use more OS threads (cores). The `max_procs` setting configures the maximum number of 'ACTIVE' OS threads. If an OS Threads blocks (e.g. during syscalls), it becomes inactive. In this case the runtime might use another OS Threads, so other go-routines can still work.

---

<div class="post-metadata">

### Author: ![Rishav\_Anand](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Rishav\_Anand](https://discuss.elastic.co/u/Rishav_Anand)
#### Post date: [January 2, 2019, 12:53pm UTC](https://discuss.elastic.co/t/limiting-number-of-cpu-usage-in-filebeat/161490/7 "2019-01-02T12:53:49Z")

</div>

Thank You for the help . its working properly.👍

---

<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 30, 2019, 1:04pm UTC](https://discuss.elastic.co/t/limiting-number-of-cpu-usage-in-filebeat/161490/8 "2019-01-30T13:04:33Z")

</div>

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