Skip to content

Commit

Permalink
update cluster label (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
kqzh authored Feb 15, 2022
1 parent 1f4ae24 commit a8bc82d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,28 @@ func (exporter *NebulaExporter) CollectMetrics(
}

metrics := convertToMetrics(originMetrics)
for _, matric := range metrics {
v, err := strconv.ParseFloat(matric.Value, 64)
for _, metric := range metrics {
v, err := strconv.ParseFloat(metric.Value, 64)
if err != nil {
continue
}

labels := []string{"cluster", "componentType", "instanceName"}
labels := []string{"nebula_cluster", "component_type", "instance_name"}
labelValues := []string{cluster, componentType, name}

if namespace != NonNamespace {
labels = append(labels, "namespace")
labelValues = append(labelValues, namespace)
}

for key, value := range matric.Labels {
for key, value := range metric.Labels {
labels = append(labels, key)
labelValues = append(labelValues, value)
}

ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
fmt.Sprintf("%s_%s_%s", FQNamespace, componentType, strings.ReplaceAll(matric.Name, ".", "_")),
fmt.Sprintf("%s_%s_%s", FQNamespace, componentType, strings.ReplaceAll(metric.Name, ".", "_")),
"",
labels,
nil,
Expand Down

0 comments on commit a8bc82d

Please sign in to comment.