@@ -62,22 +62,19 @@ type CombinedSyncer struct {
62
62
func NewCombinedSyncer (config conf.SyncPrometheusConfig , db db.DB , monitor sync.Monitor ) sync.Datasource {
63
63
slog .Info ("loading syncers" , "metrics" , config .Metrics )
64
64
syncers := []sync.Datasource {}
65
- hostConfByName := make (map [string ]conf.SyncPrometheusHostConfig )
66
- for _ , hostConf := range config .Hosts {
67
- hostConfByName [hostConf .Name ] = hostConf
68
- }
69
65
for _ , metricConfig := range config .Metrics {
70
66
syncerFunc , ok := supportedSyncers [metricConfig .Type ]
71
67
if ! ok {
72
68
panic ("unsupported metric type: " + metricConfig .Type )
73
69
}
74
- // Sync the metric from one or multiple prometheus hosts.
75
- for _ , prometheusName := range metricConfig .PrometheusNames {
76
- hostConf , ok := hostConfByName [prometheusName ]
77
- if ! ok {
78
- panic ("unknown metric host: " + prometheusName )
70
+ // Get the prometheuses to sync this metric from.
71
+ for _ , hostConf := range config .Hosts {
72
+ for _ , providedMetricType := range hostConf .ProvidedMetricTypes {
73
+ if providedMetricType == metricConfig .Type {
74
+ slog .Info ("adding syncer" , "metricType" , metricConfig .Type , "host" , hostConf .Name )
75
+ syncers = append (syncers , syncerFunc (db , hostConf , metricConfig , monitor ))
76
+ }
79
77
}
80
- syncers = append (syncers , syncerFunc (db , hostConf , metricConfig , monitor ))
81
78
}
82
79
}
83
80
return CombinedSyncer {
0 commit comments