metrics

package
v0.8.22 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package metrics [everything related to metrics goes here]

Index

Constants

View Source
const (
	Traffic          = "traffic"
	ProcessedTraffic = "processed_traffic"
)

supported default metrics

View Source
const (
	StatusLabel   = `status`
	StatusSuccess = `success`
	StatusFail    = `fail`
)

common values for prometheus metrics

View Source
const (
	DNSBlastRootDomainLabel = `root_domain`
	DNSBlastSeedDomainLabel = `seed_domain`
	DNSBlastProtocolLabel   = `protocol`
)

DNS Blast related values and labels for prometheus metrics

View Source
const (
	HTTPDestinationHostLabel = `destination_host`
	HTTPMethodLabel          = `method`
)

HTTP related values and labels

View Source
const (
	PacketgenHostLabel        = `host`
	PacketgenDstHostPortLabel = `dst_host_port`
	PacketgenProtocolLabel    = `protocol`
)

Packetgen related values and labels

View Source
const (
	SlowlorisAddressLabel  = `address`
	SlowlorisProtocolLabel = `protocol`
)

Slowloris related values and labels

View Source
const (
	RawnetAddressLabel  = `address`
	RawnetProtocolLabel = `protocol`
)

Rawnet related values and labels

View Source
const (
	ClientIDLabel = `id`
	CountryLabel  = `country`
)

Client related values and labels

Variables

View Source
var BasicAuth = `YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNjcnlwdCBpYWlSV1VBRWcweEt2NWdTd240a0JBIDE4CmlONnhLcURxWEVWdmFuU1Rh` +
	`SVl0dmplNGpLc0FqLzN5SE5neXdnM0xIMVUKLS0tIE1YdVNBVmk1NG9zNzRpQnh2R3U3MDBpWm5MNUxCb0hNeGxKTERGRDFRamMKJkpimmJGSDmx` +
	`BX2e38Z38EQZK7aq/W29YMbZKz/omNL0GPvurXZA6GTPmmlD/XZ+EjCkW6bKajIS9y9533tsn6MR8NMtFJoS+z7M9b/yd8YJR6fW069b2A==`

BasicAuth client's credentials for push gateway encrypted with utils/crypto.go#EncryptionKeys[0] key

View Source
var Default = Storage{
	// contains filtered or unexported fields
}

Default to allow global access for ease of use similar to http.DefaultClient and such

View Source
var PushGatewayCA string

PushGatewayCA variable to embed self-signed CA for TLS

Functions

func ExportPrometheusMetrics

func ExportPrometheusMetrics(ctx context.Context, logger *zap.Logger, clientID, gateways string)

ExportPrometheusMetrics starts http server and export metrics at address <ip>:9090/metrics, also pushes metrics to gateways randomly

func IncClient added in v0.7.10

func IncClient()

IncClient increments counter of calls from the current client ID

func IncDNSBlast

func IncDNSBlast(rootDomain, seedDomain, protocol, status string)

IncDNSBlast increments counter of sent dns queries

func IncHTTP

func IncHTTP(host, method, status string)

IncHTTP increments counter of sent http queries

func IncPacketgen

func IncPacketgen(host, hostPort, protocol, status, id string)

IncPacketgen increments counter of sent raw packets

func IncRawnetTCP

func IncRawnetTCP(address, status string)

IncRawnetTCP increments counter of sent raw tcp packets

func IncRawnetUDP

func IncRawnetUDP(address, status string)

IncRawnetUDP increments counter of sent raw tcp packets

func IncSlowLoris

func IncSlowLoris(address, protocol, status string)

IncSlowLoris increments counter of sent raw ethernet+ip+tcp/udp packets

func Init added in v0.8.4

func Init(clientID, country string)

Init prometheus counters.

func InitOrFail added in v0.8.4

func InitOrFail(ctx context.Context, logger *zap.Logger, prometheusOn bool, prometheusPushGateways, clientID, country string)

func NewOptionsWithFlags added in v0.8.4

func NewOptionsWithFlags() (prometheusOn *bool, prometheusPushGateways *string)

NewOptionsWithFlags returns metrics options initialized with command line flags.

func ReportStatistics added in v0.8.13

func ReportStatistics(traffic int64, clientID string) error

ReportStatistics sends basic usage events to google analytics

func ValidatePrometheusPushGateways

func ValidatePrometheusPushGateways(gatewayURLsCSV string) bool

ValidatePrometheusPushGateways split value into list of comma separated values and validate that each value is valid URL

Types

type NopWriter added in v0.8.1

type NopWriter struct{}

NopWriter implements io.Writer interface to simply track how much data has to be serialized

func (NopWriter) Write added in v0.8.1

func (w NopWriter) Write(p []byte) (n int, _ error)

type Storage

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

Storage is a general struct to store custom metrics

func (*Storage) NewWriter

func (ms *Storage) NewWriter(name, jobID string) *Writer

NewWriter creates a writer for accumulated writes to the storage

func (*Storage) Read

func (ms *Storage) Read(name string) uint64

func (*Storage) ResetAll added in v0.8.10

func (ms *Storage) ResetAll()

func (*Storage) Write

func (ms *Storage) Write(name, jobID string, value uint64)

type Writer

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

Writer is a helper to accumulate writes to a storage on a regular basis

func (*Writer) Add

func (w *Writer) Add(value uint64)

Add used to increase metric value by a specific amount

func (*Writer) Flush

func (w *Writer) Flush()

Flush used to flush pending metrics updates to the storage

func (*Writer) Set

func (w *Writer) Set(value uint64)

Set used to set metric to a specific value

func (*Writer) Update

func (w *Writer) Update(ctx context.Context, uint64erval time.Duration)

Update updates writer with a set uint64erval

Jump to

Keyboard shortcuts

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