-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Promtail: panic: duplicate metrics collector registration attempted (loki_push_api) #10796
Comments
semi-related, grafana agent shows the following similar error when reloading a config with 2023/10/05 14:49:34 http: panic serving 127.0.0.1:34356: duplicate metrics collector registration attempted
goroutine 322 [running]:
net/http.(*conn).serve.func1()
/usr/lib/go/src/net/http/server.go:1868 +0xb9
panic({0x6b7dd80?, 0xc0039e44a0?})
/usr/lib/go/src/runtime/panic.go:920 +0x270
github.com/opentracing-contrib/go-stdlib/nethttp.MiddlewareFunc.func5.1()
/home/jorge/workspace/pkg/mod/github.com/opentracing-contrib/go-stdlib@v1.0.0/nethttp/server.go:150 +0x11e
panic({0x6b7dd80?, 0xc0039e44a0?})
/usr/lib/go/src/runtime/panic.go:914 +0x21f
github.com/prometheus/client_golang/prometheus.(*Registry).MustRegister(0xc00382e7b0?, {0xc002090160?, 0x1, 0x0?})
/home/jorge/workspace/pkg/mod/github.com/prometheus/client_golang@v1.16.0/prometheus/registry.go:405 +0x78
github.com/prometheus/client_golang/prometheus/promauto.Factory.NewGaugeVec({{0x8543b70?, 0xcbc6fa0?}}, {{0xc00382e7b0, 0x14}, {0x0, 0x0}, {0x7624738, 0xf}, {0x7735aa8, 0x2b}, ...}, ...)
/home/jorge/workspace/pkg/mod/github.com/prometheus/client_golang@v1.16.0/prometheus/promauto/auto.go:308 +0x1bc
github.com/grafana/dskit/server.NewServerMetrics({{0xc00382e7b0, 0x14}, 0x0, {0x75f1162, 0x3}, {0x0, 0x0}, 0xdac, 0x0, {0x75f1162, ...}, ...})
/home/jorge/workspace/pkg/mod/github.com/grafana/dskit@v0.0.0-20230829141140-06955c011ffd/server/metrics.go:30 +0x15a
github.com/grafana/dskit/server.New({{0xc00382e7b0, 0x14}, 0x0, {0x75f1162, 0x3}, {0x0, 0x0}, 0xdac, 0x0, {0x75f1162, ...}, ...})
/home/jorge/workspace/pkg/mod/github.com/grafana/dskit@v0.0.0-20230829141140-06955c011ffd/server/server.go:224 +0x58
github.com/grafana/loki/clients/pkg/promtail/targets/lokipush.(*PushTarget).run(0xc0039016e0)
/home/jorge/workspace/pkg/mod/github.com/grafana/loki@v1.6.2-0.20231004111112-07cbef92268a/clients/pkg/promtail/targets/lokipush/pushtarget.go:85 +0x338
github.com/grafana/loki/clients/pkg/promtail/targets/lokipush.NewPushTarget({0x84f4ac0?, 0xc002c9b090}, {0x85180e0?, 0xc001e01840}, {0x0, 0x0, 0x0}, {0xc00208e7e0, 0xb}, 0xc002b90a80)
/home/jorge/workspace/pkg/mod/github.com/grafana/loki@v1.6.2-0.20231004111112-07cbef92268a/clients/pkg/promtail/targets/lokipush/pushtarget.go:64 +0x325
github.com/grafana/loki/clients/pkg/promtail/targets/lokipush.NewPushTargetManager({0x8543860, 0xc002cd2210}, {0x84f4ac0?, 0xc002c9b090}, {0x85180b8, 0xc0039e7360}, {0xc002cadb00?, 0x1, 0x1})
/home/jorge/workspace/pkg/mod/github.com/grafana/loki@v1.6.2-0.20231004111112-07cbef92268a/clients/pkg/promtail/targets/lokipush/pushtargetmanager.go:47 +0x2b0
github.com/grafana/loki/clients/pkg/promtail/targets.NewTargetManagers({0x84f5d80?, 0xc002c9dcc0?}, {0x8543860, 0xc002cd2210}, {0x84f4ac0, 0xc002c9b090}, {0x2540be400, {0xc00399de00, 0x2a}, 0x0, ...}, ...)
/home/jorge/workspace/pkg/mod/github.com/grafana/loki@v1.6.2-0.20231004111112-07cbef92268a/clients/pkg/promtail/targets/manager.go:222 +0x1cc5
github.com/grafana/loki/clients/pkg/promtail.(*Promtail).reloadConfig(0xc002c9dcc0, 0xc0020ca000)
/home/jorge/workspace/pkg/mod/github.com/grafana/loki@v1.6.2-0.20231004111112-07cbef92268a/clients/pkg/promtail/promtail.go:187 +0xc0d
github.com/grafana/loki/clients/pkg/promtail.New({{{0xee6b280, 0xee6b280}}, {{{0x0, 0x0}, 0x0, {0x0, 0x0}, {0x0, 0x0}, 0x0, ...}, ...}, ...}, ...)
/home/jorge/workspace/pkg/mod/github.com/grafana/loki@v1.6.2-0.20231004111112-07cbef92268a/clients/pkg/promtail/promtail.go:110 +0x2dd
github.com/grafana/agent/pkg/logs.(*Instance).ApplyConfig(0xc002d070b0, 0xc002c9cbe0, {{0xee6b280, 0xee6b280}, {0xc002b222c0, 0x1, 0x1}}, 0x68?) |
I can reproduce the above issue and additionally, reloading via SIGHUP also causes panic. |
The one here:
could be avoided by calling
once for the whole program. |
…er reloaded (#10798) **What this PR does / why we need it**: Prevent Promtail panicking after getting reloaded. **Which issue(s) this PR fixes**: Fixes #10796 **Special notes for your reviewer**: **Checklist** - [x] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) - [ ] Documentation added - [ ] Tests updated - [x] `CHANGELOG.md` updated - [ ] If the change is worth mentioning in the release notes, add `add-to-release-notes` label - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/setup/upgrade/_index.md` - [ ] For Helm chart changes bump the Helm chart version in `production/helm/loki/Chart.yaml` and update `production/helm/loki/CHANGELOG.md` and `production/helm/loki/README.md`. [Example PR](d10549e) --------- Co-authored-by: Michel Hollands <42814411+MichelHollands@users.noreply.github.com>
I've encountered similar error aftter I tried http://localhost:9081/reload.
I have following version of loki and promtail:
|
…er reloaded (grafana#10798) **What this PR does / why we need it**: Prevent Promtail panicking after getting reloaded. **Which issue(s) this PR fixes**: Fixes grafana#10796 **Special notes for your reviewer**: **Checklist** - [x] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) - [ ] Documentation added - [ ] Tests updated - [x] `CHANGELOG.md` updated - [ ] If the change is worth mentioning in the release notes, add `add-to-release-notes` label - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/setup/upgrade/_index.md` - [ ] For Helm chart changes bump the Helm chart version in `production/helm/loki/Chart.yaml` and update `production/helm/loki/CHANGELOG.md` and `production/helm/loki/README.md`. [Example PR](grafana@d10549e) --------- Co-authored-by: Michel Hollands <42814411+MichelHollands@users.noreply.github.com>
Describe the bug
Dynamically reloading promtail's configuration when using
loki_push_api
leads to a panic caused by double registration of metrics. This also indirectly affects Grafana Agent.To Reproduce
Steps to reproduce the behavior:
http://localhost:9080/reload
The a panic shows up in the logs.
Expected behavior
Promtail shouldn't panic on reload.
Environment:
Tested directly from the source on the latest release (commit 3b4bd12).
Screenshots, Promtail config, or terminal output
The text was updated successfully, but these errors were encountered: