Skip to content

fix(loki.process): Registration of stage.metric when used inside stage.match#5460

Merged
kalleep merged 2 commits intomainfrom
kalleep/loki-process-update-metrics
Feb 6, 2026
Merged

fix(loki.process): Registration of stage.metric when used inside stage.match#5460
kalleep merged 2 commits intomainfrom
kalleep/loki-process-update-metrics

Conversation

@kalleep
Copy link
Contributor

@kalleep kalleep commented Feb 5, 2026

Pull Request Details

When reloading config for loki.process we have had issues where metrics would be registered multiple times. It was fixed in #1292. But if you have metrics in stage.match you will hit the same issue because we never cleaned them up:

stage.match {
	selector = `{ test="" }`

	stage.metrics {
		metric.counter {
			name              = "counter"
			description       = "some metric desc"
			action            = "inc"
			match_all         = true
			max_idle_duration = "12h"
		}
	}
}

Issue(s) fixed by this Pull Request

Notes to the Reviewer

Test added in pr fails on main

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated

@kalleep kalleep requested a review from a team as a code owner February 5, 2026 15:59
@kalleep kalleep force-pushed the kalleep/loki-process-update-metrics branch from 2f8907b to b34a5cc Compare February 5, 2026 16:01
Copy link
Contributor

@kgeckhart kgeckhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

@kalleep kalleep merged commit 81caf72 into main Feb 6, 2026
47 checks passed
@kalleep kalleep deleted the kalleep/loki-process-update-metrics branch February 6, 2026 08:01
@grafana-alloybot grafana-alloybot bot mentioned this pull request Feb 6, 2026
@kalleep kalleep added the backport/v1.13 Backport to release/v1.13 label Feb 10, 2026
grafana-alloybot bot pushed a commit that referenced this pull request Feb 10, 2026
…e.match (#5460)

### Pull Request Details

When reloading config for `loki.process` we have had issues where
metrics would be registered multiple times. It was fixed in
#1292. But if you have metrics in
`stage.match` you will hit the same issue because we never cleaned them
up:

```
stage.match {
	selector = `{ test="" }`

	stage.metrics {
		metric.counter {
			name              = "counter"
			description       = "some metric desc"
			action            = "inc"
			match_all         = true
			max_idle_duration = "12h"
		}
	}
}
```

### Issue(s) fixed by this Pull Request

### Notes to the Reviewer

Test added in pr fails on main

### PR Checklist

<!-- Remove items that do not apply. For completed items, change [ ] to
[x]. -->

- [ ] Documentation added
- [x] Tests updated
- [ ] Config converters updated

(cherry picked from commit 81caf72)
kalleep added a commit that referenced this pull request Feb 11, 2026
…e.match [backport] (#5495)

## Backport of #5460

This PR backports #5460 to release/v1.13.

### Original PR Author
@kalleep

### Description
### Pull Request Details

When reloading config for `loki.process` we have had issues where
metrics would be registered multiple times. It was fixed in
#1292. But if you have metrics in
`stage.match` you will hit the same issue because we never cleaned them
up:

```
stage.match {
	selector = `{ test="" }`

	stage.metrics {
		metric.counter {
			name              = "counter"
			description       = "some metric desc"
			action            = "inc"
			match_all         = true
			max_idle_duration = "12h"
		}
	}
}
```

### Issue(s) fixed by this Pull Request

### Notes to the Reviewer

Test added in pr fails on main

### PR Checklist

<!-- Remove items that do not apply. For completed items, change [ ] to
[x]. -->

- [ ] Documentation added
- [x] Tests updated
- [ ] Config converters updated


---
*This backport was created automatically.*

Co-authored-by: Karl Persson <23356117+kalleep@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/v1.13 Backport to release/v1.13 frozen-due-to-age

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants