Skip to content
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

Change label name for metrics generator instance #1439

Merged
merged 4 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## main / unreleased

* [CHANGE] metrics-generator: Changed added metric label `instance` to `__metrics_gen_instance` to reduce collisions with custom dimensions. [#1439](https://github.com/grafana/tempo/pull/1439) (@joe-elliott)
* [FEATURE] metrics-generator: support per-tenant processor configuration [#1434](https://github.com/grafana/tempo/pull/1434) (@kvrhdn)
* [ENHANCEMENT] Added the ability to have a per tenant max search duration. [#1421](https://github.com/grafana/tempo/pull/1421) (@joe-elliott)

Expand Down
2 changes: 1 addition & 1 deletion modules/generator/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func New(cfg *Config, overrides Overrides, tenant string, appendable storage.App
externalLabels[k] = v
}
hostname, _ := os.Hostname()
externalLabels["instance"] = hostname
externalLabels["__metrics_gen_instance"] = hostname

r := &ManagedRegistry{
onShutdown: cancel,
Expand Down
22 changes: 11 additions & 11 deletions modules/generator/registry/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestManagedRegistry_counter(t *testing.T) {
counter.Inc(NewLabelValues([]string{"value-1"}), 1.0)

expectedSamples := []sample{
newSample(map[string]string{"__name__": "my_counter", "label": "value-1", "instance": mustGetHostname()}, 0, 1.0),
newSample(map[string]string{"__name__": "my_counter", "label": "value-1", "__metrics_gen_instance": mustGetHostname()}, 0, 1.0),
}
collectRegistryMetricsAndAssert(t, registry, appender, expectedSamples)
}
Expand All @@ -80,11 +80,11 @@ func TestManagedRegistry_histogram(t *testing.T) {
histogram.ObserveWithExemplar(NewLabelValues([]string{"value-1"}), 1.0, "")

expectedSamples := []sample{
newSample(map[string]string{"__name__": "histogram_count", "label": "value-1", "instance": mustGetHostname()}, 0, 1.0),
newSample(map[string]string{"__name__": "histogram_sum", "label": "value-1", "instance": mustGetHostname()}, 0, 1.0),
newSample(map[string]string{"__name__": "histogram_bucket", "label": "value-1", "instance": mustGetHostname(), "le": "1"}, 0, 1.0),
newSample(map[string]string{"__name__": "histogram_bucket", "label": "value-1", "instance": mustGetHostname(), "le": "2"}, 0, 1.0),
newSample(map[string]string{"__name__": "histogram_bucket", "label": "value-1", "instance": mustGetHostname(), "le": "+Inf"}, 0, 1.0),
newSample(map[string]string{"__name__": "histogram_count", "label": "value-1", "__metrics_gen_instance": mustGetHostname()}, 0, 1.0),
newSample(map[string]string{"__name__": "histogram_sum", "label": "value-1", "__metrics_gen_instance": mustGetHostname()}, 0, 1.0),
newSample(map[string]string{"__name__": "histogram_bucket", "label": "value-1", "__metrics_gen_instance": mustGetHostname(), "le": "1"}, 0, 1.0),
newSample(map[string]string{"__name__": "histogram_bucket", "label": "value-1", "__metrics_gen_instance": mustGetHostname(), "le": "2"}, 0, 1.0),
newSample(map[string]string{"__name__": "histogram_bucket", "label": "value-1", "__metrics_gen_instance": mustGetHostname(), "le": "+Inf"}, 0, 1.0),
}
collectRegistryMetricsAndAssert(t, registry, appender, expectedSamples)
}
Expand All @@ -107,8 +107,8 @@ func TestManagedRegistry_removeStaleSeries(t *testing.T) {
registry.removeStaleSeries(context.Background())

expectedSamples := []sample{
newSample(map[string]string{"__name__": "metric_1", "instance": mustGetHostname()}, 0, 1),
newSample(map[string]string{"__name__": "metric_2", "instance": mustGetHostname()}, 0, 2),
newSample(map[string]string{"__name__": "metric_1", "__metrics_gen_instance": mustGetHostname()}, 0, 1),
newSample(map[string]string{"__name__": "metric_2", "__metrics_gen_instance": mustGetHostname()}, 0, 2),
}
collectRegistryMetricsAndAssert(t, registry, appender, expectedSamples)

Expand All @@ -121,7 +121,7 @@ func TestManagedRegistry_removeStaleSeries(t *testing.T) {
registry.removeStaleSeries(context.Background())

expectedSamples = []sample{
newSample(map[string]string{"__name__": "metric_2", "instance": mustGetHostname()}, 0, 4),
newSample(map[string]string{"__name__": "metric_2", "__metrics_gen_instance": mustGetHostname()}, 0, 4),
}
collectRegistryMetricsAndAssert(t, registry, appender, expectedSamples)
}
Expand All @@ -141,7 +141,7 @@ func TestManagedRegistry_externalLabels(t *testing.T) {
counter.Inc(nil, 1.0)

expectedSamples := []sample{
newSample(map[string]string{"__name__": "my_counter", "instance": mustGetHostname(), "foo": "bar"}, 0, 1),
newSample(map[string]string{"__name__": "my_counter", "__metrics_gen_instance": mustGetHostname(), "foo": "bar"}, 0, 1),
}
collectRegistryMetricsAndAssert(t, registry, appender, expectedSamples)
}
Expand All @@ -165,7 +165,7 @@ func TestManagedRegistry_maxSeries(t *testing.T) {

assert.Equal(t, uint32(1), registry.activeSeries.Load())
expectedSamples := []sample{
newSample(map[string]string{"__name__": "metric_1", "label": "value-1", "instance": mustGetHostname()}, 0, 1),
newSample(map[string]string{"__name__": "metric_1", "label": "value-1", "__metrics_gen_instance": mustGetHostname()}, 0, 1),
}
collectRegistryMetricsAndAssert(t, registry, appender, expectedSamples)
}
Expand Down