github.com/influxdata/influxdb/v2@v2.7.6/telegraf/plugins/inputs/syslog.go (about)

     1  package inputs
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  )
     7  
     8  // Syslog is based on telegraf Syslog plugin.
     9  type Syslog struct {
    10  	baseInput
    11  	Address string `json:"server"`
    12  }
    13  
    14  // PluginName is based on telegraf plugin name.
    15  func (s *Syslog) PluginName() string {
    16  	return "syslog"
    17  }
    18  
    19  // TOML encodes to toml string
    20  func (s *Syslog) TOML() string {
    21  	return fmt.Sprintf(`[[inputs.%s]]
    22    ## Specify an ip or hostname with port - eg., tcp://localhost:6514, tcp://10.0.0.1:6514
    23    ## Protocol, address and port to host the syslog receiver.
    24    ## If no host is specified, then localhost is used.
    25    ## If no port is specified, 6514 is used (RFC5425#section-4.1).
    26    server = "%s"
    27  
    28    ## TLS Config
    29    # tls_allowed_cacerts = ["/etc/telegraf/ca.pem"]
    30    # tls_cert = "/etc/telegraf/cert.pem"
    31    # tls_key = "/etc/telegraf/key.pem"
    32  
    33    ## Period between keep alive probes.
    34    ## 0 disables keep alive probes.
    35    ## Defaults to the OS configuration.
    36    ## Only applies to stream sockets (e.g. TCP).
    37    # keep_alive_period = "5m"
    38  
    39    ## Maximum number of concurrent connections (default = 0).
    40    ## 0 means unlimited.
    41    ## Only applies to stream sockets (e.g. TCP).
    42    # max_connections = 1024
    43  
    44    ## Read timeout is the maximum time allowed for reading a single message (default = 5s).
    45    ## 0 means unlimited.
    46    # read_timeout = "5s"
    47  
    48    ## The framing technique with which it is expected that messages are transported (default = "octet-counting").
    49    ## Whether the messages come using the octect-counting (RFC5425#section-4.3.1, RFC6587#section-3.4.1),
    50    ## or the non-transparent framing technique (RFC6587#section-3.4.2).
    51    ## Must be one of "octet-counting", "non-transparent".
    52    # framing = "octet-counting"
    53  
    54    ## The trailer to be expected in case of non-transparent framing (default = "LF").
    55    ## Must be one of "LF", or "NUL".
    56    # trailer = "LF"
    57  
    58    ## Whether to parse in best effort mode or not (default = false).
    59    ## By default best effort parsing is off.
    60    # best_effort = false
    61  
    62    ## Character to prepend to SD-PARAMs (default = "_").
    63    ## A syslog message can contain multiple parameters and multiple identifiers within structured data section.
    64    ## Eg., [id1 name1="val1" name2="val2"][id2 name1="val1" nameA="valA"]
    65    ## For each combination a field is created.
    66    ## Its name is created concatenating identifier, sdparam_separator, and parameter name.
    67    # sdparam_separator = "_"
    68  `, s.PluginName(), s.Address)
    69  }
    70  
    71  // UnmarshalTOML decodes the parsed data to the object
    72  func (s *Syslog) UnmarshalTOML(data interface{}) error {
    73  	dataOK, ok := data.(map[string]interface{})
    74  	if !ok {
    75  		return errors.New("bad server for syslog input plugin")
    76  	}
    77  	s.Address, _ = dataOK["server"].(string)
    78  	return nil
    79  }