From e1b9588d8d6bd2239befe252f138837076614d0e Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 10 Jul 2017 07:28:41 -0300 Subject: [elastic] separate cpu and memory graphs --- elastic/generate-config.py | 53 ++++++-- elastic/templates/dashboard-per-test.mustache | 4 +- .../templates/visualization-visState-cpu.mustache | 117 +++++++++++++++++ .../visualization-visState-memory.mustache | 141 +++++++++++++++++++++ .../visualization-visState-resources.mustache | 141 --------------------- 5 files changed, 299 insertions(+), 157 deletions(-) create mode 100644 elastic/templates/visualization-visState-cpu.mustache create mode 100644 elastic/templates/visualization-visState-memory.mustache delete mode 100644 elastic/templates/visualization-visState-resources.mustache diff --git a/elastic/generate-config.py b/elastic/generate-config.py index 6facbd2..9ff1210 100755 --- a/elastic/generate-config.py +++ b/elastic/generate-config.py @@ -10,7 +10,7 @@ import pystache import requests -URL='https://moose.leap.se:9200' +URL = 'https://moose.leap.se:9200' def _get_logger(): @@ -32,11 +32,21 @@ def _delete_jsons(directory): def generate_visualizations(tests): with open(os.path.join('templates', 'visualization.mustache'), 'r') as f: template = f.read() - with open(os.path.join('templates', 'visualization-visState-time.mustache')) as f: + + path = os.path.join('templates', 'visualization-visState-time.mustache') + with open(path) as f: template_visState_time = f.read() - with open(os.path.join('templates', 'visualization-visState-resources.mustache')) as f: - template_visState_resources = f.read() - with open(os.path.join('templates', 'visualization-searchSourceJSON.mustache')) as f: + + path = os.path.join('templates', 'visualization-visState-cpu.mustache') + with open(path) as f: + template_visState_cpu = f.read() + + path = os.path.join('templates', 'visualization-visState-memory.mustache') + with open(path) as f: + template_visState_memory = f.read() + + path = os.path.join('templates', 'visualization-searchSourceJSON.mustache') + with open(path) as f: template_searchSourceJSON = f.read() out_dir = './visualization' @@ -49,7 +59,8 @@ def generate_visualizations(tests): graphs = [ ('time', 'Time taken by ', 'weasel', template_visState_time), - ('resources', 'Resources consumed by ', 'weasel', template_visState_resources) + ('cpu', 'CPU percentage used by ', 'weasel', template_visState_cpu), + ('memory', 'Memory used by ', 'weasel', template_visState_memory) ] for test_name in tests: @@ -59,20 +70,33 @@ def generate_visualizations(tests): out_file = os.path.join(out_dir, test_name + '_' + type + '.json') logger.info('Generating ' + out_file) + query = "commit_info.project:soledad" \ + " AND machine_info.host='" + host + "'" \ + " AND name='" + test_name + "'" +# " AND commit_info.branch='master'" + + # results that are accurate for time are not accurate for memory, + # and vice versa. + if type == 'time' or type == 'cpu': + query += " AND NOT _exists_:extra_info.memory_percent" + else: + query += " AND _exists_:extra_info.memory_percent" + + if type == 'cpu': + query += " AND _exists_:extra_info.cpu_percent" + context = { - 'title': title + test_name, - 'test_name': test_name, - 'query': "commit_info.project:soledad " -# "AND commit_info.branch='master' " - "AND machine_info.host='" + host + "' " - "AND name='" + test_name + "'" + 'title': title + test_name, + 'test_name': test_name, + 'query': query, } visState = pystache.render(template_visState, context) assert json.loads(visState) context['visState'] = json.dumps(visState) - searchSourceJSON = pystache.render(template_searchSourceJSON, context) + searchSourceJSON = pystache.render( + template_searchSourceJSON, context) assert json.loads(searchSourceJSON) context['searchSourceJSON'] = json.dumps(searchSourceJSON) @@ -119,7 +143,8 @@ def _dashboard_for_all_tests(tests): def _dashboard_for_one_test(test): - with open(os.path.join('templates', 'dashboard-per-test.mustache'), 'r') as f: + path = os.path.join('templates', 'dashboard-per-test.mustache') + with open(path, 'r') as f: template = f.read() context = {'test_name': test} rendered = pystache.render(template, context) diff --git a/elastic/templates/dashboard-per-test.mustache b/elastic/templates/dashboard-per-test.mustache index d9b8b52..a397546 100644 --- a/elastic/templates/dashboard-per-test.mustache +++ b/elastic/templates/dashboard-per-test.mustache @@ -1,8 +1,8 @@ { "title": "Benchmarks for {{{test_name}}}", "hits": 0, - "description": "All Soledad benchmak tests run on Weasel", - "panelsJSON": "[{\"size_x\":6,\"size_y\":3,\"panelIndex\":1,\"type\":\"visualization\",\"id\":\"{{{test_name}}}_time\",\"col\":1,\"row\":1},{\"size_x\":6,\"size_y\":3,\"panelIndex\":2,\"type\":\"visualization\",\"id\":\"{{{test_name}}}_resources\",\"col\":7,\"row\":1}]", + "description": "Per-test benchmarks for {{{test_name}}}", + "panelsJSON": "[{\"col\":1,\"id\":\"{{{test_name}}}_time\",\"panelIndex\":1,\"row\":1,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"},{\"col\":1,\"id\":\"{{{test_name}}}_cpu\",\"panelIndex\":3,\"row\":4,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"},{\"size_x\":6,\"size_y\":3,\"panelIndex\":4,\"type\":\"visualization\",\"id\":\"{{{test_name}}}_memory\",\"col\":7,\"row\":1}]", "optionsJSON": "{\"darkTheme\":true}", "uiStateJSON": "{}", "version": 1, diff --git a/elastic/templates/visualization-visState-cpu.mustache b/elastic/templates/visualization-visState-cpu.mustache new file mode 100644 index 0000000..e078f46 --- /dev/null +++ b/elastic/templates/visualization-visState-cpu.mustache @@ -0,0 +1,117 @@ +{ + "type" : "line", + "aggs" : [ + { + "params" : { + "field" : "extra_info.cpu_percent", + "customLabel" : "CPU usage (%)" + }, + "schema" : "metric", + "enabled" : true, + "type" : "avg", + "id" : "1" + }, + { + "type" : "terms", + "enabled" : true, + "schema" : "segment", + "params" : { + "orderAgg" : { + "params" : { + "field" : "commit_info.time" + }, + "type" : "min", + "enabled" : true, + "schema" : "orderAgg", + "id" : "2-orderAgg" + }, + "order" : "asc", + "field" : "commit_id_and_date", + "size" : 50, + "orderBy" : "custom", + "customLabel" : "Commit info: id and date" + }, + "id" : "2" + } + ], + "listeners" : {}, + "params" : { + "addTimeMarker" : false, + "showCircles" : true, + "addTooltip" : true, + "scale" : "linear", + "legendPosition" : "right", + "valueAxes" : [ + { + "type" : "value", + "scale" : { + "type" : "linear", + "mode" : "normal" + }, + "show" : true, + "style" : {}, + "position" : "left", + "name" : "LeftAxis-1", + "labels" : { + "filter" : false, + "rotate" : 0, + "show" : true, + "truncate" : 100 + }, + "title" : { + "text" : "CPU usage (%)" + }, + "id" : "ValueAxis-1" + } + ], + "addLegend" : true, + "grid" : { + "style" : { + "color" : "#eee" + }, + "categoryLines" : false + }, + "radiusRatio" : 9, + "defaultYExtents" : false, + "setYExtents" : false, + "interpolate" : "linear", + "categoryAxes" : [ + { + "title" : { + "text" : "Commit info: id and date" + }, + "id" : "CategoryAxis-1", + "labels" : { + "truncate" : 100, + "show" : true + }, + "position" : "bottom", + "show" : false, + "style" : {}, + "scale" : { + "type" : "linear" + }, + "type" : "category" + } + ], + "drawLinesBetweenPoints" : true, + "seriesParams" : [ + { + "drawLinesBetweenPoints" : true, + "show" : true, + "valueAxis" : "ValueAxis-1", + "interpolate" : "linear", + "type" : "line", + "data" : { + "label" : "CPU usage (%)", + "id" : "1" + }, + "mode" : "normal", + "showCircles" : true, + "lineWidth" : 2 + } + ], + "times" : [] + }, + "title" : "CPU usage for {{{test_name}}}" +} diff --git a/elastic/templates/visualization-visState-memory.mustache b/elastic/templates/visualization-visState-memory.mustache new file mode 100644 index 0000000..7fc3bb8 --- /dev/null +++ b/elastic/templates/visualization-visState-memory.mustache @@ -0,0 +1,141 @@ +{ + "listeners" : {}, + "params" : { + "interpolate" : "linear", + "legendPosition" : "right", + "setYExtents" : false, + "seriesParams" : [ + { + "drawLinesBetweenPoints" : true, + "data" : { + "label" : "Mean memory (%)", + "id" : "1" + }, + "showCircles" : true, + "interpolate" : "linear", + "type" : "line", + "show" : true, + "valueAxis" : "ValueAxis-1", + "mode" : "normal", + "lineWidth" : 2 + }, + { + "show" : true, + "mode" : "normal", + "lineWidth" : 2, + "valueAxis" : "ValueAxis-1", + "data" : { + "label" : "Max memory (%)", + "id" : "3" + }, + "drawLinesBetweenPoints" : true, + "interpolate" : "linear", + "type" : "line", + "showCircles" : true + } + ], + "drawLinesBetweenPoints" : true, + "addLegend" : true, + "addTooltip" : true, + "categoryAxes" : [ + { + "id" : "CategoryAxis-1", + "scale" : { + "type" : "linear" + }, + "style" : {}, + "type" : "category", + "show" : false, + "title" : { + "text" : "Commit info: id and date" + }, + "labels" : { + "truncate" : 100, + "show" : true + }, + "position" : "bottom" + } + ], + "times" : [], + "valueAxes" : [ + { + "style" : {}, + "show" : true, + "name" : "LeftAxis-1", + "id" : "ValueAxis-1", + "scale" : { + "mode" : "normal", + "type" : "linear" + }, + "position" : "left", + "type" : "value", + "title" : { + "text" : "" + }, + "labels" : { + "rotate" : 0, + "filter" : false, + "show" : true, + "truncate" : 100 + } + } + ], + "showCircles" : true, + "scale" : "linear", + "grid" : { + "style" : { + "color" : "#eee" + }, + "categoryLines" : false + }, + "defaultYExtents" : false, + "radiusRatio" : 9, + "addTimeMarker" : false + }, + "aggs" : [ + { + "enabled" : true, + "schema" : "metric", + "params" : { + "field" : "extra_info.memory_percent.stats.mean", + "customLabel" : "Mean memory (%)" + }, + "type" : "avg", + "id" : "1" + }, + { + "type" : "terms", + "id" : "2", + "params" : { + "customLabel" : "Commit id and time", + "orderAgg" : { + "id" : "2-orderAgg", + "type" : "min", + "enabled" : true, + "schema" : "orderAgg", + "params" : { + "field" : "commit_info.time" + } + }, + "size" : 50, + "order" : "desc", + "field" : "commit_id_and_date", + "orderBy" : "custom" + }, + "enabled" : true, + "schema" : "segment" + }, + { + "type" : "avg", + "id" : "3", + "enabled" : true, + "schema" : "metric", + "params" : { + "field" : "extra_info.memory_percent.stats.max", + "customLabel" : "Maximum memory (%)" + } + } + ], + "title" : "Memory usage: {{{test_name}}}", + "type" : "line" +} diff --git a/elastic/templates/visualization-visState-resources.mustache b/elastic/templates/visualization-visState-resources.mustache deleted file mode 100644 index 53b008a..0000000 --- a/elastic/templates/visualization-visState-resources.mustache +++ /dev/null @@ -1,141 +0,0 @@ -{ - "aggs" : [ - { - "type" : "avg", - "enabled" : true, - "params" : { - "field" : "extra_info.cpu_percent", - "customLabel" : "CPU usage (%)" - }, - "schema" : "metric", - "id" : "1" - }, - { - "id" : "2", - "schema" : "segment", - "type" : "terms", - "enabled" : true, - "params" : { - "orderAgg" : { - "id" : "2-orderAgg", - "schema" : "orderAgg", - "params" : { - "field" : "commit_info.time" - }, - "type" : "min", - "enabled" : true - }, - "orderBy" : "custom", - "customLabel" : "Commit info: id and date", - "order" : "asc", - "size" : 1000, - "field" : "commit_id_and_date" - } - }, - { - "schema" : "metric", - "id" : "3", - "params" : { - "field" : "extra_info.memory_percent.stats.max", - "customLabel" : "Memory usage (%)" - }, - "type" : "avg", - "enabled" : true - } - ], - "title" : "Resources used by {{{test_name}}}", - "params" : { - "valueAxes" : [ - { - "scale" : { - "mode" : "normal", - "type" : "linear" - }, - "position" : "left", - "type" : "value", - "title" : { - "text" : "" - }, - "name" : "LeftAxis-1", - "id" : "ValueAxis-1", - "style" : {}, - "labels" : { - "show" : true, - "filter" : false, - "rotate" : 0, - "truncate" : 100 - }, - "show" : true - } - ], - "legendPosition" : "right", - "seriesParams" : [ - { - "showCircles" : true, - "type" : "line", - "interpolate" : "linear", - "data" : { - "id" : "1", - "label" : "CPU usage (%)" - }, - "drawLinesBetweenPoints" : true, - "show" : true, - "lineWidth" : 2, - "valueAxis" : "ValueAxis-1", - "mode" : "normal" - }, - { - "showCircles" : true, - "interpolate" : "linear", - "type" : "line", - "data" : { - "label" : "Memory usage (%)", - "id" : "3" - }, - "drawLinesBetweenPoints" : true, - "show" : true, - "mode" : "normal", - "valueAxis" : "ValueAxis-1", - "lineWidth" : 2 - } - ], - "setYExtents" : false, - "defaultYExtents" : false, - "radiusRatio" : 9, - "grid" : { - "categoryLines" : false, - "style" : { - "color" : "#eee" - } - }, - "times" : [], - "interpolate" : "linear", - "showCircles" : true, - "scale" : "linear", - "addTimeMarker" : false, - "addLegend" : true, - "addTooltip" : true, - "drawLinesBetweenPoints" : true, - "categoryAxes" : [ - { - "id" : "CategoryAxis-1", - "style" : {}, - "labels" : { - "show" : true, - "truncate" : 100 - }, - "show" : false, - "scale" : { - "type" : "linear" - }, - "position" : "bottom", - "type" : "category", - "title" : { - "text" : "Commit info: id and date" - } - } - ] - }, - "type" : "line", - "listeners" : {} -} -- cgit v1.2.3