diff --git a/exporter/exporter.go b/exporter/exporter.go index cc0b497..fb4780e 100644 --- a/exporter/exporter.go +++ b/exporter/exporter.go @@ -158,6 +158,19 @@ func (exporter *NebulaExporter) collect(wg *sync.WaitGroup, namespace, clusterNa instance.Name, instance.EndpointPort) wg.Add(2) + if instance.ComponentType == "storaged" { + wg.Add(1) + go func() { + defer wg.Done() + rocksDBStatus, err := getNebulaRocksDBStats(podIpAddress, podHttpPort) + if err != nil { + klog.Errorf("get query metrics from %s:%d failed: %v", podIpAddress, podHttpPort, err) + return + } + exporter.CollectMetrics(instance.Name, instance.ComponentType, namespace, clusterName, rocksDBStatus, ch) + }() + } + go func() { defer wg.Done() metrics, err := getNebulaMetrics(podIpAddress, podHttpPort) diff --git a/exporter/metric.go b/exporter/metric.go index 9babee8..c57a9d0 100644 --- a/exporter/metric.go +++ b/exporter/metric.go @@ -30,6 +30,27 @@ func getNebulaMetrics(ipAddress string, port int32) ([]string, error) { return metrics, nil } +func getNebulaRocksDBStats(ipAddress string, port int32) ([]string, error) { + httpClient := http.Client{ + Timeout: time.Second * 2, + } + + resp, err := httpClient.Get(fmt.Sprintf("http://%s:%d/rocksdb_stats", ipAddress, port)) + if err != nil { + return []string{}, err + } + defer resp.Body.Close() + + bytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + return []string{}, err + } + + metrics := strings.Split(strings.TrimSpace(string(bytes)), "\n") + + return metrics, nil +} + func isNebulaComponentRunning(ipAddress string, port int32) bool { httpClient := http.Client{ Timeout: time.Second * 2,