Documentation ¶
Index ¶
Constants ¶
const ( // PrometheusHistogram is label name of PrometheusCounterBackend PrometheusHistogram = "prometheus-histogram" // LocalLogLabel is label name of LocalLogBackend LocalLogLabel = "local-log" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { // ProcessHTTPRequest is used to perform HTTP audit process ProcessHTTPRequest(req *http.Request) bool // Match is used to determine if the backend matches Match(*BackendLabels) bool ProcessBeforeHandler() bool }
Backend defines what function audit backend should hold
func NewLocalLogBackend ¶
NewLocalLogBackend returns a LocalLogBackend
func NewPrometheusHistogramBackend ¶
func NewPrometheusHistogramBackend(histogramVec *prometheus.HistogramVec, before bool) Backend
NewPrometheusHistogramBackend returns a PrometheusHistogramBackend
type BackendLabels ¶
type BackendLabels struct {
Labels []string
}
BackendLabels is used to store some audit backend labels.
type LabelMatcher ¶
type LabelMatcher struct {
// contains filtered or unexported fields
}
LabelMatcher is used to help backend implement audit.Backend
func (*LabelMatcher) Match ¶
func (m *LabelMatcher) Match(labels *BackendLabels) bool
Match is used to check whether backendLabel is in the labels
type LocalLogBackend ¶
type LocalLogBackend struct { *LabelMatcher *Sequence }
LocalLogBackend is an implementation of audit.Backend and it uses `github.com/pingcap/log` to implement audit
func (*LocalLogBackend) ProcessHTTPRequest ¶
func (l *LocalLogBackend) ProcessHTTPRequest(r *http.Request) bool
ProcessHTTPRequest is used to implement audit.Backend
type PrometheusHistogramBackend ¶
type PrometheusHistogramBackend struct { *LabelMatcher *Sequence // contains filtered or unexported fields }
PrometheusHistogramBackend is an implementation of audit.Backend and it uses Prometheus histogram data type to implement audit. Note: histogram.WithLabelValues will degrade performance. Please don't use it in the hot path.
func (*PrometheusHistogramBackend) ProcessHTTPRequest ¶
func (b *PrometheusHistogramBackend) ProcessHTTPRequest(req *http.Request) bool
ProcessHTTPRequest is used to implement audit.Backend
type Sequence ¶
type Sequence struct {
// contains filtered or unexported fields
}
Sequence is used to help backend implement audit.Backend
func (*Sequence) ProcessBeforeHandler ¶
ProcessBeforeHandler is used to identify whether this backend should execute before handler