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

update metrics collect to nebula 3.0 #38

Merged
merged 1 commit into from
Jan 7, 2022
Merged

update metrics collect to nebula 3.0 #38

merged 1 commit into from
Jan 7, 2022

Conversation

kqzh
Copy link
Contributor

@kqzh kqzh commented Dec 28, 2021

  • support collect space metric
  • support collect nebula 3.0 metric
  • remove bare-metal namespace label

@kqzh kqzh added the wip label Dec 28, 2021
@kqzh kqzh removed the wip label Jan 6, 2022
}

func convertToMap(metrics []string) map[string]MetricValue {
matches := make(map[string]MetricValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

give a default length of len(metrics)?


type MetricValue struct {
Value string
Label map[string]string
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to Labels?

if start == -1 {
return metric, nil
}
end := strings.LastIndex(metric, "}")
Copy link
Contributor

Choose a reason for hiding this comment

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

if end is -1, will panic?

exporter/type.go Outdated
Comment on lines 9 to 11
GraphdComponent ComponentType = "graphd"
MetadComponent ComponentType = "metad"
StoragedComponent ComponentType = "storaged"
Copy link
Contributor

Choose a reason for hiding this comment

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

remove it if no more used.

Timeout: time.Second * 2,
}

resp, err := httpClient.Get(fmt.Sprintf("http://%s:%d/stats?stats=", ipAddress, port))
Copy link
Contributor

Choose a reason for hiding this comment

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

remove ?stats=?

Comment on lines 59 to 63
countStr := "count=0"
if status.Status == "running" {
countStr = strings.Replace(countStr, "0", "1", 1)
}
statusMetrics := []string{countStr}
Copy link
Contributor

Choose a reason for hiding this comment

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

It's no good to usestrings.Replace(countStr, "0", "1", 1)?

}

func (exporter *NebulaExporter) Describe(ch chan<- *prometheus.Desc) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

No more used ?

Comment on lines 133 to 143
ch <- prometheus.MustNewConstMetric(prometheus.NewDesc(
fmt.Sprintf("%s_%s_%s", FQNamespace, componentType, strings.ReplaceAll(metric, ".", "_")),
"", labels,
nil),
prometheus.GaugeValue,
v,
labelValues...,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

format it?

Copy link
Contributor

@veezhang veezhang left a comment

Choose a reason for hiding this comment

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

LGTM

}

label := make(map[string]string)
labelsStr := strings.Split(metric[start+1:end], ",")
Copy link
Contributor

Choose a reason for hiding this comment

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

why the sep is ","

Copy link
Contributor Author

Choose a reason for hiding this comment

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

becase the metric may like this num_queries{space=nba,partition=1}

}
}

func (exporter *NebulaExporter) collect(wg *sync.WaitGroup, namespace, clusterName string, instance Instance, ch chan<- prometheus.Metric) {
podIpAddress := instance.EndpointIP
podHttpPort := instance.EndpointPort

if podHttpPort == 0 {
if podHttpPort <= 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

<0 means?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because port < 0 also invalid


// FQNamespace represents the prometheus FQName
FQNamespace = "nebula"
NonNamespace = "none_namespace"
Copy link
Contributor

Choose a reason for hiding this comment

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

none seems more concise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I consider concise name may easy to used by user, so I use a long name none_namespace

@MegaByte875 MegaByte875 self-requested a review January 7, 2022 06:34
Copy link
Contributor

@MegaByte875 MegaByte875 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants