# Configuring fields.yml for custom Beat

**URL:** <https://discuss.elastic.co/t/configuring-fields-yml-for-custom-beat/92358>\
**Category:** Beats\
**Tags:** beats-development\
**Created:** [July 8, 2017, 10:58am UTC](https://discuss.elastic.co/t/configuring-fields-yml-for-custom-beat/92358 "2017-07-08T10:58:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Russell\_Seymour](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_seymour/32/1298_2.png) [@Russell\_Seymour](https://discuss.elastic.co/u/Russell_Seymour)\
**Post date:** [July 8, 2017, 10:58am UTC](https://discuss.elastic.co/t/configuring-fields-yml-for-custom-beat/92358/1 "2017-07-08T10:58:18Z")

</div>

I am writing a custom beat to read temperature.

I have created the Beat using this, [https://www.elastic.co/blog/build-your-own-beat](https://www.elastic.co/blog/build-your-own-beat), as an example.

However I am confused as to how to modify the fields.yml file so that the correct data types are set. I have tried adding the following to the `fields.yml` file in the root of my project:

```
- key: temperaturebeat
  title: temperaturebeat
  description:
  fields:
    - name: counter
      type: long
      required: true
      description: >
        PLEASE UPDATE DOCUMENTATION
    - name: deviceid
      type: string
    - name: sensorid
      type: string
    - name: celcius
      type: double
    - name: farenheit
      type: double

```

But each time I run `male update` the file is modified and these entries are removed. I have tried creating a file `etc/fields.yml` but the same thing happens.

My beat sort of works as it is, but the `celcius` measurement is seen as a `long` whereas the `farehnheit` is seen as a `float`. As you can see from the above I want them both to be `double`.

The following is how I am reading the values

```
func (bt *Temperaturebeat) readThermometers(dirFile string, beatname string, deviceid string) {

	// Build the pattern for the glob
	pattern := fmt.Sprintf("%s/??-????????????", dirFile)

	// Find all the files that have the specified pattern
	files, _ := filepath.Glob(pattern)
	for _, thermo := range files {

		// Create the path to the file from which to read the value
		thermoFile := fmt.Sprintf("%s/w1_slave", thermo)

		// get the C and F
		temperatureC, temperatureF := temperature(thermoFile)

		event := common.MapStr{
			"@timestamp": common.Time(time.Now()),
			"type": beatname,
			"deviceid": deviceid,
			"sensorid": path.Base(thermo),
			"celcius": temperatureC,
			"farenheit": temperatureF,
		}

		bt.client.PublishEvent(event)
	}
}

func temperature(file string) (float64, float64) {

	// Read the data in from the device
	dataBytes, err := ioutil.ReadFile(file)
	check(err)
	data := string(dataBytes)

	// Get the value of the temperature from the device
	result := regexTemp.FindStringSubmatch(data)
	tempFloat, err := strconv.ParseFloat(result[1], 64)
	check(err)

	// determine the C and F
	celcius := tempFloat / 1000
	farenheit := celcius*1.8 + 32

	return celcius, farenheit
}

```

The beat is configured to output to logstash if that makes any difference.

Any help is gratefully received.

Thanks, Russell

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [July 10, 2017, 7:09am UTC](https://discuss.elastic.co/t/configuring-fields-yml-for-custom-beat/92358/2 "2017-07-10T07:09:26Z")

</div>

Which version of libbeat are you using? The most recent one looks under the `_meta/fields.yml` for your fields file.

---

<div class="post-metadata">

**Author:** ![Russell\_Seymour](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_seymour/32/1298_2.png) [@Russell\_Seymour](https://discuss.elastic.co/u/Russell_Seymour)\
**Post date:** [July 10, 2017, 7:23am UTC](https://discuss.elastic.co/t/configuring-fields-yml-for-custom-beat/92358/3 "2017-07-10T07:23:13Z")

</div>

@ruflin, thanks for that - it is exactly where the file is.

---

<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:** [August 7, 2017, 7:38am UTC](https://discuss.elastic.co/t/configuring-fields-yml-for-custom-beat/92358/4 "2017-08-07T07:38:30Z")

</div>

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