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

Link scope-ui graphs clickable to prometheus queries #2664

Merged
merged 31 commits into from
Aug 15, 2017

Conversation

rndstr
Copy link
Contributor

@rndstr rndstr commented Jun 29, 2017

scope-app:

  • Adds -app.metrics-graph cli flag for configuring the base url to
    use for graph links; supports :orgID and :query placeholders
  • Assigns query URLs to existing metrics and creates an empty metric if it's missing

scope-ui:

  • Extends <CloudFeature /> with option alwaysShow
  • Adds <CloudLink /> to simplify routing when in cloud vs not in cloud
  • Links metric graphs in the ui's node details view for all k8s
    toplogies and containers so far

TODO

  • receive design suggestions
  • deal with overflow items (remove dead code in case not in use)
  • verify naming of pods in k8s for queries
  • integration tests (postponed)
  • lint errors

As long as there is no --app.metrics-graph configured, this features is invisible.

Screenshots
scope-metric-links-hover
scope-metric-links-overflow
scope-metric-links-tableview

@rndstr rndstr changed the title Link scope-ui graphs clickable to prometheus queries [WIP] Link scope-ui graphs clickable to prometheus queries Jun 29, 2017
prog/main.go Outdated
@@ -353,6 +354,7 @@ func setupFlags(flags *flags) {
flag.IntVar(&flags.app.memcachedCompressionLevel, "app.memcached.compression", gzip.DefaultCompression, "How much to compress reports stored in memcached.")
flag.StringVar(&flags.app.userIDHeader, "app.userid.header", "", "HTTP header to use as userid")
flag.BoolVar(&flags.app.externalUI, "app.externalUI", false, "Point to externally hosted static UI assets")
flag.StringVar(&flags.app.metricsGraphURL, "app.metrics-graph", "", "Enable extended metrics graph by providing a templated URL (supports :orgID and :query)")

This comment was marked as abuse.

}
params := &queryParams{[]cell{{[]string{query}}}}

bs, err := json.Marshal(params)

This comment was marked as abuse.

@2opremio
Copy link
Contributor

Please fix the linting errors.

@bboreham
Copy link
Collaborator

bboreham commented Jul 4, 2017

I note that #2620 anticipates some further additions, e.g. StatefulSet/PetSet. Should we also anticipate them here?

// Prometheus queries for topologies
topologyQueries = map[string]map[string]*template.Template{
report.Pod: {
docker.MemoryUsage: prepareTemplate(`sum(container_memory_usage_bytes{pod_name="{{.Label}}"})`),

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

"github.com/ugorji/go/codec"
)

// MetricLink describes a link referencing a metric.

This comment was marked as abuse.

This comment was marked as abuse.


var (
// As configured by the user
metricsGraphURL = ""

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@rndstr rndstr force-pushed the scope-cortex-ui-link-promquery branch 3 times, most recently from 9c3e7c9 to b43dfd2 Compare July 12, 2017 10:47
@rndstr rndstr force-pushed the scope-cortex-ui-link-promquery branch 2 times, most recently from 388a599 to 9c57959 Compare July 24, 2017 12:09
@rndstr rndstr changed the title [WIP] Link scope-ui graphs clickable to prometheus queries Link scope-ui graphs clickable to prometheus queries Jul 24, 2017
Copy link
Contributor

@davkal davkal left a comment

Choose a reason for hiding this comment

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

LGTM, only minor issues.

UX has been discussed separately. This is a good first step.


onClick() {
trackMixpanelEvent('scope.node.metric.click', {
layout: GRAPH_VIEW_MODE,

This comment was marked as abuse.

This comment was marked as abuse.

@@ -20,7 +21,12 @@ export default class NodeDetailsHealth extends React.Component {
}

render() {
const metrics = this.props.metrics || [];
const {
metrics = makeList(),

This comment was marked as abuse.

This comment was marked as abuse.


onClick() {
trackMixpanelEvent('scope.node.metric.click', {
layout: TABLE_VIEW_MODE,

This comment was marked as abuse.

This comment was marked as abuse.

});
}

static dismissEvent(ev) {

This comment was marked as abuse.

@@ -109,7 +109,7 @@ function getSortedNodes(nodes, sortedByHeader, sortedDesc) {
const getValue = getValueForSortedBy(sortedByHeader);
const withAndWithoutValues = groupBy(nodes, (n) => {
const v = getValue(n);
return v !== null && v !== undefined ? 'withValues' : 'withoutValues';
return !n.valueEmpty && v !== null && v !== undefined ? 'withValues' : 'withoutValues';

This comment was marked as abuse.

This comment was marked as abuse.


export function darkenColor(c) {
let color = hsl(c);
if (hsl.l < 0.5) {

This comment was marked as abuse.

This comment was marked as abuse.

"d3-zoom": "1.1.4",
"dagre": "0.7.4",
"debug": "2.6.6",
"filesize": "3.5.9",
"filter-invalid-dom-props": "^2.0.0",

This comment was marked as abuse.

This comment was marked as abuse.

<NodeDetailsHealth
metrics={details.metrics}
topologyId={topologyId}
nodeColor={nodeColor}

This comment was marked as abuse.

This comment was marked as abuse.

}

bs.Reset()
if err := tpl.Execute(&bs, summary); err != nil {

This comment was marked as abuse.

This comment was marked as abuse.

return ""
}

if metricsGraphURL[len(metricsGraphURL)-1] != '/' {

This comment was marked as abuse.

This comment was marked as abuse.

@rndstr rndstr force-pushed the scope-cortex-ui-link-promquery branch 3 times, most recently from f1be917 to 21d909d Compare August 1, 2017 10:30
@@ -12,6 +12,10 @@
// TODO: Remove this line once Service UI CONFIGURE button stops being added to Scope.
.scope-wrapper .setup-nav-button { display: none; }

a {
text-decoration: none;

This comment was marked as abuse.

@rndstr
Copy link
Contributor Author

rndstr commented Aug 3, 2017

@2opremio @davkal @bboreham PTAL?

@rndstr rndstr force-pushed the scope-cortex-ui-link-promquery branch 2 times, most recently from 6931aa6 to 69c4430 Compare August 14, 2017 14:04
rndstr added 3 commits August 14, 2017 18:46
scope-app:
- Adds `-app.metrics-graph` cli flag for configuring the base url to
  use for graph links; supports `:orgID` and `:query` placeholders
- Renders `metric_links` in node detail API response

scope-ui:
- Extends `<CloudFeature />` with option `alwaysShow` and adds
  boolean `isCloud` property
- Links metric graphs in the ui's node details view for all k8s
  toplogies; or displays placeholder graph if no metrics available
rndstr added 22 commits August 14, 2017 18:46
The initial idea was to keep it separate since the unattached
links were also to be displayed distinctively from the metrics.
With the new design, unattached links are rendered in the same
list as metrics with attached links.

Therefore, we treat unattached metric links as an empty metric.
@rndstr rndstr force-pushed the scope-cortex-ui-link-promquery branch from 69c4430 to b47cfbd Compare August 14, 2017 17:46
@davkal
Copy link
Contributor

davkal commented Aug 15, 2017

Latest JS changes LGTM. Cant wait to see it on dev!

output := []Connection{}
for row, count := range c.counts {
// Use MakeNodeSummary to render the id and label of this node
// TODO(paulbellamy): Would be cleaner if we hade just a
// MakeNodeID(ns[row.remoteNodeID]). As we don't need the whole summary.
summary, _ := MakeNodeSummary(r, ns[row.remoteNodeID])
summary, _ := MakeNodeSummary(r, ns[row.remoteNodeID], metricsGraphURL)

This comment was marked as abuse.

@@ -15,7 +15,7 @@ import (
// MetricLink describes a URL referencing a metric.
type MetricLink struct {
// References the metric id
ID string `json:"id,omitempty"`
ID string `json:"id"`

This comment was marked as abuse.

@rndstr rndstr merged commit 0d381a3 into master Aug 15, 2017
@rndstr rndstr deleted the scope-cortex-ui-link-promquery branch August 15, 2017 17:56
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