Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support v2-nightly #31

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
## 构建运行 exporter

```shell
$ git clone https://vesoft-inc/nebula-stats-exporter.git
$ git clone https://github.com/vesoft-inc/nebula-stats-exporter.git
$ cd nebula-stats-exporter
$ make build
$ ./nebula-stats-exporter --help
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Some of the metrics collections are:
## Building and running the exporter

```shell
$ git clone https://vesoft-inc/nebula-stats-exporter.git
$ git clone https://github.com/vesoft-inc/nebula-stats-exporter.git
$ cd nebula-stats-exporter
$ make build
$ ./nebula-stats-exporter --help
Expand Down
45 changes: 32 additions & 13 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ func NewNebulaExporter(ns, cluster, listenAddr string, client *kubernetes.Client
"num_forward_tranx",
"num_delete_edges_errors",
"num_update_vertex",
"num_delete_tags_errors",
"num_delete_tags",
"delete_tags",
}

for _, storagedLabel := range storagedLabels {
Expand Down Expand Up @@ -324,7 +327,7 @@ func (exporter *NebulaExporter) Describe(ch chan<- *prometheus.Desc) {
func (exporter *NebulaExporter) Collect(ch chan<- prometheus.Metric) {
now := time.Now()
klog.Infoln("Start collect")
defer func(){
defer func() {
klog.Infof("Complete collect, time elapse %s", time.Since(now))
}()

Expand Down Expand Up @@ -527,21 +530,37 @@ func (exporter *NebulaExporter) buildMetricMap(

func convertToMap(metrics []string) map[string]string {
matches := make(map[string]string)
for t := 0; ; t += 2 {
if t+1 >= len(metrics) {
break
}
ok, value := getRValue(metrics[t])
if !ok {
continue
// match metric format
// value=0
// name=num_queries.rate.60
if strings.Contains(metrics[0], "value=") {
for t := 0; ; t += 2 {
if t+1 >= len(metrics) {
break
}
ok, value := getRValue(metrics[t])
if !ok {
continue
}
ok, metric := getRValue(metrics[t+1])
if !ok {
continue
}
if value != "" && metric != "" {
matches[metric] = value
}
}
ok, metric := getRValue(metrics[t+1])
if !ok {
return matches
}

// match metric format
// slow_query_latency_us.p95.5=0
for _, metric := range metrics {
s := strings.Split(metric, "=")
if len(s) != 2 {
continue
}
if value != "" && metric != "" {
matches[metric] = value
}
matches[s[0]] = s[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use getRValue here?
ok, metric := getRValue(metrics)
if !ok {
continue
}
matches[s[0]] = metric

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I will check the length of 's'.

}
return matches
}
Expand Down