formatterimpl

package
v0.0.0-...-c0f4c10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package formatterimpl implements the formatter component.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockModule

func MockModule() fxutil.Module

MockModule provides a dummy formatter that just hashes packets.

func Module

func Module() fxutil.Module

Module implements the formatter component.

Types

type JSONFormatter

type JSONFormatter struct {
	// contains filtered or unexported fields
}

JSONFormatter is a Formatter implementation that transforms Traps into JSON

func (JSONFormatter) FormatPacket

func (f JSONFormatter) FormatPacket(packet *packet.SnmpPacket) ([]byte, error)

FormatPacket converts a raw SNMP trap packet to a FormattedSnmpPacket containing the JSON data and the tags to attach

{
  "trap": {
    "ddsource": "snmp-traps",
    "ddtags": "namespace:default,snmp_device:10.0.0.2,...",
    "timestamp": 123456789,
    "snmpTrapName": "...",
    "snmpTrapOID": "1.3.6.1.5.3.....",
    "snmpTrapMIB": "...",
    "uptime": "12345",
    "genericTrap": "5", # v1 only
    "specificTrap": "0",  # v1 only
    "variables": [
      {
        "oid": "1.3.4.1....",
        "type": "integer",
        "value": 12
      },
      ...
    ],
  }
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL