servicenow

package
v0.0.0-test3 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Whether ServiceNow integration is enabled.
	Enabled bool `toml:"enabled" override:"enabled"`
	// ServiceNow events API URL.
	URL string `toml:"url" override:"url"`
	// Event source.
	Source string `toml:"source" override:"source"`
	// ServiceNow authentication username.
	Username string `toml:"username" override:"username"`
	// ServiceNow authentication password.
	Password string `toml:"password" override:"password,redact"`
	// Whether all alerts should automatically post to ServiceNow.
	Global bool `toml:"global" override:"global"`
	// Whether all alerts should automatically use stateChangesOnly mode.
	// Only applies if global is also set.
	StateChangesOnly bool `toml:"state-changes-only" override:"state-changes-only"`
}

func NewConfig

func NewConfig() Config

func (Config) Validate

func (c Config) Validate() error

type Diagnostic

type Diagnostic interface {
	WithContext(ctx ...keyvalue.T) Diagnostic
	Error(msg string, err error)
}

type Event added in v1.5.8

type Event struct {
	Source         string `json:"source"`
	Node           string `json:"node,omitempty"`
	Type           string `json:"type,omitempty"`
	Resource       string `json:"resource,omitempty"`
	MetricName     string `json:"metric_name,omitempty"`
	MessageKey     string `json:"message_key,omitempty"`
	Severity       string `json:"severity,omitempty"`
	Description    string `json:"description,omitempty"`
	AdditionalInfo string `json:"additional_info,omitempty"`
}

Event is a structure representing ServiceNow event. It can also represent an alert.

type Events added in v1.5.8

type Events struct {
	Records []Event `json:"records"`
}

ServiceNow provides web service API which is recommended for publishing events. Multiple events can be published in a single call. https://docs.servicenow.com/bundle/paris-it-operations-management/page/product/event-management/task/send-events-via-web-service.html

type HandlerConfig

type HandlerConfig struct {
	// web service URL used to post messages.
	// If empty uses the service URL from the configuration.
	URL string `mapstructure:"url"`

	// Username for BASIC authentication.
	// If empty uses username from the configuration.
	Username string `mapstructure:"username"`

	// Password for BASIC authentication.
	// If empty uses password from the configuration.
	Password string `mapstructure:"password"`

	// Event source.
	// If empty uses source from the configuration.
	Source string `mapstructure:"source"`

	// Node name.
	Node string `json:"node"`

	// Metric type.
	Type string `json:"type"`

	// Node resource relevant to the event.
	Resource string `json:"resource"`

	// Metric name for which event has been created.
	MetricName string `json:"metric_name"`

	// Message key that identifies related event.
	MessageKey string `json:"message_key"`

	// Addition info is a map of key value pairs.
	AdditionalInfo map[string]interface{} `mapstructure:"additional_info"`
}

type Service

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

func NewService

func NewService(c Config, d Diagnostic) *Service

func (*Service) Alert

func (s *Service) Alert(url, alertID, message string, level alert.Level, data *alert.EventData, hc *HandlerConfig) error

func (*Service) Close

func (s *Service) Close() error

func (*Service) Global

func (s *Service) Global() bool

func (*Service) Handler

func (s *Service) Handler(c HandlerConfig, ctx ...keyvalue.T) alert.Handler

func (*Service) Open

func (s *Service) Open() error

func (*Service) StateChangesOnly

func (s *Service) StateChangesOnly() bool

func (*Service) Test

func (s *Service) Test(options interface{}) error

func (*Service) TestOptions

func (s *Service) TestOptions() interface{}

func (*Service) Update

func (s *Service) Update(newConfig []interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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