v1

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LapiBouncerHits = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Name: "cs_lapi_bouncer_requests_total",
		Help: "Number of calls to each route per method grouped by bouncers.",
	},
	[]string{"bouncer", "route", "method"},
)

hits per bouncer

View Source
var LapiMachineHits = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Name: "cs_lapi_machine_requests_total",
		Help: "Number of calls to each route per method grouped by machines.",
	},
	[]string{"machine", "route", "method"},
)

hits per machine

View Source
var LapiNilDecisions = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Name: "cs_lapi_decisions_ko_total",
		Help: "Number of calls to /decisions that returned nil result.",
	},
	[]string{"bouncer"},
)
keep track of the number of calls (per bouncer) that lead to nil/non-nil responses.

while it's not exact, it's a good way to know - when you have a rutpure bouncer - what is the rate of ok/ko answers you got from lapi

View Source
var LapiNonNilDecisions = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Name: "cs_lapi_decisions_ok_total",
		Help: "Number of calls to /decisions that returned non-nil result.",
	},
	[]string{"bouncer"},
)

hits per bouncer

View Source
var LapiResponseTime = prometheus.NewHistogramVec(
	prometheus.HistogramOpts{
		Name:    "cs_lapi_request_duration_seconds",
		Help:    "Response time of LAPI",
		Buckets: []float64{0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.2, 0.3, 0.4, 0.5, 0.75, 1},
	},
	[]string{"endpoint", "method"})
View Source
var LapiRouteHits = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Name: "cs_lapi_route_requests_total",
		Help: "Number of calls to each route per method.",
	},
	[]string{"route", "method"},
)

prometheus

Functions

func FormatAlerts

func FormatAlerts(result []*ent.Alert) models.AddAlertsRequest

FormatAlerts : Format results from the database to be swagger model compliant

func FormatDecisions

func FormatDecisions(decisions []*ent.Decision, dedup bool) ([]*models.Decision, error)

Format decisions for the bouncers, and deduplicate them by keeping only the longest one

func FormatOneAlert

func FormatOneAlert(alert *ent.Alert) *models.Alert

func PrometheusBouncersHasEmptyDecision

func PrometheusBouncersHasEmptyDecision(c *gin.Context)

func PrometheusBouncersHasNonEmptyDecision

func PrometheusBouncersHasNonEmptyDecision(c *gin.Context)

func PrometheusBouncersMiddleware

func PrometheusBouncersMiddleware() gin.HandlerFunc

func PrometheusMachinesMiddleware

func PrometheusMachinesMiddleware() gin.HandlerFunc

func PrometheusMiddleware

func PrometheusMiddleware() gin.HandlerFunc

Types

type Controller

type Controller struct {
	Ectx          context.Context
	DBClient      *database.Client
	APIKeyHeader  string
	Middlewares   *middlewares.Middlewares
	Profiles      []*csprofiles.Runtime
	CAPIChan      chan []*models.Alert
	PluginChannel chan csplugin.ProfileAlert
	ConsoleConfig csconfig.ConsoleConfig
	TrustedIPs    []net.IPNet
}

func New

func New(cfg *ControllerV1Config) (*Controller, error)

func (*Controller) CreateAlert

func (c *Controller) CreateAlert(gctx *gin.Context)

CreateAlert writes the alerts received in the body to the database

func (*Controller) CreateMachine

func (c *Controller) CreateMachine(gctx *gin.Context)

func (*Controller) DeleteAlertByID added in v1.4.2

func (c *Controller) DeleteAlertByID(gctx *gin.Context)

DeleteAlertByID delete the alert associated to the ID

func (*Controller) DeleteAlerts

func (c *Controller) DeleteAlerts(gctx *gin.Context)

DeleteAlerts deletes alerts from the database based on the specified filter

func (*Controller) DeleteDecisionById

func (c *Controller) DeleteDecisionById(gctx *gin.Context)

func (*Controller) DeleteDecisions

func (c *Controller) DeleteDecisions(gctx *gin.Context)

func (*Controller) FindAlertByID

func (c *Controller) FindAlertByID(gctx *gin.Context)

FindAlertByID returns the alert associated with the ID

func (*Controller) FindAlerts

func (c *Controller) FindAlerts(gctx *gin.Context)

FindAlerts: returns alerts from the database based on the specified filter

func (*Controller) GetDecision

func (c *Controller) GetDecision(gctx *gin.Context)

func (*Controller) HandleDBErrors

func (c *Controller) HandleDBErrors(gctx *gin.Context, err error)

func (*Controller) HeartBeat added in v1.4.0

func (c *Controller) HeartBeat(gctx *gin.Context)

func (*Controller) StreamDecision

func (c *Controller) StreamDecision(gctx *gin.Context)

type ControllerV1Config added in v1.4.0

type ControllerV1Config struct {
	DbClient      *database.Client
	Ctx           context.Context
	ProfilesCfg   []*csconfig.ProfileCfg
	CapiChan      chan []*models.Alert
	PluginChannel chan csplugin.ProfileAlert
	ConsoleConfig csconfig.ConsoleConfig
	TrustedIPs    []net.IPNet
}

Jump to

Keyboard shortcuts

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