Skip to content

Commit 30cd8db

Browse files
authored
Add Plus metrics receiver log messages (#1078)
1 parent 30b6a16 commit 30cd8db

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

internal/collector/nginxplusreceiver/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type APIDetails struct {
3232
}
3333

3434
// Validate checks if the receiver configuration is valid
35+
// nolint: ireturn
3536
func (cfg *Config) Validate() error {
3637
if cfg.APIDetails.URL == "" {
3738
return errors.New("endpoint cannot be empty for nginxplusreceiver")

internal/collector/otel_collector_plugin.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (oc *Collector) handleNginxConfigUpdate(ctx context.Context, msg *bus.Messa
263263
return
264264
}
265265

266-
reloadCollector := oc.checkForNewReceivers(nginxConfigContext)
266+
reloadCollector := oc.checkForNewReceivers(ctx, nginxConfigContext)
267267

268268
if reloadCollector {
269269
slog.InfoContext(ctx, "Reloading OTel collector config, nginx config updated")
@@ -394,7 +394,7 @@ func (oc *Collector) restartCollector(ctx context.Context) {
394394
}
395395
}
396396

397-
func (oc *Collector) checkForNewReceivers(nginxConfigContext *model.NginxConfigContext) bool {
397+
func (oc *Collector) checkForNewReceivers(ctx context.Context, nginxConfigContext *model.NginxConfigContext) bool {
398398
nginxReceiverFound, reloadCollector := oc.updateExistingNginxPlusReceiver(nginxConfigContext)
399399

400400
if !nginxReceiverFound && nginxConfigContext.PlusAPI.URL != "" {
@@ -410,10 +410,12 @@ func (oc *Collector) checkForNewReceivers(nginxConfigContext *model.NginxConfigC
410410
CollectionInterval: defaultCollectionInterval,
411411
},
412412
)
413+
slog.DebugContext(ctx, "NGINX Plus API found, NGINX Plus receiver enabled to scrape metrics")
413414

414415
reloadCollector = true
415416
} else if nginxConfigContext.PlusAPI.URL == "" {
416-
reloadCollector = oc.addNginxOssReceiver(nginxConfigContext)
417+
slog.WarnContext(ctx, "NGINX Plus API is not configured, searching for stub status endpoint")
418+
reloadCollector = oc.addNginxOssReceiver(ctx, nginxConfigContext)
417419
}
418420

419421
if oc.config.IsFeatureEnabled(pkgConfig.FeatureLogsNap) {
@@ -428,7 +430,7 @@ func (oc *Collector) checkForNewReceivers(nginxConfigContext *model.NginxConfigC
428430
return reloadCollector
429431
}
430432

431-
func (oc *Collector) addNginxOssReceiver(nginxConfigContext *model.NginxConfigContext) bool {
433+
func (oc *Collector) addNginxOssReceiver(ctx context.Context, nginxConfigContext *model.NginxConfigContext) bool {
432434
nginxReceiverFound, reloadCollector := oc.updateExistingNginxOSSReceiver(nginxConfigContext)
433435

434436
if !nginxReceiverFound && nginxConfigContext.StubStatus.URL != "" {
@@ -445,8 +447,11 @@ func (oc *Collector) addNginxOssReceiver(nginxConfigContext *model.NginxConfigCo
445447
CollectionInterval: defaultCollectionInterval,
446448
},
447449
)
450+
slog.DebugContext(ctx, "Stub status endpoint found, OSS receiver enabled to scrape metrics")
448451

449452
reloadCollector = true
453+
} else if nginxConfigContext.StubStatus.URL == "" {
454+
slog.WarnContext(ctx, "Stub status endpoint not found, NGINX metrics not available")
450455
}
451456

452457
return reloadCollector

0 commit comments

Comments
 (0)