v1

package
v0.0.0-...-a0c03a0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

It is based on `InVisionApp/go-health`

Copyright 2019 Cisco Systems, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	ErrCounterCreateFailed  = Error("Failed to create counter.")
	ErrCounterDestroyFailed = Error("Failed to remove counter.")
)

Counter errors.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACIClient

type ACIClient interface {
	Login() error
	Faults() ([]Map, error)
	NodeList() (map[string]map[string]interface{}, error)
	Logout() error
}

ACIClient is an interface implemented by an ACI API client.

type ACIClientConfig

type ACIClientConfig struct {
	Hosts []string
	User  string
	Pass  string
	Debug bool
}

ACIClientConfig is used to specify options for ACIClient.

ACIClientConfig is based on: "github.com/udhos/acigo"

type ACIConfig

type ACIConfig struct {
	Application    string
	ListenAddress  string
	CycleInterval  int
	ACITimeout     time.Duration
	AmURL          string
	ACIHosts       []string
	AlertsCFGFile  string
	SecretsCFGFile string
	Version        string
	User           string
	Pass           string

	StaticLabels       LabelMap
	Throttle           bool
	PostTime           int
	SleepTime          int
	SendTime           int
	ConsulEnabled      bool
	ConsulACIGroupHost string
	Debug              bool
	// contains filtered or unexported fields
}

Represents ACI settings.

type ACIFaultRaw

type ACIFaultRaw struct {
	Ack             string `json:"ack,omitempty"`
	Cause           string `json:"cause,omitempty"`
	ChangeSet       string `json:"changeSet,omitempty"`
	ChildAction     string `json:"childAction,omitempty"`
	Code            string `json:"code,omitempty"`
	Created         string `json:"created,omitempty"`
	DN              string `json:"dn,omitempty"`
	Delegated       string `json:"delegated,omitempty"`
	Descr           string `json:"descr,omitempty"`
	Domain          string `json:"domain,omitempty"`
	HighestSeverity string `json:"highestSeverity,omitempty"`
	LC              string `json:"lc,omitempty"`
	LastTransition  string `json:"lastTransition,omitempty"`
	Occur           string `json:"occur,omitempty"`
	OrigSeverity    string `json:"origSeverity,omitempty"`
	PrevSeverity    string `json:"prevSeverity,omitempty"`
	Rule            string `json:"rule,omitempty"`
	Severity        string `json:"severity,omitempty"`
	Status          string `json:"status,omitempty"`
	Subject         string `json:"subject,omitempty"`
	Type            string `json:"type,omitempty"`
}

ACIFaultRaw represents an ACI fault as scraped from the ACI API. It is designed to be used in the receiver of ACIFaultRawParser.

type ACIFaultRawParser

type ACIFaultRawParser interface {

	// Created returns the ACI API's created time for the fault in UTC timezone
	// and as RFC3339 time format.
	Created() (time.Time, error)

	// LastTransition returns the ACI API's last transition time for the fault
	// in UTC timezone and as RFC3339 time format.
	LastTransition() (time.Time, error)

	// ServerityID returns a numerical severity for the fault based on
	// the return value from ACIFaultRawSeverityIDParser.
	SeverityID() (ACIFaultSeverityID, error)

	// SubID returns the fault's `sub_id`. The return value is result of
	// pruning pattern `/fault-.*` from the fault's Distinguished Name (or DN).
	SubID() (string, error)
}

ACIFaultRawParser represents the ability to parse an ACI fault as scraped from the ACI API.

type ACIFaultSeverityID

type ACIFaultSeverityID int

ACIFaultSeverityID represents a ACI fault's severity level ID as mapped inside the Observability Framework.

type ACIFaultSeverityIDParser

type ACIFaultSeverityIDParser interface {
	fmt.Stringer
	Raw() ACIFaultSeverityRaw
}

ACIFaultSeverityIDParser represents the ability, given a ACIFaultSeverityID, to parse it into different formats (e.g. ACIFaultSeverityRaw).

type ACIFaultSeverityRaw

type ACIFaultSeverityRaw string

ACIFaultSeverityRaw represents a ACI fault's raw severity level as returned by the ACI API.

type ACIFaultSeverityRawParser

type ACIFaultSeverityRawParser interface {
	fmt.Stringer
	ID() ACIFaultSeverityID
}

ACIFaultSeverityRawParser represents the ability, given a ACIFaultSeverityRaw, to parse it into different formats (e.g. ACIFaultSeverityID).

type APIVersion

type APIVersion string

APIVersion represents a named version of an API (e.g. "v1", "v1").

type APIVersionValidator

type APIVersionValidator interface {
	// Validate returns a non-nil error if a given APIVersion is found to be
	// invalid.
	Validate() error
}

APIVersionValidator is an interface that represents the ability to return a non-nil error if a given APIVersion is invalid.

type Agent

type Agent struct {
	Hostname string `json:"hostname,omitempty"`

	Id string `json:"id,omitempty"`

	EphemeralId string `json:"ephemeral_id,omitempty"`

	Type string `json:"type,omitempty"`

	Version string `json:"version,omitempty"`
}

type Alert

type Alert struct {
	Labels       LabelMap          `json:"labels"`
	Annotations  map[string]string `json:"annotations"`
	StartsAt     time.Time         `json:"startsAt"`
	EndsAt       time.Time         `json:"endsAt"`
	GeneratorURL string            `json:"generatorURL"`
}

Represents Alertmanager alert.

type AlertPublisher

type AlertPublisher interface {
	Alerts(io.Reader) (PostableEvent, error)
	Publish(*Document) error
}

Interface to publish snmpd traps to Alertmanager.

type AnnotationMap

type AnnotationMap LabelMap

AnnotationMap is a Domain Type that represents a LabelMap used to annotate rather than label a resource.

type AnnotationMapCopier

type AnnotationMapCopier interface {
	// Copy returns a copy of an existing AnnotationMap.
	Copy() AnnotationMap
}

AnnotationMapCopier is an interface that represents the ability to return a copy of an existing AnnotationMap.

type AnnotationMapEqualer

type AnnotationMapEqualer interface {
	// Equal returns true when two AnnotationMap structs hold the same data.
	Equal(other AnnotationMap) bool
}

AnnotationMapEqualer is an interface that represents the ability to return true only if two AnnotationMap structs hold the same data.

type AnnotationMapMerger

type AnnotationMapMerger interface {
	// Merge returns a new merged AnnotationMap, given two AnnotationMap structs.
	Merge(other AnnotationMap) AnnotationMap
}

AnnotationMapMerger is an interface that represents the ability to return a new merged AnnotationMap, given two given AnnotationMap structs.

type AnnotationMapStringer

type AnnotationMapStringer interface {
	// String implements the `fmt.Stringer` interface.
	String() string
}

AnnotationMapStringer is an interface that embeds the `fmt.Stringer` interface.

type AnnotationMapValidator

type AnnotationMapValidator interface {
	// Validate returns a non-nil error if a given AnnotationMap is found to be
	// invalid.
	Validate() error
}

AnnotationMapValidator is an interface that represents the ability to return a non-nil error if a given AnnotationMap is invalid.

type AppStatus

type AppStatus struct {
	ApiVersion string `json:"apiVersion"`

	Description string `json:"description"`

	Links AppStatusLinks `json:"links"`

	Status string `json:"status"`
}
type AppStatusLinks struct {
	About string `json:"about"`
}

type Cacher

type Cacher interface {
	Read(io.Reader, interface{}) error
	Write(io.Writer, interface{}) error
}

Cache data

type CaseConverter

type CaseConverter interface {
	ToSnake() string
}

CaseConverter is an interface that represents the ability to return a case-converted string. For example, "this-case" -> "ThatCase".

CaseConverter is based on the functions implemented in `github.com/iancoleman/strcase`.

type CaseString

type CaseString string

CaseString represents a string that will be commonly used in the receiver of the CaseConverter interface.

type Client

type Client http.Client

Represents HTTP client

type Counter

type Counter interface {
	Create() error
	Incr() error
	Destroy() error
}

Counter is a Domain Type that represents the options for creating a counter. It is based on `prometheus/Counter`

type Decoder

type Decoder interface {
	Decode(io.Reader) error
}

Decode configs in *_config.go

type Document

type Document struct {
	ApiVersion string `json:"apiVersion,omitempty"`

	Kind string `json:"kind,omitempty"`

	Receipts Receipts `json:"receipts,omitempty"`
}

type Ecs

type Ecs struct {
	Version string `json:"version,omitempty"`
}

type Encoder

type Encoder interface {
	Encode(io.Writer) error
}

Encode configs in *_config.go

type Error

type Error string

Error represents an OF error.

func (Error) Error

func (e Error) Error() string

Error returns the error as a string.

type Filebeat

type Filebeat struct {
	Agent Agent `json:"agent,omitempty"`

	Ecs Ecs `json:"ecs,omitempty"`

	Input PostableEventInput `json:"input,omitempty"`

	Host Host `json:"host,omitempty"`

	Log Log `json:"log,omitempty"`

	Message string `json:"message,omitempty"`

	Version string `json:"@version,omitempty"`

	Timestamp string `json:"@timestamp,omitempty"`
}

type Fingerprinter

type Fingerprinter interface {
	Fingerprint() string
}

Interface for fingerprinting alerts.

type Graceful

type Graceful interface {
	Start() error
	Stop() error
}

Methods required to implement graceful.

type HTTPConfig

type HTTPConfig struct {
	ListenAddress string
	ReadTimeout   time.Duration
	WriteTimeout  time.Duration
}

type Handler

type Handler interface {
	ServeHTTP(ResponseWriter, Request)
}

Represents HTTP handler

type HealthChecker

type HealthChecker interface {
	Start() error
	Stop() error
	AddURL(name string, urlTarget string, timeout time.Duration) error
	State(urlTarget string) error
}

type Host

type Host struct {
	Name string `json:"name,omitempty"`
}

type Hostname

type Hostname string

Hostname represents the fully-qualified domain name of a host.

type HostnameFinder

type HostnameFinder interface {
	Hostnames() ([]Hostname, error)
}

HostnameFinder is an interface that represents the ability to determine the hostnames associated with an IPv4 or IPv6 address or similar entity.

type IP

type IP string

IP represents an IPv4 or IPv6 address.

type IPv4Finder

type IPv4Finder interface {
	IPv4() ([]IP, error)
}

IPv4Finder is an interface that represents the ability to determine the IPv4 addresses asssociated with a Hostname or similar entity.

type IPv4Validator

type IPv4Validator interface {
	IsIPv4() bool
}

IPv4Validator is an interface that represents the ability to validate that a given IP is an IPv4 address.

type IPv6Finder

type IPv6Finder interface {
	IPv6() ([]IP, error)
}

IPv6Finder is an interface that represents the ability to determine the IPv6 addresses asssociated with a Hostname or similar entity.

type IPv6Validator

type IPv6Validator interface {
	IsIPv6() bool
}

IPv6Validator is an interface that represents the ability to validate that a given IP is an IPv6 address.

type InfoCollector

type InfoCollector interface {
	// Register registers a collector with Prometheus that exports metrics about InfoService.
	Register() error

	// Unregister unregisters the collector with Prometheus. Normally, this would be called in a defer statement.
	Unregister() bool
}

InformerCollector is an optional extension to InfoService that represents the ability to expose metadata, build and version information as a Prometheus metrics collector.

type InfoService

type InfoService interface {
	// BuildInfo returns build information as a string.
	BuildInfo() string

	// Metadata returns metadata as a string.
	Metadata() string

	// String returns metadata, build and version information as a string.
	String() string

	// VersionInfo returns version information as a string.
	VersionInfo() string
}

InfoService is a domain interface that represents a service for exposing build and version information.

type LabelMap

type LabelMap map[LabelName]LabelValue

LabelMap is a Domain Type that represents a map of labels used to label a resource. It is based on `prometheus/common.LabelSet`

type LabelMapCopier

type LabelMapCopier interface {
	// Copy returns a copy of an existing LabelMap.
	Copy() LabelMap
}

LabelMapCopier is an interface that represents the ability to return a copy of an existing LabelMap.

type LabelMapEqualer

type LabelMapEqualer interface {
	// Equal returns true when two LabelMap structs hold the same data.
	Equal(other LabelMap) bool
}

LabelMapEqualer is an interface that represents the ability to return true only if two LabelMap structs hold the same data.

type LabelMapMerger

type LabelMapMerger interface {
	// Merge returns a new merged LabelMap, given two LabelMap structs.
	Merge(other LabelMap) LabelMap
}

LabelMapMerger is an interface that represents the ability to return a new merged LabelMap, given two given LabelMap structs.

type LabelMapStringer

type LabelMapStringer interface {
	// String implements the `fmt.Stringer` interface.
	String() string
}

LabelMapStringer is an interface that embeds the `fmt.Stringer` interface.

type LabelMapValidator

type LabelMapValidator interface {
	// Validate returns a non-nil error if a given LabelMap is found to be
	// invalid.
	Validate() error
}

LabelMapValidator is an interface that represents the ability to return a non-nil error if a given LabelMap is invalid.

type LabelName

type LabelName string

LabelName represents a key in a LabelMap.

LabelName is based on LabelName in `github.com/prometheus/common/model`.

type LabelNameValidator

type LabelNameValidator interface {
	Validate() error
}

LabelNameValidator is an interface that represents the ability to return a non-nil error if a given LabelName is invalid.

type LabelValue

type LabelValue string

LabelValue represents a value in a LabelMap.

LabelValue is based on LabelValue in `github.com/prometheus/common/model`.

type LabelValueValidator

type LabelValueValidator interface {
	Validate() error
}

LabelValueValidator is an interface that represents the ability to return a non-nil error if a given LabelValue is invalid.

type Log

type Log struct {
	Offset int32 `json:"offset,omitempty"`

	File LogFile `json:"file,omitempty"`
}

type LogFile

type LogFile struct {
	Path string `json:"path,omitempty"`
}

type Logger

type Logger interface {
	Fatalf(message string, args ...interface{})
	Panicf(message string, args ...interface{})
	Debugf(message string, args ...interface{})
	Errorf(message string, args ...interface{})
	Infof(message string, args ...interface{})
	LogLevel() string
	SetLevel(string)
	Tracef(message string, args ...interface{})
	Warningf(message string, args ...interface{})

	WithError(error) Logger
	WithField(string, interface{}) Logger
	WithFields(map[string]interface{}) Logger

	SetOutput(io.Writer)
}

Methods required for a logger.

type Logstash

type Logstash struct {
	Tags []string `json:"tags,omitempty"`
}

type MIB

type MIB struct {
	Name        string
	Description string
	Units       string
}

Represents MIB description.

type MIBRegistry

type MIBRegistry interface {
	// Return MIB for given OID.
	MIB(string) *MIB

	// Return MIB for given OID.
	// Translate each node in OID to its corresponding name, if MIB has its definition, else use the number.
	// Ex : 1.3.6.1.2.1.11.19 -> iso.org.dod.internet.mgmt.MIB-2.snmp.snmpInTraps.
	//      1.3.6.1.2.1.11.19.54334 -> iso.org.dod.internet.mgmt.MIB-2.snmp.snmpInTraps.54334.
	String(string) string

	// Translate the last node to its name. Ex: 1.3.6.1.2.1.11.19 -> snmpInTraps.
	ShortString(string) string

	// Load given map[oid]MIB into registry.
	Load(map[string]MIB) error
}

type Map

type Map map[string]interface{}

Map represents an arbitrary map[string]interface{} data that will be decoded into a native Go structure.

type MapDecoder

type MapDecoder interface {
	DecodeMap(output interface{}) error
}

MapDecoder is implemented by an object that can decode arbitrary map[string]interface{} data into a native Go structure and return the result.

MapDecoder is based on: "github.com/mitchellh/mapstructure"

type PostAlertsParams

type PostAlertsParams struct {
	Alerts []Alert

	Context    context.Context
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Represents Alertmanager postAlerts params.

type PostableEvent

type PostableEvent struct {
	Agent Agent `json:"agent,omitempty"`

	ApiVersion string `json:"apiVersion,omitempty"`

	Document Document `json:"document,omitempty"`

	Ecs Ecs `json:"ecs,omitempty"`

	Input PostableEventInput `json:"input,omitempty"`

	Host Host `json:"host,omitempty"`

	Log Log `json:"log,omitempty"`

	Message string `json:"message,omitempty"`

	Version string `json:"@version,omitempty"`

	Tags []string `json:"tags,omitempty"`

	Timestamp string `json:"@timestamp,omitempty"`
}

type PostableEventInput

type PostableEventInput struct {
	Type string `json:"type,omitempty"`
}

type Receipts

type Receipts struct {
	Filebeat Filebeat `json:"filebeat,omitempty"`

	Logstash Logstash `json:"logstash,omitempty"`

	Snmptrapd Snmptrapd `json:"snmptrapd,omitempty"`
}

type Request

type Request *http.Request

type ResponseWriter

type ResponseWriter http.ResponseWriter

type SNMPConfig

type SNMPConfig struct {
	AMAddress     string
	AMTimeout     time.Duration
	SNMPMibsDir   string
	CacheFile     string
	ListenAddress string
	ConfigDir     string
}

Represents SNMP settings.

type SchemaLoader

type SchemaLoader interface {
	Load([]byte) error
}

Defines schema loader

type SchemaValidator

type SchemaValidator interface {
	ValidateYAML([]byte) error
	ValidateJSON([]byte) error
}

Defines schema Validator

type Serve

type Serve interface {
	ListenAndServe() error
	Shutdown() error
	Handle(string, Handler)
	HandleFunc(string, func(ResponseWriter, Request))
}

Represents HTTP server components

type Server

type Server struct {
	Srv *http.Server
	Mux *http.ServeMux
	G   Graceful
}

type Snmptrapd

type Snmptrapd struct {
	Timestamp string `json:"timestamp,omitempty"`

	Source TrapSource `json:"source,omitempty"`

	Vars []TrapVar `json:"vars,omitempty"`

	PduSecurity string `json:"pduSecurity,omitempty"`
}

type TrapSource

type TrapSource struct {
	Address string `json:"address"`

	Hostname string `json:"hostname"`

	InternetLayerProtocol string `json:"internetLayerProtocol"`

	Port string `json:"port"`

	TransportLayerProtocol string `json:"transportLayerProtocol"`
}

type TrapVar

type TrapVar struct {
	Value string `json:"value"`

	Type string `json:"type"`

	Oid string `json:"oid"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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