@@ -159,6 +159,43 @@ func (d *sflowv5Decoder) Decode(srcIP net.IP, payload []byte) ([]telegraf.Metric
159
159
fields [k ] = v
160
160
}
161
161
metrics = append (metrics , metric .New ("netflow" , tags , fields , t ))
162
+ case sflow.DropSample :
163
+ fields := map [string ]interface {}{
164
+ "ip_version" : decodeSflowIPVersion (msg .IPVersion ),
165
+ "sys_uptime" : msg .Uptime ,
166
+ "agent_subid" : msg .SubAgentId ,
167
+ "seq_number" : sample .Header .SampleSequenceNumber ,
168
+ "sampling_drops" : sample .Drops ,
169
+ "in_snmp" : sample .Input ,
170
+ "out_snmp" : sample .Output ,
171
+ "reason" : sample .Reason ,
172
+ }
173
+
174
+ var err error
175
+ fields ["agent_ip" ], err = decodeIP (msg .AgentIP )
176
+ if err != nil {
177
+ return nil , fmt .Errorf ("decoding 'agent_ip' failed: %w" , err )
178
+ }
179
+
180
+ // Decode the source information
181
+ if name := decodeSflowSourceInterface (sample .Header .SourceIdType ); name != "" {
182
+ fields [name ] = sample .Header .SourceIdValue
183
+ }
184
+ // Decode the sampling direction
185
+ if sample .Header .SourceIdValue == sample .Input {
186
+ fields ["direction" ] = "ingress"
187
+ } else {
188
+ fields ["direction" ] = "egress"
189
+ }
190
+ recordFields , err := d .decodeFlowRecords (sample .Records )
191
+ if err != nil {
192
+ return nil , err
193
+ }
194
+ for k , v := range recordFields {
195
+ fields [k ] = v
196
+ }
197
+ metrics = append (metrics , metric .New ("netflow" , tags , fields , t ))
198
+
162
199
default :
163
200
return nil , fmt .Errorf ("unknown record type %T" , s )
164
201
}
@@ -249,9 +286,6 @@ func (d *sflowv5Decoder) decodeFlowRecords(records []sflow.FlowRecord) (map[stri
249
286
case sflow.ExtendedGateway :
250
287
var err error
251
288
fields ["next_hop_ip_version" ] = record .NextHopIPVersion
252
- if err != nil {
253
- return nil , fmt .Errorf ("decoding 'next_hop' failed: %w" , err )
254
- }
255
289
fields ["next_hop" ], err = decodeIP (record .NextHop )
256
290
if err != nil {
257
291
return nil , fmt .Errorf ("decoding 'next_hop' failed: %w" , err )
@@ -276,6 +310,21 @@ func (d *sflowv5Decoder) decodeFlowRecords(records []sflow.FlowRecord) (map[stri
276
310
}
277
311
fields ["communities" ] = strings .Join (parts , "," )
278
312
fields ["local_pref" ] = record .LocalPref
313
+ case sflow.EgressQueue :
314
+ fields ["out_queue" ] = record .Queue
315
+ case sflow.ExtendedACL :
316
+ fields ["acl_id" ] = record .Number
317
+ fields ["acl_name" ] = record .Name
318
+ switch record .Direction {
319
+ case 1 :
320
+ fields ["direction" ] = "ingress"
321
+ case 2 :
322
+ fields ["direction" ] = "egress"
323
+ default :
324
+ fields ["direction" ] = "unknown"
325
+ }
326
+ case sflow.ExtendedFunction :
327
+ fields ["function" ] = record .Symbol
279
328
default :
280
329
return nil , fmt .Errorf ("unhandled flow record type %T" , r .Data )
281
330
}
0 commit comments