Skip to content

Commit

Permalink
Fix scraped targets metric (#5263)
Browse files Browse the repository at this point in the history
  • Loading branch information
thampiotr authored Sep 21, 2023
1 parent bdc288b commit 9f38669
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ Main (unreleased)

- Fix `loki.source.file` race condition in cleaning up metrics when stopping to tail files. (@thampiotr)

- Fixed the `agent_prometheus_scrape_targets_gauge` incorrectly reporting all discovered targets
instead of targets that belong to current instance when clustering is enabled. (@thampiotr)

v0.36.1 (2023-09-06)
--------------------

Expand Down
2 changes: 1 addition & 1 deletion component/prometheus/scrape/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func (c *Component) Run(ctx context.Context) error {
// 'clustered' targets implementation every time.
ct := discovery.NewDistributedTargets(cl, c.cluster, tgs)
promTargets := c.componentTargetsToProm(jobName, ct.Get())
c.targetsGauge.Set(float64(len(promTargets)))

select {
case targetSetsChan <- promTargets:
Expand Down Expand Up @@ -251,7 +252,6 @@ func (c *Component) Update(args component.Arguments) error {
default:
}

c.targetsGauge.Set(float64(len(c.args.Targets)))
return nil
}

Expand Down

0 comments on commit 9f38669

Please sign in to comment.