PMM-12894 Fix metrics collisions

This commit is contained in:
Artem Gavrilov 2024-02-26 19:48:22 +02:00
parent 7300148014
commit 27e91bbd44

View File

@ -123,7 +123,6 @@ func makeRegistry(ctx context.Context, dsns []string, connSema *semaphore.Weight
opts := []ExporterOpt{ opts := []ExporterOpt{
AutoDiscoverDatabases(*autoDiscoverDatabases), AutoDiscoverDatabases(*autoDiscoverDatabases),
WithConstantLabels(*constantLabelsList),
ExcludeDatabases(excludedDatabases), ExcludeDatabases(excludedDatabases),
WithConnectionsSemaphore(connSema), WithConnectionsSemaphore(connSema),
WithContext(ctx), WithContext(ctx),
@ -133,6 +132,7 @@ func makeRegistry(ctx context.Context, dsns []string, connSema *semaphore.Weight
defaultExporter := NewExporter(dsns, append( defaultExporter := NewExporter(dsns, append(
opts, opts,
CollectorName("exporter"), CollectorName("exporter"),
WithConstantLabels(*constantLabelsList), // This option depends on collectors name, so keep it after CollectorName option
DisableDefaultMetrics(*disableDefaultMetrics), DisableDefaultMetrics(*disableDefaultMetrics),
DisableSettingsMetrics(*disableSettingsMetrics), DisableSettingsMetrics(*disableSettingsMetrics),
IncludeDatabases(*includeDatabases), IncludeDatabases(*includeDatabases),
@ -144,6 +144,7 @@ func makeRegistry(ctx context.Context, dsns []string, connSema *semaphore.Weight
hrExporter := NewExporter(dsns, hrExporter := NewExporter(dsns,
append(opts, append(opts,
CollectorName("custom_query.hr"), CollectorName("custom_query.hr"),
WithConstantLabels(*constantLabelsList), // This option depends on collectors name, so keep it after CollectorName option
WithUserQueriesEnabled(HR), WithUserQueriesEnabled(HR),
WithEnabled(*collectCustomQueryHr), WithEnabled(*collectCustomQueryHr),
DisableDefaultMetrics(true), DisableDefaultMetrics(true),
@ -158,6 +159,7 @@ func makeRegistry(ctx context.Context, dsns []string, connSema *semaphore.Weight
mrExporter := NewExporter(dsns, mrExporter := NewExporter(dsns,
append(opts, append(opts,
CollectorName("custom_query.mr"), CollectorName("custom_query.mr"),
WithConstantLabels(*constantLabelsList), // This option depends on collectors name, so keep it after CollectorName option
WithUserQueriesEnabled(MR), WithUserQueriesEnabled(MR),
WithEnabled(*collectCustomQueryMr), WithEnabled(*collectCustomQueryMr),
DisableDefaultMetrics(true), DisableDefaultMetrics(true),
@ -171,6 +173,7 @@ func makeRegistry(ctx context.Context, dsns []string, connSema *semaphore.Weight
lrExporter := NewExporter(dsns, lrExporter := NewExporter(dsns,
append(opts, append(opts,
CollectorName("custom_query.lr"), CollectorName("custom_query.lr"),
WithConstantLabels(*constantLabelsList), // This option depends on collectors name, so keep it after CollectorName option
WithUserQueriesEnabled(LR), WithUserQueriesEnabled(LR),
WithEnabled(*collectCustomQueryLr), WithEnabled(*collectCustomQueryLr),
DisableDefaultMetrics(true), DisableDefaultMetrics(true),