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

init jenkins input plugin #3292

Closed
wants to merge 2 commits into from

Conversation

ctrlok
Copy link
Contributor

@ctrlok ctrlok commented Oct 2, 2017

Initial PR. Plugin for getting metrics from Jenkins.
I'm not sure that I did all in right way, so I ask some questions here:

is a good idea to name measurement "jenkins" with a lot of fields like

http.responseCodes.serverError.count
http.responseCodes.serverError.m15_rate
http.responseCodes.serverError.m1_rate
http.responseCodes.serverError.m5_rate
http.responseCodes.serverError.mean_rate

or will be better to create a lot of measurements like http.responseCodes.serverError with fields count, m15_rate, etc?

@ctrlok
Copy link
Contributor Author

ctrlok commented Oct 2, 2017

Hm... there is interesting mistake

2017/10/02 11:12:02 http: TLS handshake error from 127.0.0.1:55467: remote error: tls: bad certificate
FAIL	github.com/influxdata/telegraf/plugins/inputs/http_listener	4.449s

Copy link
Contributor

@phemmer phemmer left a comment

Choose a reason for hiding this comment

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

Not going to speak to the measurement name thing, but there are a few minor things I noticed looking over the code.

return fmt.Errorf("%s returned HTTP status %s", addr.String(), resp.Status)
}

parsed, err := parseResponse(resp.Body, addr.Host)
Copy link
Contributor

Choose a reason for hiding this comment

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

err isn't checked.

counters.tags["type"] = "counters"
for k1, v1 := range jenkinsData.Counters {
for k2, v2 := range v1 {
counters.fields[fmt.Sprintf("%s.%s", k1, k2)] = v2
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a nitpick, though since this gets called a lot it might be significant, but the fmt.Sprintf adds overhead when you can do k1+"."+k2. Same for the similar lines below.

uri := fmt.Sprintf("%s/metrics/%s/metrics", u.Url, u.Token)
addr, err := url.Parse(uri)
if err != nil {
acc.AddError(fmt.Errorf("Unable to parse address '%s': %s", u, err))
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there should be a continue here so that we skip the entry with the bad address.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Actually, I get that line of code from here (https://github.com/influxdata/telegraf/blob/master/plugins/inputs/nginx/nginx.go#L74) so you may want update nginx plugin too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the heads up, I updated the nginx plugin b610276

@ctrlok
Copy link
Contributor Author

ctrlok commented Oct 2, 2017

@phemmer thanks for your review!

@danielnelson
Copy link
Contributor

It looks like Jenkins uses dropwizard style metrics, these are a little tricky to convert to a style that works well with Telegraf's data model. We have pull requests #2846 and #2369 which both attempt it.

Ideally, we would complete the dropwizard json parser first and use it in this plugin, I was holding it up while I rewrote the configuration loading system but perhaps it is best to finish it up before hand so the plugins can use it.

How about we discuss a general way to translate dropwizard metrics to Telegraf metrics over on #2846 and then we can use it here to parse the Jenkins metrics?

@danielnelson
Copy link
Contributor

@ctrlok: We have merged @atzoum's dropwizard parser on master, we should update this plugin to use it internally for handling the incoming metrics.

@sun-mir
Copy link

sun-mir commented May 29, 2018

Any progress on this work?

@russorat
Copy link
Contributor

should we close this in favor of #4022 ?

@danielnelson
Copy link
Contributor

Yes, #4022 will provide a plugin that doesn't require any Jenkins plugins. The Jenkins Metrics Plugin that this PR uses can now be monitored using the http input along with data_format = "dropwizard".

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.

5 participants