Telegraf1 is an agent that is capable of collecting various metrics and exporting them to various storage backends.
Setup
Telegraf is lots of options. Start with something small and simple, then iterate on adding something else to the config. Makes it easier to troubleshoot.
1[global_tags]
2[agent]
3 interval = "10s"
4 round_interval = true
5 metric_batch_size = 1000
6 metric_buffer_limit = 10000
7 collection_jitter = "0s"
8 flush_interval = "10s"
9 flush_jitter = "0s"
10 precision = ""
11 hostname = ""
12 omit_hostname = false
13[[outputs.influxdb]]
14 urls = ["http://127.0.0.1:8086"]
15 database = "telegraf"
16 skip_database_creation = false
17[[inputs.snmp]]
18 agents = ["udp://192.168.0.1:161"]
19 interval = "60s"
20 timeout = "10s"
21 version = 1
22 community = "public"
23 retries = 3
24 [[inputs.snmp.field]]
25 name = "hostname"
26 oid = "RFC1213-MIB::sysName.0"
27 is_tag = true
28 [[inputs.snmp.field]]
29 name = "uptime"
30 oid = ".1.3.6.1.2.1.1.3.0"
31 # IF-MIB::ifTable contains counters on input and output traffic as well as
32 # errors and discards. EtherLike-MIB::dot3StatsTable contains detailed
33 # ethernet-level information about what kind of errors have been logged on an
34 # interface (such as FCS error, frame too long, etc)
35 [[inputs.snmp.table]]
36 name = "interface"
37 inherit_tags = [ "hostname" ]
38 [[inputs.snmp.table.field]]
39 name = "ifName"
40 oid = "IF-MIB::ifName"
41 is_tag = true
42 [[inputs.snmp.table.field]]
43 name = "ifAlias"
44 oid = "IF-MIB::ifAlias"
45 is_tag = true
46 [[inputs.snmp.table.field]]
47 name = "ifDescr"
48 oid = "IF-MIB::ifDescr"
49 is_tag = true
50 [[inputs.snmp.table.field]]
51 oid = "IF-MIB::ifHighSpeed"
52 [[inputs.snmp.table.field]]
53 oid = "IF-MIB::ifAdminStatus"
54 [[inputs.snmp.table.field]]
55 oid = "IF-MIB::ifOperStatus"
56 [[inputs.snmp.table.field]]
57 oid = "IF-MIB::ifHCInOctets"
58 [[inputs.snmp.table.field]]
59 oid = "IF-MIB::ifHCOutOctets"
60 [[inputs.snmp.table.field]]
61 oid = "IF-MIB::ifInDiscards"
62 [[inputs.snmp.table.field]]
63 oid = "IF-MIB::ifOutDiscards"
64 [[inputs.snmp.table.field]]
65 oid = "IF-MIB::ifInErrors"
66 [[inputs.snmp.table.field]]
67 oid = "IF-MIB::ifOutErrors"
68 [[inputs.snmp.table.field]]
69 oid = "IF-MIB::ifInUnknownProtos"
70 [[inputs.snmp.table.field]]
71 oid = "IF-MIB::ifHCInUcastPkts"
72 [[inputs.snmp.table.field]]
73 oid = "IF-MIB::ifHCOutUcastPkts"
74 [[inputs.snmp.table.field]]
75 oid = "IF-MIB::ifHCInBroadcastPkts"
76 [[inputs.snmp.table.field]]
77 oid = "IF-MIB::ifHCOutBroadcastPkts"
78 [[inputs.snmp.table.field]]
79 oid = "IF-MIB::ifHCInMulticastPkts"
80 [[inputs.snmp.table.field]]
81 oid = "IF-MIB::ifHCOutMulticastPkts"
Here is the config I started with. It collects a small number of things from a single device. In this case, a Juniper SRX100. Things I changed from the defaults:
- URL for influxdb
- Database name
- SNMP agents
- SNMP community
- The sub-sections for SNMP (I hard-coded the OID because it wasn’t working with the MIB name)
You can test your telegraf config by doing
1$ telegraf --test --config /path/to/telegraf.conf
2...
3$
There should be plenty of output that is collected from the SNMP device configured, and no errors.
Viewing the data we collected
1root@monitoring:~ # influx
2Connected to http://localhost:8086 version 1.8.0
3InfluxDB shell version: 1.8.0
4> use telegraf
5Using database telegraf
6> show measurements
7name: measurements
8name
9----
10interface
11> select * from interface limit 2
12name: interface
13time agent_host dot3StatsAlignmentErrors dot3StatsCarrierSenseErrors dot3StatsDeferredTransmissions dot3StatsDuplexStatus dot3StatsEtherChipSet dot3StatsExcessiveCollisions dot3StatsFCSErrors dot3StatsFrameTooLongs dot3StatsIndex dot3StatsInternalMacReceiveErrors dot3StatsInternalMacTransmitErrors dot3StatsLateCollisions dot3StatsMultipleCollisionFrames dot3StatsSQETestErrors dot3StatsSingleCollisionFrames dot3StatsSymbolErrors host hostname ifAdminStatus ifAlias ifConnectorPresent ifCounterDiscontinuityTime ifDescr ifHCInBroadcastPkts ifHCInMulticastPkts ifHCInOctets ifHCInUcastPkts ifHCOutBroadcastPkts ifHCOutMulticastPkts ifHCOutOctets ifHCOutUcastPkts ifHighSpeed ifInBroadcastPkts ifInDiscards ifInErrors ifInMulticastPkts ifInNUcastPkts ifInOctets ifInUcastPkts ifInUnknownProtos ifIndex ifLastChange ifLinkUpDownTrapEnable ifMtu ifName ifOperStatus ifOutBroadcastPkts ifOutDiscards ifOutErrors ifOutMulticastPkts ifOutNUcastPkts ifOutOctets ifOutQLen ifOutUcastPkts ifPhysAddress ifPromiscuousMode ifSpecific ifSpeed ifType
14---- ---------- ------------------------ --------------------------- ------------------------------ --------------------- --------------------- ---------------------------- ------------------ ---------------------- -------------- --------------------------------- ---------------------------------- ----------------------- -------------------------------- ---------------------- ------------------------------ --------------------- ---- -------- ------------- ------- ------------------ -------------------------- ------- ------------------- ------------------- ------------ --------------- -------------------- -------------------- ------------- ---------------- ----------- ----------------- ------------ ---------- ----------------- -------------- ---------- ------------- ----------------- ------- ------------ ---------------------- ----- ------ ------------ ------------------ ------------- ----------- ------------------ --------------- ----------- --------- -------------- ------------- ----------------- ---------- ------- ------
151595976547000000000 192.168.2.1 monitoring srx100.lab 1 ge-0/0/10.0 0 0 0 0 0 0 506 3693 1514 7 0 0 0 0 0 0 54:e0:32:2f:86:8d .0.0 0 53
161595976547000000000 192.168.2.1 monitoring srx100.lab 1 ge-0/0/11 0 0 0 0 0 0 507 3369 1514 2 0 0 0 0 0 0 54:e0:32:2f:86:8e .0.0 0 6
17>
18root@monitoring:~ #
Looks like we’re successfully storing data in InfluxDB2.
Conclusion
Next up, setting up visualizations.
Comments