webhook

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Priority

func Priority(s string) (syslog.Priority, error)

Priority converts priority settings in config to syslog.Priority

func RFC3164FormatterNoPid

func RFC3164FormatterNoPid(p syslog.Priority, hostname, tag, content string) string

RFC3164FormatterNoPid is same with syslog.RFC3164Formatter except PID is removed.

Types

type Config

type Config struct {
	Mode        string   `yaml:"mode"`
	Severity    string   `yaml:"severity"`
	Facility    string   `yaml:"facility"`
	Labels      []string `yaml:"labels"`
	Annotations []string `yaml:"annotations"`
	Custom      custom   `yaml:"custom"`
}

Config is the output format configurations

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig loads configs from the specified YAML file

type Server

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

Server is a webhook server to handle messages

func New

func New(cfg *ServerCfg) (*Server, error)

New create a Server

func (*Server) Close

func (s *Server) Close()

Close closes the server

func (*Server) HandleAlert

func (s *Server) HandleAlert(w http.ResponseWriter, req *http.Request)

HandleAlert handles webhook for AlertManager

func (*Server) ListenAndServe

func (s *Server) ListenAndServe()

ListenAndServe starts the server

func (*Server) ShowVersion

func (s *Server) ShowVersion(w http.ResponseWriter, req *http.Request)

ShowVersion returns the version of this program

type ServerCfg

type ServerCfg struct {
	ListenAddr string
	SyslogAddr string
	Network    string
	Tag        string
	NoPid      bool
	Timeout    int
	Hostname   string
	Config     *Config
}

ServerCfg is the config options used by Server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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