Documentation ¶
Index ¶
- type ResourcesMetricsCollector
- func (c ResourcesMetricsCollector) Collect(metrics chan<- prometheus.Metric)
- func (c ResourcesMetricsCollector) Describe(descs chan<- *prometheus.Desc)
- func (c ResourcesMetricsCollector) NeedLeaderElection() bool
- func (c *ResourcesMetricsCollector) SetupWithManager(mgr ctrl.Manager) error
- func (c ResourcesMetricsCollector) Start(ctx context.Context) error
- type SeverityLabel
- type Status
- type StatusLabel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResourcesMetricsCollector ¶
type ResourcesMetricsCollector struct { logr.Logger etc.Config trivyoperator.ConfigData client.Client // contains filtered or unexported fields }
ResourcesMetricsCollector is a custom Prometheus collector that produces metrics on-demand from the trivy-operator custom resources. Since these resources are already cached by the Kubernetes API client shared with the operator, metrics scrapes should never actually hit the API server. All resource reads are served from cache, reducing API server load without consuming additional cluster resources. An alternative (more traditional) approach would be to maintain metrics in the internal Prometheus registry on resource reconcile. The collector approach was selected in order to avoid potentially stale metrics; i.e. the controller would have to reconcile all resources at least once for the metrics to be up-to-date, which could take some time in large clusters. Also deleting metrics from registry for obsolete/deleted resources is challenging without introducing finalizers, which we want to avoid for operational reasons.
For more advanced use-cases, and/or very large clusters, this internal collector can be disabled and replaced by https://github.com/giantswarm/starboard-exporter, which collects trivy metrics from a dedicated workload supporting sharding etc.
func NewResourcesMetricsCollector ¶ added in v0.5.0
func NewResourcesMetricsCollector(logger logr.Logger, config etc.Config, trvConfig trivyoperator.ConfigData, clt client.Client) *ResourcesMetricsCollector
func (ResourcesMetricsCollector) Collect ¶
func (c ResourcesMetricsCollector) Collect(metrics chan<- prometheus.Metric)
func (ResourcesMetricsCollector) Describe ¶
func (c ResourcesMetricsCollector) Describe(descs chan<- *prometheus.Desc)
func (ResourcesMetricsCollector) NeedLeaderElection ¶
func (c ResourcesMetricsCollector) NeedLeaderElection() bool
func (*ResourcesMetricsCollector) SetupWithManager ¶
func (c *ResourcesMetricsCollector) SetupWithManager(mgr ctrl.Manager) error
type SeverityLabel ¶ added in v0.4.0
func NewSeverityLabel ¶ added in v0.4.0
func NewSeverityLabel(severity v1alpha1.Severity) SeverityLabel
func SeverityCritical ¶ added in v0.4.0
func SeverityCritical() SeverityLabel
func SeverityHigh ¶ added in v0.4.0
func SeverityHigh() SeverityLabel
func SeverityLow ¶ added in v0.4.0
func SeverityLow() SeverityLabel
func SeverityMedium ¶ added in v0.4.0
func SeverityMedium() SeverityLabel
func SeverityUnknown ¶ added in v0.4.0
func SeverityUnknown() SeverityLabel
type StatusLabel ¶ added in v0.9.0
func NewStatusLabel ¶ added in v0.9.0
func NewStatusLabel(status Status) StatusLabel
func StatusFail ¶ added in v0.9.0
func StatusFail() StatusLabel
func StatusPass ¶ added in v0.9.0
func StatusPass() StatusLabel