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

Updates to status API, re-align status page #10180

Merged
merged 12 commits into from
Feb 16, 2017
Merged

Conversation

jbudz
Copy link
Member

@jbudz jbudz commented Feb 3, 2017

  • snake_case, Discuss casing in the API #5429
  • share latest metrics instead of samples over time
  • add concurrent connections, uptime, requests
  • added config to remove metrics from api response
  • modify several field names to match elasticsearch, eg buildSha -> version.build_hash
    before:
{
  name: "esc1d1",
  version: "5.2.0",
  buildNum: 14695,
  buildSha: "9b0119b706e53fbd67b447381fe80f71b9996893",
  uuid: "a3ed392d-695c-4a3e-998c-bd7724b93124",
  status: {
    overall: {
      state: "green",
      title: "Green",
      nickname: "Looking good",
      icon: "success",
      since: "2017-02-01T03:14:42.000Z"
    },
    statuses: [
      {
        id: "ui settings",
        state: "green",
        icon: "success",
        message: "Ready",
        since: "2017-02-01T03:22:46.773Z"
      },
      {
        id: "plugin:kibana@5.2.0",
        state: "green",
        icon: "success",
        message: "Ready",
        since: "2017-02-01T03:14:42.000Z"
      },
      {
        id: "plugin:elasticsearch@5.2.0",
        state: "green",
        icon: "success",
        message: "Kibana index ready",
        since: "2017-02-01T03:22:46.772Z"
      },
      {
        id: "plugin:console@5.2.0",
        state: "green",
        icon: "success",
        message: "Ready",
        since: "2017-02-01T03:14:42.176Z"
      },
      {
        id: "plugin:timelion@5.2.0",
        state: "green",
        icon: "success",
        message: "Ready",
        since: "2017-02-01T03:14:42.528Z"
      }
    ]
  },
  metrics: {
    heapTotal: [
      [
        1486147535911,
        70504448
      ],
      [
        1486147530910,
        69455872
      ],
      [
        1486147525908,
        69455872
      ],
      [
        1486147520906,
        69455872
      ],
      [
        1486147515904,
        69455872
      ],
      [
        1486147510903,
        69455872
      ],
      [
        1486147505901,
        69455872
      ],
      [
        1486147500898,
        69455872
      ],
      [
        1486147495896,
        69455872
      ],
      [
        1486147490894,
        69455872
      ],
      [
        1486147485891,
        69455872
      ],
      [
        1486147480890,
        69455872
      ]
    ],
    heapUsed: [
      [
        1486147535911,
        61269984
      ],
      [
        1486147530910,
        61552528
      ],
      [
        1486147525908,
        61141568
      ],
      [
        1486147520906,
        61425648
      ],
      [
        1486147515904,
        61014688
      ],
      [
        1486147510903,
        61294040
      ],
      [
        1486147505901,
        60883080
      ],
      [
        1486147500898,
        61164496
      ],
      [
        1486147495896,
        60753536
      ],
      [
        1486147490894,
        61034624
      ],
      [
        1486147485891,
        60626848
      ],
      [
        1486147480890,
        60908728
      ]
    ],
    load: [
      [
        1486147535911,
        [
          0.1181640625,
          0.1103515625,
          0.0908203125
        ]
      ],
      [
        1486147530910,
        [
          0.12890625,
          0.1123046875,
          0.091796875
        ]
      ],
      [
        1486147525908,
        [
          0.140625,
          0.1142578125,
          0.0927734375
        ]
      ],
      [
        1486147520906,
        [
          0.1533203125,
          0.1162109375,
          0.09375
        ]
      ],
      [
        1486147515904,
        [
          0.07958984375,
          0.10107421875,
          0.08837890625
        ]
      ],
      [
        1486147510903,
        [
          0.0869140625,
          0.10302734375,
          0.0888671875
        ]
      ],
      [
        1486147505901,
        [
          0.0947265625,
          0.10498046875,
          0.08935546875
        ]
      ],
      [
        1486147500898,
        [
          0.10302734375,
          0.10693359375,
          0.08984375
        ]
      ],
      [
        1486147495896,
        [
          0.1123046875,
          0.10888671875,
          0.09033203125
        ]
      ],
      [
        1486147490894,
        [
          0.12255859375,
          0.11083984375,
          0.0908203125
        ]
      ],
      [
        1486147485891,
        [
          0.13330078125,
          0.11279296875,
          0.091796875
        ]
      ],
      [
        1486147480890,
        [
          0.14501953125,
          0.11474609375,
          0.0927734375
        ]
      ]
    ],
    responseTimeAvg: [
      [
        1486147535911,
        null
      ],
      [
        1486147530910,
        null
      ],
      [
        1486147525908,
        null
      ],
      [
        1486147520906,
        null
      ],
      [
        1486147515904,
        null
      ],
      [
        1486147510903,
        null
      ],
      [
        1486147505901,
        null
      ],
      [
        1486147500898,
        null
      ],
      [
        1486147495896,
        null
      ],
      [
        1486147490894,
        null
      ],
      [
        1486147485891,
        null
      ],
      [
        1486147480890,
        null
      ]
    ],
    responseTimeMax: [
      [
        1486147535911,
        0
      ],
      [
        1486147530910,
        0
      ],
      [
        1486147525908,
        0
      ],
      [
        1486147520906,
        0
      ],
      [
        1486147515904,
        0
      ],
      [
        1486147510903,
        0
      ],
      [
        1486147505901,
        0
      ],
      [
        1486147500898,
        0
      ],
      [
        1486147495896,
        0
      ],
      [
        1486147490894,
        0
      ],
      [
        1486147485891,
        0
      ],
      [
        1486147480890,
        0
      ]
    ],
    requestsPerSecond: [
      [
        1486147535911,
        0
      ],
      [
        1486147530910,
        0
      ],
      [
        1486147525908,
        0
      ],
      [
        1486147520906,
        0
      ],
      [
        1486147515904,
        0
      ],
      [
        1486147510903,
        0
      ],
      [
        1486147505901,
        0
      ],
      [
        1486147500898,
        0
      ],
      [
        1486147495896,
        0
      ],
      [
        1486147490894,
        0
      ],
      [
        1486147485891,
        0
      ],
      [
        1486147480890,
        0
      ]
    ]
  }
}

image

after:

{
  name: "Jons-MacBook-Pro-2.local",
  uuid: "5b2de169-2785-441b-ae8c-186a1936b17d",
  version: {
    number: "6.0.0-alpha1",
    build_hash: "6cb7fec4e154faa0a4a3fee4b33dfef91b9870d9",
    build_number: 8467,
    build_snapshot: false
  },
  status: {
    overall: {
      state: "green",
      title: "Green",
      nickname: "Looking good",
      icon: "success",
      since: "2017-02-15T17:11:45.042Z"
    },
    statuses: [
      {
        id: "ui settings",
        state: "green",
        icon: "success",
        message: "Ready",
        since: "2017-02-15T17:11:46.042Z"
      },
      {
        id: "plugin:kibana@6.0.0-alpha1",
        state: "green",
        icon: "success",
        message: "Ready",
        since: "2017-02-15T17:11:45.042Z"
      },
      {
        id: "plugin:elasticsearch@6.0.0-alpha1",
        state: "green",
        icon: "success",
        message: "Kibana index ready",
        since: "2017-02-15T17:11:46.033Z"
      },
      {
        id: "plugin:console@6.0.0-alpha1",
        state: "green",
        icon: "success",
        message: "Ready",
        since: "2017-02-15T17:11:45.125Z"
      },
      {
        id: "plugin:timelion@6.0.0-alpha1",
        state: "green",
        icon: "success",
        message: "Ready",
        since: "2017-02-15T17:11:46.034Z"
      }
    ]
  },
  metrics: {
    last_updated: "2017-02-15T17:21:14.314Z",
    collection_interval_in_millis: 5000,
    uptime_in_millis: 573027,
    process: {
      mem: {
        heap_max_in_bytes: 113516544,
        heap_used_in_bytes: 98240248
      }
    },
    os: {
      cpu: {
        load_average: {
          1m: 1.75634765625,
          5m: 1.755859375,
          15m: 1.755859375
        }
      }
    },
    response_times: {
      avg_in_millis: 74.58333333333333,
      max_in_millis: 802
    },
    requests: {
      total: 12,
      disconnects: 0,
      status_codes: {
        200: 12
      }
    },
    concurrent_connections: 0
  }
}

image

collection_time_in_millis: config.get('ops.interval'),
uptime_in_millis: process.uptime() * 1000,
process: {
heap: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to nest this under memory as monitoring has done?

const timestamp = new Date().toISOString();
kbnServer.metrics = {
last_updated: timestamp,
collection_time_in_millis: config.get('ops.interval'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I really dislike shorthand, but it appears this is the standard set in ES. Thoughts on collection_interval_in_millis? I feel like we can make it a bit more descriptive.

status: kbnServer.status.toJSON()
};

if (config.get('status.metrics')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a time which we would not want to return the metrics? This could cause problems with beats consuming it if they can't rely on it being returned.

In 5.x we will need to provide a config to toggle the format introduced in this PR.

@jbudz jbudz force-pushed the status-api branch 2 times, most recently from aaf4cc0 to f2239b3 Compare February 6, 2017 14:17
@tbragin tbragin added the Team:Operations Team label for Operations Team label Feb 6, 2017
@jbudz jbudz removed the tests_needed label Feb 6, 2017
Copy link
Contributor

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

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

LGTM

@epixa
Copy link
Contributor

epixa commented Feb 10, 2017

Tests failed on this

@epixa epixa self-assigned this Feb 13, 2017
@epixa
Copy link
Contributor

epixa commented Feb 13, 2017

I'm getting this error in browser console when I visit the status page:

TypeError: Cannot read property 'length' of undefined
    at formatNumber (http://zero:5601/bundles/status_page.bundle.js?v=8467:433:37)
    at formatNumeral (http://zero:5601/bundles/status_page.bundle.js?v=8467:127:23)
    at Numeral.format (http://zero:5601/bundles/status_page.bundle.js?v=8467:660:21)
    at formatNumber (http://zero:5601/bundles/status_page.bundle.js?v=8467:1139:39)
    at http://zero:5601/bundles/status_page.bundle.js?v=8467:1092:43
    at Array.map (native)
    at http://zero:5601/bundles/status_page.bundle.js?v=8467:1091:21
    at fn (eval at compile (http://zero:5601/bundles/commons.bundle.js?v=8467:35087:16), <anonymous>:4:333)
    at regularInterceptedExpression (http://zero:5601/bundles/commons.bundle.js?v=8467:36167:22)
    at Object.expressionInputsWatch [as get] (http://zero:5601/bundles/commons.bundle.js?v=8467:36095:25)

Copy link
Contributor

@epixa epixa left a comment

Choose a reason for hiding this comment

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

This is looking good other than the bug in the console log.

},
os: {
cpu: {
load: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to load_average to align with ES?

process: {
mem: {
heap: {
total_in_bytes: _.get(event, 'psmem.heapTotal'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to heap_max_in_bytes and nest under mem to align with ES?

mem: {
heap: {
total_in_bytes: _.get(event, 'psmem.heapTotal'),
used_in_bytes: _.get(event, 'psmem.heapUsed')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to heap_used_in_bytes and nest under mem to align with ES?

@tylersmalley
Copy link
Contributor

@epixa, this is ready for another look.

@epixa
Copy link
Contributor

epixa commented Feb 15, 2017

If you're both comfortable with this, I am. I gave it a pretty thorough review before, and the recent changes are minimal.

@epixa
Copy link
Contributor

epixa commented Feb 15, 2017

@ruflin Do you want to look at this API response before we merge it?

@tylersmalley
Copy link
Contributor

Here is an example output of /api/status

{
  "name":"tsmalley",
  "uuid":"43469b79-7cfa-46fb-a187-387f2d1252d3",
  "version":{
    "number":"6.0.0-alpha1",
    "build_hash":"6cb7fec4e154faa0a4a3fee4b33dfef91b9870d9",
    "build_number":8467,
    "build_snapshot":false
  },
  "status":{
    "overall":{
      "state":"red",
      "title":"Red",
      "nickname":"Danger Will Robinson! Danger!",
      "icon":"danger",
      "since":"2017-02-15T22:05:09.916Z"
    },
    "statuses":[
      {
        "id":"ui settings",
        "state":"red",
        "icon":"danger",
        "message":"Elasticsearch plugin is red",
        "since":"2017-02-15T22:05:10.198Z"
      },
      {
        "id":"plugin:kibana@6.0.0-alpha1",
        "state":"green",
        "icon":"success",
        "message":"Ready",
        "since":"2017-02-15T22:05:09.820Z"
      },
      {
        "id":"plugin:elasticsearch@6.0.0-alpha1",
        "state":"red",
        "icon":"danger",
        "message":"Unable to connect to Elasticsearch at http://localhost:9200.",
        "since":"2017-02-15T22:05:09.916Z"
      },
      {
        "id":"plugin:console@6.0.0-alpha1",
        "state":"green",
        "icon":"success",
        "message":"Ready",
        "since":"2017-02-15T22:05:09.907Z"
      },
      {
        "id":"plugin:timelion@6.0.0-alpha1",
        "state":"green",
        "icon":"success",
        "message":"Ready",
        "since":"2017-02-15T22:05:10.189Z"
      }
    ]
  },
  "metrics":{
    "last_updated":"2017-02-15T22:05:23.605Z",
    "collection_interval_in_millis":5000,
    "uptime_in_millis":19416,
    "process":{
      "mem":{
        "heap_max_in_bytes":201592832,
        "heap_used_in_bytes":174029824
      }
    },
    "os":{
      "cpu":{
        "load_average":{
          "1m":4.51513671875,
          "5m":3.46142578125,
          "15m":3.46142578125
        }
      }
    },
    "response_times":{
      "avg_in_millis":null,
      "max_in_millis":0
    },
    "requests":{
      "total":0,
      "disconnects":0,
      "status_codes":{

      }
    },
    "concurrent_connections":2
  }
}

@ruflin
Copy link
Contributor

ruflin commented Feb 16, 2017

@epixa @tylersmalley LGTM. Most important part for me is that there are no arrays (beside the statuses one) and only one set of values. That is the case here.

Thanks for all the work on this one.

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

Successfully merging this pull request may close these issues.

6 participants