# Extract keys from field name (not field value)

**URL:** <https://discuss.elastic.co/t/extract-keys-from-field-name-not-field-value/207406>\
**Category:** Logstash\
**Created:** [November 11, 2019, 5:54pm UTC](https://discuss.elastic.co/t/extract-keys-from-field-name-not-field-value/207406 "2019-11-11T17:54:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vshankara](https://avatars.discourse-cdn.com/v4/letter/v/8c91f0/32.png) [@vshankara](https://discuss.elastic.co/u/vshankara)\
**Post date:** [November 11, 2019, 5:54pm UTC](https://discuss.elastic.co/t/extract-keys-from-field-name-not-field-value/207406/1 "2019-11-11T17:54:24Z")

</div>

I have a requirement to retrieve filesystem utilization metrics for Linux servers via SNMP. I am utilizing logstash to do a snmp walk on HOST-RESOURCES-MIB and ingesting in to elastic. Here is how it is reported

```
**HOST-RESOURCES-MIB::hrStorageType.31** = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
**HOST-RESOURCES-MIB::hrStorageType.35** = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
**HOST-RESOURCES-MIB::hrStorageSize.31** = INTEGER: 499668
**HOST-RESOURCES-MIB::hrStorageSize.35** = INTEGER: 2558871
**HOST-RESOURCES-MIB::hrStorageDescr.31** = STRING: /
**HOST-RESOURCES-MIB::hrStorageDescr.35** = STRING: /dev/shm
**HOST-RESOURCES-MIB::hrStorageUsed.31** = INTEGER: 143316
**HOST-RESOURCES-MIB::hrStorageUsed.35** = INTEGER: 0

```

I need to dynamically extract the id's `31`, `35` so that i can use them with other fields to calculate utilization.

For eg: `31` is id for `/`. I can get the % utilization for this filesystem by `(HOST-RESOURCES-MIB::hrStorageUsed.31/HOST-RESOURCES-MIB::hrStorageSize.3) * 100`.

Please help as to how can I dynamically capture these id's from the field and loop through them in a array. Any ruby filter that could help here?

---

<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:** [December 9, 2019, 5:54pm UTC](https://discuss.elastic.co/t/extract-keys-from-field-name-not-field-value/207406/2 "2019-12-09T17:54:32Z")

</div>

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