MCPcopy
hub / github.com/crowdsecurity/crowdsec / startLPMetrics

Function startLPMetrics

cmd/crowdsec/crowdsec.go:110–136  ·  view source on GitHub ↗
(ctx context.Context, cConfig *csconfig.Config, apiClient *apiclient.ApiClient, hub *cwhub.Hub, datasources []acquisitionTypes.DataSource)

Source from the content-addressed store, hash-verified

108}
109
110func startLPMetrics(ctx context.Context, cConfig *csconfig.Config, apiClient *apiclient.ApiClient, hub *cwhub.Hub, datasources []acquisitionTypes.DataSource) error {
111 mp := NewMetricsProvider(
112 apiClient,
113 lpMetricsDefaultInterval,
114 log.WithField("service", "lpmetrics"),
115 datasources,
116 hub,
117 )
118
119 go func() {
120 defer trace.ReportPanic()
121 mp.Run(ctx)
122 }()
123
124 if cConfig.Prometheus != nil && cConfig.Prometheus.Enabled {
125 aggregated := false
126 if cConfig.Prometheus.Level == metrics.MetricsLevelAggregated {
127 aggregated = true
128 }
129
130 if err := acquisition.GetMetrics(datasources, aggregated); err != nil {
131 return fmt.Errorf("while fetching prometheus metrics for datasources: %w", err)
132 }
133 }
134
135 return nil
136}
137
138// runCrowdsec starts the log processor service
139func runCrowdsec(

Callers 1

runCrowdsecFunction · 0.85

Calls 3

RunMethod · 0.95
GetMetricsFunction · 0.92
NewMetricsProviderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…