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

Display custom metrics for pods if they are available. #1109

Merged
merged 1 commit into from
Jan 17, 2017

Conversation

mwringe
Copy link
Contributor

@mwringe mwringe commented Jan 12, 2017

The Hawkular OpenShift Agent is capable of gathering a few custom metrics from pods which are deployed.

This PR will allow these pods to be displayed under the pod's metric page

@mwringe mwringe force-pushed the custom-metrics branch 2 times, most recently from a0ae698 to b899219 Compare January 13, 2017 15:20
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

@mwringe Is this something you wanted for 1.5?

angular.forEach(response, function(metric) {

// set the label to the description if specified
var label = (metric.description !== undefined) ? metric.description : metric.name;
Copy link
Member

Choose a reason for hiding this comment

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

var label = metric.description || metric.name;

var label = (metric.description !== undefined) ? metric.description : metric.name;

// get the unit value if specified
var unit = (metric.unit !== undefined) ? metric.unit : "unknown";
Copy link
Member

Choose a reason for hiding this comment

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

var unit = metric.unit || "unknown";

But maybe the empty string is better if no unit set?

var unit = metric.unit || "";

};
metrics.push(metric);
});
return metrics;
Copy link
Member

Choose a reason for hiding this comment

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

indentation

description: value.tags.description,
};
metrics.push(metric);
});
Copy link
Member

Choose a reason for hiding this comment

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

Suggest using _.map. (Untested, but I think this will work.)

return _.map(response.data, function(value) {
  return {
    name: value.tags.metric_name,
    unit: value.tags.units,
    description: value.tags.description
  };
});

var metric = {
name: value.tags.metric_name,
unit: value.tags.units,
description: value.tags.description,
Copy link
Member

Choose a reason for hiding this comment

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

Extra trailing comma

@spadgett
Copy link
Member

@mwringe
Copy link
Contributor Author

mwringe commented Jan 13, 2017

@spadgett Ok, I made the requested changes to the code.

Custom metrics is something we want for 1.5, we are hoping to have something in the console to display these metrics. If we can not get it the console at this point in time, we will look to create a custom console extension or rely on something like grafana to display them.

@spadgett
Copy link
Member

@mwringe can you add a flag to disable custom metrics to constants.js? something like

https://github.com/openshift/origin-web-console/blob/master/app/scripts/constants.js#L66

@mwringe
Copy link
Contributor Author

mwringe commented Jan 16, 2017

@spadgett do we just want a flag to be added and the rest kept the same? Or a flag to be added and the drop down to still be used instead?

@spadgett
Copy link
Member

my opinion: flag added and the rest kept the same.

@jwforres let me know if you disagree

@jwforres
Copy link
Member

jwforres commented Jan 16, 2017 via email

@mwringe
Copy link
Contributor Author

mwringe commented Jan 17, 2017

Update to include a flag to enable/disable custom metrics.

I also fixed an issue I found where we were not properly fetching counter based metrics and fixed a potential issue with encoding the metric name for the chart prefix.


// note: the prefix needs to follow selector rules
// converting to base64 and cleaning up the special /,+,= characters
var prefix = btoa(metric.name).replace(/\+/g,"_62_").replace(/\//g,"_63_").replace(/\=/g,"");
Copy link
Member

Choose a reason for hiding this comment

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

Suggest this instead for the prefix:

var prefix = _.uniqueId('custom-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.

awesome, that will work

@@ -50,7 +51,12 @@ angular.module("openshiftConsole")

function getRequestURL(config) {
return getMetricsURL().then(function(metricsURL) {
var template = metricsURL + POD_GAUGE_TEMPLATE;
var template;
if (config.type !== undefined && config.type === "counter") {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just

if (config.type === 'counter') { ... }

although probably worth a comment saying gauge is assumed when type is not set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

var url = metricsURL + "/metrics";

var params = {
tags: "custom_metric:true,pod_name:" + podName
Copy link
Member

Choose a reason for hiding this comment

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

Missed this on first review, but should we use pod UID instead in case a pod with the same name is created twice? (For pods that don't have generated names.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, good catch. Thanks. I will fix that.

@mwringe
Copy link
Contributor Author

mwringe commented Jan 17, 2017

Ok, updated with the requested changes.

@spadgett
Copy link
Member

[merge]

@openshift-bot
Copy link

Evaluated for origin web console merge up to 31e7597

@openshift-bot
Copy link

openshift-bot commented Jan 17, 2017

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/927/) (Base Commit: 695c74d)

@openshift-bot openshift-bot merged commit c421188 into openshift:master Jan 17, 2017
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.

4 participants