# CPU Usage of Specific Process

**URL:** <https://discuss.elastic.co/t/cpu-usage-of-specific-process/82863>\
**Category:** Elasticsearch\
**Created:** [April 19, 2017, 10:29am UTC](https://discuss.elastic.co/t/cpu-usage-of-specific-process/82863 "2017-04-19T10:29:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prakash1243](https://avatars.discourse-cdn.com/v4/letter/p/35a633/32.png) [@prakash1243](https://discuss.elastic.co/u/prakash1243)\
**Post date:** [April 19, 2017, 10:29am UTC](https://discuss.elastic.co/t/cpu-usage-of-specific-process/82863/1 "2017-04-19T10:29:12Z")

</div>

Hi-  
Am trying to get the Maximum aggregated value for a specific process using Ruby Client. Here is the query I created:

```
def get_process_cpu(hostname)
  begin
    res = @client.search index: 'metricbeat-*', body:
        {
            "size": 0,
            "aggs": {
                "1": {
                    "max": {
                        "field": "system.process.cpu.total.pct"
                    }
                }
            },
            "query": {
                "bool": {
                    "must": [
                        {
                            "query_string": {
                                "query": "metricset.name: process",
                            }
                        },
                        {
                            "match": {
                                "beat.name": {
                                    "query": "#{hostname}",
                                    "type": "phrase"
                                }
                            }
                        },
                        {
                            "match": {
                                "system.process.name": {
                                    "query": "metricbeat.exe",
                                    "type": "phrase"
                                }
                            }
                        }
                    ]
                }
            }
        }

```

But, I think am getting the max percentage among all the processes not specific to metricbeat.exe... Could some one please have a look into the query and let me know if any thing wrong. Thanks !

---

<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:** [May 17, 2017, 10:41am UTC](https://discuss.elastic.co/t/cpu-usage-of-specific-process/82863/2 "2017-05-17T10:41:32Z")

</div>

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