# Create custom metricbeat fields

**URL:** <https://discuss.elastic.co/t/create-custom-metricbeat-fields/178757>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [April 27, 2019, 2:14pm UTC](https://discuss.elastic.co/t/create-custom-metricbeat-fields/178757 "2019-04-27T14:14:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mladen](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mladen](https://discuss.elastic.co/u/mladen)\
**Post date:** [April 27, 2019, 2:14pm UTC](https://discuss.elastic.co/t/create-custom-metricbeat-fields/178757/1 "2019-04-27T14:14:09Z")

</div>

Hello,

For purpose of monitoring CPU utilization per service I have created custom metricbeat fields. Using metricbeat all data are transferred to logstash pipeline.

This is my filter section:

> filter {  
> if [system][process] {  
> if [system][process][cmdline] {  
> if [system][process][cmdline] =~ "DataFlowEngine\s.\*" {  
> grok {  
> match =\> {  
> "[system][process][cmdline]" =\> "^%{WORD} %{WORD} %{NOTSPACE} %{WORD:[system][process][eg\_group]}$"  
> }  
> add\_field =\> { "system.process.cpu.total.%{[system][process][eg\_group]}" =\> "%{[system][process][cpu][total][pct]}" }  
> remove\_field =\> "[system][process][cmdline]"  
> }  
> }  
> }  
> }  
> }

Logstash pipeline basically copy field system.process.cpu.total.pct and change the name based on cmd field of the process.

I have a problem to create proper kibana index pattern for custom metricbeat fields. Using setup.template.append\_fields in metricbeat.yml file I managed to create fields with name and type that I need but I can’t proper format of the fields (in my case format is percent).

I add following line in my metricbeat.yml file:

> setup.template.append\_fields:
> 
> - name: system.process.cpu.total.address  
> type: scaled\_float  
> format: percent
> - name: system.process.cpu.total.crm  
> type: scaled\_float  
> format: percent
> - name: system.process.cpu.total.dms  
> type: scaled\_float  
> format: percent
> - name: system.process.cpu.total.erp  
> type: scaled\_float  
> format: percent

I presume that format isn’t possible to setup using metricbeat.yml?

I also try with creating custom metricbeat and fields.yml but with no luck.

Do you have any idea how to solve my problem or suggestion for another approach?

I have 6.7.1 version for all components.

BR,  
Mladen

---

<div class="post-metadata">

**Author:** ![Mario\_Castro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario_castro/32/35107_2.png) [@Mario\_Castro](https://discuss.elastic.co/u/Mario_Castro)\
**Post date:** [April 29, 2019, 11:24am UTC](https://discuss.elastic.co/t/create-custom-metricbeat-fields/178757/2 "2019-04-29T11:24:23Z")

</div>

Hi @mladen 🙂

The best place to setup format is in the index pattern definition in Kibana. Once the index pattern is created, you can navigate on each field and setup the formatting it needs:

![image](https://us1.discourse-cdn.com/elastic/original/3X/c/8/c8eeae8d6eddb006831b6d69680980c07e0ed89e.png)

At the right, you can press the pencil and set a proper formatting for each field, including percentages.

---

<div class="post-metadata">

**Author:** ![mladen](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mladen](https://discuss.elastic.co/u/mladen)\
**Post date:** [April 29, 2019, 11:12pm UTC](https://discuss.elastic.co/t/create-custom-metricbeat-fields/178757/3 "2019-04-29T23:12:04Z")

</div>

Hello @Mario_Castro, thank you for your answer. I was thinking to change format as you suggested but I was scared what will happen with index pattern 🙂 . I do as you suggest and everything works fine.

Once more many thanks for your help.

BR,  
Mladen

---

<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 27, 2019, 11:12pm UTC](https://discuss.elastic.co/t/create-custom-metricbeat-fields/178757/4 "2019-05-27T23:12:07Z")

</div>

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