Documentation ¶
Index ¶
- Constants
- Variables
- func NewHTTPClient(conn *PollConnection, enableRedirects bool, maxRedirects int64) (*http.Client, *atomic.Int64)
- type BasePoller
- type BasicService
- func (s *BasicService) Collect(ch chan<- prometheus.Metric)
- func (s *BasicService) Describe(ch chan<- *prometheus.Desc)
- func (s *BasicService) Host() *Host
- func (s *BasicService) Name() string
- func (s *BasicService) Poll()
- func (s *BasicService) Port() uint64
- func (s *BasicService) Proto() string
- func (s *BasicService) Status() Status
- type ChallengeResponseMetricSet
- type ChallengeResponseService
- func (crs *ChallengeResponseService) Challenge(conn io.Writer) (float64, Status)
- func (crs *ChallengeResponseService) Collect(ch chan<- prometheus.Metric)
- func (crs *ChallengeResponseService) Describe(ch chan<- *prometheus.Desc)
- func (crs *ChallengeResponseService) Poll()
- func (crs *ChallengeResponseService) Status() Status
- type HTTPService
- type Host
- func (s *Host) Collect(ch chan<- prometheus.Metric)
- func (s *Host) Describe(ch chan<- *prometheus.Desc)
- func (s *Host) LastPoll() time.Time
- func (s *Host) Latency() time.Duration
- func (s *Host) NextPoll() time.Duration
- func (s *Host) Poll(limiter *Limiter, hostQueue chan<- *Host)
- func (s *Host) SincePoll() time.Duration
- func (s *Host) Status() Status
- type Limiter
- type PollConnection
- type Poller
- type Status
- type TLSService
Constants ¶
const MetricLabelFailed = "failed"
const MetricLabelSuccess = "successful"
const Namespace = "poller"
const PollStatusFailed = Status(float64(0))
const PollStatusSuccess = Status(float64(1))
Variables ¶
var ErrTooManyRedirects = errors.New("Too many redirects")
var PollStatusUnknown = Status(math.NaN()) //nolint:gochecknoglobals
Functions ¶
func NewHTTPClient ¶
func NewHTTPClient(conn *PollConnection, enableRedirects bool, maxRedirects int64) (*http.Client, *atomic.Int64)
NewHTTPClient returns an HTTP client which talks over the already established connection.
Types ¶
type BasePoller ¶ added in v0.9.1
type BasePoller interface { Poller // contains filtered or unexported methods }
BasePoller implements the doPoll method which returns the net.Conn so a higher level Poller can use it. Poller's which functionally cannot release the connection cannot be BasePollers.
func NewBasicService ¶
func NewBasicService(host *Host, opts config.BasicServiceConfig) BasePoller
type BasicService ¶
type BasicService struct { PortOpen prometheus.Gauge // Port open metric PortOpenCount *prometheus.CounterVec // Cumulative number of port open checks // contains filtered or unexported fields }
func (*BasicService) Collect ¶
func (s *BasicService) Collect(ch chan<- prometheus.Metric)
func (*BasicService) Describe ¶
func (s *BasicService) Describe(ch chan<- *prometheus.Desc)
func (*BasicService) Host ¶
func (s *BasicService) Host() *Host
func (*BasicService) Name ¶
func (s *BasicService) Name() string
func (*BasicService) Poll ¶
func (s *BasicService) Poll()
Poll implements the actual polling functionality of the service. It is distinct to the prometheus scrapers because we only ever want to run polls on *our* schedule.
func (*BasicService) Port ¶
func (s *BasicService) Port() uint64
func (*BasicService) Proto ¶
func (s *BasicService) Proto() string
func (*BasicService) Status ¶
func (s *BasicService) Status() Status
type ChallengeResponseMetricSet ¶ added in v0.9.1
type ChallengeResponseMetricSet struct { ServiceRequestSuccessful prometheus.Gauge // Indicates if the service could be successfully sent data ServiceRequestSize prometheus.Gauge // Number of bytes sent to the service ServiceChallengeStartTimeStamp prometheus.Gauge // Timestamp when the most recent service challenge started ServiceChallengeTime prometheus.Gauge // Time it took to send the challenge ServiceResponseTimeToFirstByte prometheus.Gauge // Time it took the service to send anything ServiceRespondedSuccessfully prometheus.Gauge // Indicates if the service responded with expected data ServiceResponseSize prometheus.Gauge // Number of bytes read before response match ServiceResponseDuration prometheus.Gauge // Time in microseconds to read the response bytes ServiceRequestCount *prometheus.CounterVec // Cumulative count of service requests ServiceRespondedCount *prometheus.CounterVec // Cumulative count of service responses ServiceResponseTimeToFirstByteCount prometheus.Counter // Cumulative count of service responses }
ChallengeResponseMetricSet implements the actual challenge-response metrics.
func NewChallengeResponseMetricSet ¶ added in v0.9.1
func NewChallengeResponseMetricSet(constantLabels prometheus.Labels) ChallengeResponseMetricSet
NewChallengeResponseMetricSet initializes a new set of metrics with the given constant labels.
func (*ChallengeResponseMetricSet) Collect ¶ added in v0.9.1
func (crms *ChallengeResponseMetricSet) Collect(ch chan<- prometheus.Metric)
func (*ChallengeResponseMetricSet) Describe ¶ added in v0.9.1
func (crms *ChallengeResponseMetricSet) Describe(ch chan<- *prometheus.Desc)
type ChallengeResponseService ¶
type ChallengeResponseService struct { ChallengeResponseMetricSet BasePoller // contains filtered or unexported fields }
ChallengeResponseService implements a bare challenge-response service.
func NewChallengeResponseService ¶
func NewChallengeResponseService(host *Host, opts config.ChallengeResponseConfig) *ChallengeResponseService
func (*ChallengeResponseService) Challenge ¶
func (crs *ChallengeResponseService) Challenge(conn io.Writer) (float64, Status)
Challenge sends the challenge to the service connection, and returns in Prometheus form the number of bytes and result.
func (*ChallengeResponseService) Collect ¶
func (crs *ChallengeResponseService) Collect(ch chan<- prometheus.Metric)
func (*ChallengeResponseService) Describe ¶
func (crs *ChallengeResponseService) Describe(ch chan<- *prometheus.Desc)
Describe returns the Prometheus metrics description.
func (*ChallengeResponseService) Poll ¶
func (crs *ChallengeResponseService) Poll()
func (*ChallengeResponseService) Status ¶
func (crs *ChallengeResponseService) Status() Status
Status is used by the web-UI for quick inspections.
type HTTPService ¶
type HTTPService struct { ChallengeResponseMetricSet Poller // but it is a Poller // contains filtered or unexported fields }
HTTPService is a degenerate ChallengeResponse service which does specific status code checking and always reads all the bytes it's sent. However a challenge response poller is quite different to using the HTTP client library so an HTTPService only inherits challenge-response configuration, and a basic poller for connections - it does not actually a challenge-response service.
func NewHTTPService ¶
func NewHTTPService(host *Host, opts config.HTTPServiceConfig) *HTTPService
func (*HTTPService) Collect ¶
func (hs *HTTPService) Collect(ch chan<- prometheus.Metric)
func (*HTTPService) Describe ¶
func (hs *HTTPService) Describe(ch chan<- *prometheus.Desc)
func (*HTTPService) Poll ¶
func (hs *HTTPService) Poll()
func (*HTTPService) Status ¶
func (hs *HTTPService) Status() Status
Return true if the last polled status was one of the allowed statuses.
type Host ¶
type Host struct { IP string // Resolved IP address (from last poll) Pollers []Poller // List of services to poll // Instantaneous metrics (easy to alert against) NumPolls prometheus.Counter // Number of times polls have been attempted LastPollTime prometheus.Gauge // Time of last poll Resolvable prometheus.Gauge // Is the hostname resolvable (IP is always true) PathReachable prometheus.Gauge // Is the host IP routable? PingLatency prometheus.Gauge // Latency to contact host - NaN if unavailable // Tally metrics (more accurate but harder) ResolvableCount *prometheus.CounterVec // success/failure count ReachableCount *prometheus.CounterVec // success/failure count PingResultCount *prometheus.CounterVec // cumulative count of pings LatencyCount prometheus.Counter // cumulative latency from successful polls *config.HostConfig // contains filtered or unexported fields }
Hosts are the top of a service hierarchy and contain a number of pollers. If the host fails to be resolvable or routable, then all pollers beneath it stop returning data (specifically they return NaN).
func NewHost ¶
func NewHost(opts *config.HostConfig) *Host
func (*Host) Collect ¶
func (s *Host) Collect(ch chan<- prometheus.Metric)
func (*Host) Describe ¶
func (s *Host) Describe(ch chan<- *prometheus.Desc)
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Basic generic resource limiter.
func NewLimiter ¶
type PollConnection ¶ added in v0.9.1
PollConnection wraps net.Conn and carries additional information about the service poll.
func (*PollConnection) Context ¶ added in v0.9.1
func (p *PollConnection) Context() context.Context
func (*PollConnection) Deadline ¶ added in v0.9.1
func (p *PollConnection) Deadline() time.Time
Deadline is the timeout set when the connection was originally opened.
func (*PollConnection) Dialer ¶ added in v0.9.1
func (p *PollConnection) Dialer() proxy.ContextDialer
type Poller ¶
type Poller interface { // Poll causes the service to update it's internal state. // Every Poll implementation should call any nested Poll implementations // *first* before running it's own functionality. Poll() Name() string // Returns the name of the poller Proto() string // Returns the protocol of the poller Port() uint64 // Returns the port of the poller Status() Status // Returns the overall status of the service Host() *Host // Returns the attached host of the service Describe(ch chan<- *prometheus.Desc) Collect(ch chan<- prometheus.Metric) // contains filtered or unexported methods }
type TLSService ¶ added in v0.9.1
type TLSService struct { CertificateNotAfter *prometheus.GaugeVec // Epoch time the SSL certificate expires CertificateNotBefore *prometheus.GaugeVec // Epoch time the SSL certificate is not valid before CertificateValid *prometheus.GaugeVec // Whether the certificate validates to this host CertificateValidCount *prometheus.CounterVec // Cumulative count of SSL validations BasePoller // contains filtered or unexported fields }
A TLS protected service. This can be any type of service, and simply adds certificate metrics to the base service. As a result it is not directly instantiated.
func (*TLSService) Collect ¶ added in v0.9.1
func (s *TLSService) Collect(ch chan<- prometheus.Metric)
func (*TLSService) Describe ¶ added in v0.9.1
func (s *TLSService) Describe(ch chan<- *prometheus.Desc)