@@ -836,33 +836,51 @@ func updatePrometheusTargets(
836
836
l .Errorf ("error getting the port for node %d: %v" , nodeID , err )
837
837
return
838
838
}
839
+
839
840
nodeIP := v .PrivateIP
840
841
if reachability == promhelperclient .Public {
841
842
nodeIP = v .PublicIP
842
843
}
843
- nodeInfo := fmt .Sprintf ("%s:%d" , nodeIP , desc .Port )
844
- nodeIPPortsMutex .Lock ()
844
+
845
845
// ensure atomicity in map update
846
+ nodeIPPortsMutex .Lock ()
847
+ defer nodeIPPortsMutex .Unlock ()
848
+
849
+ // Hardware metrics
846
850
if _ , ok := nodeIPPorts [nodeID ]; ! ok {
847
851
nodeIPPorts [nodeID ] = []* promhelperclient.NodeInfo {
848
852
{
849
853
Target : fmt .Sprintf ("%s:%d" , nodeIP , vm .NodeExporterPort ),
850
- CustomLabels : createLabels (nodeID , v , "node_exporter" , ! c . Secure ),
854
+ CustomLabels : createLabels (nodeID , v , "node_exporter" , false ),
851
855
},
852
856
{
853
857
Target : fmt .Sprintf ("%s:%d" , nodeIP , vm .EbpfExporterPort ),
854
- CustomLabels : createLabels (nodeID , v , "ebpf_exporter" , ! c . Secure ),
858
+ CustomLabels : createLabels (nodeID , v , "ebpf_exporter" , false ),
855
859
},
856
860
}
857
861
}
862
+
863
+ // CRDB metrics
858
864
nodeIPPorts [nodeID ] = append (
859
865
nodeIPPorts [nodeID ],
860
866
& promhelperclient.NodeInfo {
861
- Target : nodeInfo ,
867
+ Target : fmt . Sprintf ( "%s:%d" , nodeIP , desc . Port ) ,
862
868
CustomLabels : createLabels (nodeID , v , "cockroachdb" , ! c .Secure ),
863
869
},
864
870
)
865
- nodeIPPortsMutex .Unlock ()
871
+
872
+ // Workload metrics
873
+ // TODO (golgeek): find a way to figure out if workload will be running
874
+ // on the node and only scrape its actual metrics port?
875
+ for port := vm .WorkloadMetricsPortMin ; port <= vm .WorkloadMetricsPortMax ; port ++ {
876
+ nodeIPPorts [nodeID ] = append (
877
+ nodeIPPorts [nodeID ],
878
+ & promhelperclient.NodeInfo {
879
+ Target : fmt .Sprintf ("%s:%d" , nodeIP , port ),
880
+ CustomLabels : createLabels (nodeID , v , "workload" , false ),
881
+ },
882
+ )
883
+ }
866
884
}(int (node ), c .VMs [node - 1 ])
867
885
868
886
}
@@ -902,26 +920,26 @@ func createLabels(nodeID int, v vm.VM, job string, insecure bool) map[string]str
902
920
if t , ok := v .Labels ["test_run_id" ]; ok {
903
921
labels ["test_run_id" ] = t
904
922
}
923
+
924
+ // Default configuration for promhelperservice is HTTPS but insecure exporters
925
+ // are scraped over HTTP.
926
+ if insecure {
927
+ labels ["__scheme__" ] = "http"
928
+ }
929
+
905
930
switch job {
906
931
case "cockroachdb" :
907
932
labels ["__metrics_path__" ] = "/_status/vars"
908
- if insecure {
909
- labels ["__scheme__" ] = "http"
910
- }
911
933
case "node_exporter" :
912
934
labels ["__metrics_path__" ] = vm .NodeExporterMetricsPath
913
- // node_exporter is always scraped over http
914
- labels ["__scheme__" ] = "http"
915
-
916
- // Node ID is exposed by cockroachdb metrics, we add it to node_exporter
917
- labels ["node_id" ] = strconv .Itoa (nodeID )
918
-
919
935
case "ebpf_exporter" :
920
936
labels ["__metrics_path__" ] = vm .EbpfExporterMetricsPath
921
- // ebpf_exporter is always scraped over http
922
- labels ["__scheme__" ] = "http"
937
+ case "workload" :
938
+ labels ["__metrics_path__" ] = vm .WorkloadMetricsPath
939
+ }
923
940
924
- // Node ID is exposed by cockroachdb metrics, we add it to ebpf_exporter
941
+ // Node ID is exposed by cockroachdb metrics, let's add it to other exporters.
942
+ if job != "cockroachdb" {
925
943
labels ["node_id" ] = strconv .Itoa (nodeID )
926
944
}
927
945
0 commit comments