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
- type Agent
- type Alert
- type AppStatus
- type AppStatusLinks
- type Cacher
- type Client
- type Concatenate
- type Counter
- type CounterVector
- type Decoder
- type Document
- type Ecs
- type Encoder
- type Error
- type Filebeat
- type Graceful
- type HTTPConfig
- type Handler
- type HealthChecker
- type HistogramVector
- type Host
- type Log
- type LogFile
- type Logger
- type Logstash
- type MIB
- type MIBRegistry
- type Measurer
- type Notifier
- type PostAlertsParams
- type PostableEvent
- type PostableEventInput
- type Receipts
- type Request
- type ResponseWriter
- type SNMPConfig
- type SchemaLoader
- type SchemaValidator
- type Serve
- type Server
- type Snmptrapd
- type TrapSource
- type TrapVar
- type UUIDGen
- type Watcher
- type Writer
Constants ¶
const ( // Value errors. ErrOIDNotFound = Error("OID not present in trap vars.") ErrUnknownAs = Error("Unknown v2.snmp.As type.") ErrNoneNumericalOID = Error("Numerical OID expected..") // Concatenate errors. ErrPathIsNotDir = Error("Path is not a directory.") // Mod errors. ErrInvalidOperation = Error("Operation not possible for given Mod.") ErrKeyMissing = Error("Key missing in mod.") // Alert Generator errors. ErrConfigNotFound = Error("Unknown config.") ErrNoMatch = Error("No alert matched in alert config.") ErrUnknownEventType = Error("Unknown event type specified.") // Counter errors. ErrCounterCreateFailed = Error("Failed to create counter.") ErrCounterDestroyFailed = Error("Failed to remove counter.") // CounterVec errors. ErrCounterVecCreateFailed = Error("Failed to create counter vector.") ErrHistogramVecCreateFailed = Error("Failed to create histogram vector.") )
const AMTimeFormat = "2006-01-02T15:04:05.000Z07:00"
RFC3339 with milliseconds. Time format expected by Alertmanager.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct { Labels map[string]string `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 AppStatus ¶
type AppStatus struct { ApiVersion string `json:"apiVersion"` Description string `json:"description"` Links AppStatusLinks `json:"links"` Status string `json:"status"` }
type AppStatusLinks ¶
type AppStatusLinks struct {
About string `json:"about"`
}
type Concatenate ¶
Interface to merge all configs in conf.d dir.
type Counter ¶
Counter is a Domain Type that represents the options for creating a counter. It is based on `prometheus/Counter`
type CounterVector ¶
type CounterVector interface { Create([]string) error // Labels. Incr(map[string]string) error // map[Label]Value }
CounterVector is a Domain Type that represents the options for creating a CounterVec. It is based on `prometheus/CounterVec`
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 HTTPConfig ¶
type Handler ¶
type Handler interface {
ServeHTTP(ResponseWriter, Request)
}
Represents HTTP handler
type HealthChecker ¶
type HistogramVector ¶
type HistogramVector interface { Create([]string) error // Labels. Observed([]string, float64) error // []LabelValues, seconds }
HistogramVector is a Domain Type that represents the options for creating a HistogramVector is based on `prometheus/HistogramVector`
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 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 Measurer ¶
type Measurer interface {
Measure(ResponseWriter, Request, func(ResponseWriter, Request))
}
Represents HTTP Response code/time measurements
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 ResponseWriter ¶
type ResponseWriter interface { Header() http.Header Write([]byte) (int, error) WriteHeader(int) StatusCode() int }
Represents HTTP ResponseWriter
type SNMPConfig ¶
type SNMPConfig struct { Application string AMAddress string AMTimeout time.Duration SNMPMibsDir string CacheFile string ListenAddress string ConfigDir string Version string Throttle bool PostTime int SleepTime int SendTime int DryRun bool LogUnknown bool ForwardUnknown bool }
Represents SNMP settings.
type SchemaValidator ¶
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 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 Writer ¶
type Writer interface { // Write a response object to the ResponseWriter with status code 200. Write(w ResponseWriter, r Request, e interface{}) // WriteCode writes a response object to the ResponseWriter and sets a response code. WriteCode(w ResponseWriter, r Request, code int, e interface{}) // WriteCreated writes a response object to the ResponseWriter with status code 201 and // the Location header set to location. WriteCreated(w ResponseWriter, r Request, location string, e interface{}) // WriteError writes an error to ResponseWriter and tries to extract the error's status code by // asserting statusCodeCarrier. If the error does not implement statusCodeCarrier, the status code // is set to 500. WriteError(w ResponseWriter, r Request, err interface{}) // WriteErrorCode writes an error to ResponseWriter and forces an error code. WriteErrorCode(w ResponseWriter, r Request, code int, err interface{}) }
Writer is a helper to write arbitrary data to a ResponseWriter