# SNMP/SNMPTRAP input with filter and output to CSV

**URL:** <https://discuss.elastic.co/t/snmp-snmptrap-input-with-filter-and-output-to-csv/191905>\
**Category:** Logstash\
**Created:** [July 23, 2019, 8:01pm UTC](https://discuss.elastic.co/t/snmp-snmptrap-input-with-filter-and-output-to-csv/191905 "2019-07-23T20:01:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![icecotorra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icecotorra/32/50771_2.png) [@icecotorra](https://discuss.elastic.co/u/icecotorra)\
**Post date:** [July 23, 2019, 8:01pm UTC](https://discuss.elastic.co/t/snmp-snmptrap-input-with-filter-and-output-to-csv/191905/1 "2019-07-23T20:01:39Z")

</div>

Hello,

I want to be able to grab the output of any SNMP/SNMPTRAP and structure it so it can be exported to a CSV file. I will then take the file and import it to another box running Elasticsearch and Kibana.

Can you please point me to the direction of a grok filter and output section that can help me understand how to do this?

From what I see not too many people in this forum are using the ELK to parse and manipulate SNMP data.

Output lines are for testing, I know I have to do a CSV plugin output from logstash.

Thanks.

My \*.conf file:

> Blockquote

input {  
snmptrap {  
host =\> "0.0.0.0"  
community =\> "public"  
port =\> "162"  
}  
}

input {  
snmp {  
get =\> [".1.3.6.1.2.1.1.3.0", ".1.3.6.1.2.1.2.2.1.2.2"]  
hosts =\> [{host =\> "udp:10.30.30.1/161" community =\> "public" version =\> "2c" retries =\> 2 timeout =\> 1000}]  
}  
}

output {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "mikrotik"  
}  
stdout { codec =\> rubydebug }  
}

> Blockquote

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 23, 2019, 9:06pm UTC](https://discuss.elastic.co/t/snmp-snmptrap-input-with-filter-and-output-to-csv/191905/2 "2019-07-23T21:06:16Z")

</div>

If I use that snmp input I get

```
  "iso.org.dod.internet.mgmt.mib-2.system.sysUpTime.sysUpTimeInstance" => 202330,
"iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifDescr.2" => "error: no such instance currently exists at this OID",

```

Personally I would adjust that using 'oid\_root\_skip =\> 6' to get the easier to read

```
  "system.sysUpTime.sysUpTimeInstance" => 198404,
"interfaces.ifTable.ifEntry.ifDescr.0" => "error: no such instance currently exists at this OID",

```

Unfortunately this is a terrible match for a csv filter. I would suggest something like

```
output { file { path => "/some/path/snmp.txt" codec => json_lines } }

```

Not sure what you are looking to do with grok. Are there specific fields you need to parse?

---

<div class="post-metadata">

**Author:** ![icecotorra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icecotorra/32/50771_2.png) [@icecotorra](https://discuss.elastic.co/u/icecotorra)\
**Post date:** [July 23, 2019, 10:07pm UTC](https://discuss.elastic.co/t/snmp-snmptrap-input-with-filter-and-output-to-csv/191905/3 "2019-07-23T22:07:07Z")

</div>

That is a simple example config. Not finished entering all the OID info for other devices. I will have numerous devices and traps. What I really need is a filter to organize the data and export it to CSV. For example: use grok filter to grab (hostname, timestamp, interfaces, uptime, memory) and create a CSV file that is organized.

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:** [August 20, 2019, 10:07pm UTC](https://discuss.elastic.co/t/snmp-snmptrap-input-with-filter-and-output-to-csv/191905/4 "2019-08-20T22:07:09Z")

</div>

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