From 1014d90478aa1a69f4fbeb5e7384a432560d5ebf Mon Sep 17 00:00:00 2001 From: Tony Clarke Date: Thu, 21 Feb 2019 14:56:28 -0500 Subject: [PATCH 1/5] Add new row to Grafana dashboard that includes four JVM panels --- .../asciidoc/gateway-grafana-dashboard.json | 1426 ++++++++++++++++- 1 file changed, 1367 insertions(+), 59 deletions(-) diff --git a/docs/src/main/asciidoc/gateway-grafana-dashboard.json b/docs/src/main/asciidoc/gateway-grafana-dashboard.json index 95defd61..3e51373d 100644 --- a/docs/src/main/asciidoc/gateway-grafana-dashboard.json +++ b/docs/src/main/asciidoc/gateway-grafana-dashboard.json @@ -14,41 +14,50 @@ "type": "grafana", "id": "grafana", "name": "Grafana", - "version": "4.4.1" + "version": "5.0.0" }, { "type": "panel", "id": "graph", "name": "Graph", - "version": "" + "version": "5.0.0" }, { "type": "datasource", "id": "prometheus", "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "singlestat", - "name": "Singlestat", - "version": "" + "version": "5.0.0" } ], "annotations": { - "list": [] + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] }, "editable": true, "gnetId": null, "graphTooltip": 0, - "hideControls": false, "id": null, + "iteration": 1550777954006, "links": [], - "refresh": "1m", - "rows": [ + "panels": [ { - "collapse": false, - "height": 38, + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 50, "panels": [ { "cacheTimeout": null, @@ -59,7 +68,7 @@ "rgba(191, 148, 112, 0.89)", "rgba(50, 172, 45, 0.97)" ], - "datasource": "${DS_PROMETHEUS}", + "datasource": "prometheus", "description": "", "format": "none", "gauge": { @@ -69,6 +78,12 @@ "thresholdLabels": false, "thresholdMarkers": true }, + "gridPos": { + "h": 3, + "w": 8, + "x": 0, + "y": 2 + }, "hideTimeOverride": false, "id": 28, "interval": null, @@ -98,7 +113,6 @@ "to": "null" } ], - "span": 4, "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", "full": false, @@ -142,7 +156,7 @@ "rgba(191, 148, 112, 0.89)", "rgba(50, 172, 45, 0.97)" ], - "datasource": "${DS_PROMETHEUS}", + "datasource": "prometheus", "description": "", "format": "none", "gauge": { @@ -152,6 +166,12 @@ "thresholdLabels": false, "thresholdMarkers": true }, + "gridPos": { + "h": 3, + "w": 8, + "x": 8, + "y": 2 + }, "hideTimeOverride": false, "id": 29, "interval": null, @@ -181,7 +201,6 @@ "to": "null" } ], - "span": 4, "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", "full": false, @@ -225,7 +244,7 @@ "rgba(191, 148, 112, 0.89)", "rgba(50, 172, 45, 0.97)" ], - "datasource": "${DS_PROMETHEUS}", + "datasource": "prometheus", "description": "", "format": "none", "gauge": { @@ -235,6 +254,12 @@ "thresholdLabels": false, "thresholdMarkers": true }, + "gridPos": { + "h": 3, + "w": 8, + "x": 16, + "y": 2 + }, "hideTimeOverride": false, "id": 30, "interval": null, @@ -264,7 +289,6 @@ "to": "null" } ], - "span": 4, "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", "full": false, @@ -301,23 +325,32 @@ } ], "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": true, "title": "Total Throughput", - "titleSize": "h2" + "type": "row" }, { - "collapse": false, - "height": 250, + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 1 + }, + "id": 51, "panels": [ { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, - "datasource": "${DS_PROMETHEUS}", + "datasource": "prometheus", "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 0, + "y": 3 + }, "id": 49, "legend": { "avg": false, @@ -337,9 +370,294 @@ "points": false, "renderer": "flot", "repeat": "routeId", + "scopedVars": { + "routeId": { + "selected": false, + "text": "ms-test", + "value": "ms-test" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "gateway_requests_seconds_sum{routeId=~\"$routeId\", job=~\"$gatewayService\"}/gateway_requests_seconds_count{routeId=~\"$routeId\", job=~\"$gatewayService\"}", + "format": "time_series", + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ status }}", + "metric": "gateway_api_time_seconds_sum", + "refId": "A", + "step": 240 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "$routeId", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 6, + "y": 3 + }, + "id": 70, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": null, + "repeatIteration": 1550777954005, + "repeatPanelId": 49, + "scopedVars": { + "routeId": { + "selected": false, + "text": "msnext", + "value": "msnext" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "gateway_requests_seconds_sum{routeId=~\"$routeId\", job=~\"$gatewayService\"}/gateway_requests_seconds_count{routeId=~\"$routeId\", job=~\"$gatewayService\"}", + "format": "time_series", + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ status }}", + "metric": "gateway_api_time_seconds_sum", + "refId": "A", + "step": 240 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "$routeId", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 12, + "y": 3 + }, + "id": 71, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": null, + "repeatIteration": 1550777954005, + "repeatPanelId": 49, + "scopedVars": { + "routeId": { + "selected": false, + "text": "msnext-a3s", + "value": "msnext-a3s" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "gateway_requests_seconds_sum{routeId=~\"$routeId\", job=~\"$gatewayService\"}/gateway_requests_seconds_count{routeId=~\"$routeId\", job=~\"$gatewayService\"}", + "format": "time_series", + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ status }}", + "metric": "gateway_api_time_seconds_sum", + "refId": "A", + "step": 240 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "$routeId", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 18, + "y": 3 + }, + "id": 72, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": null, + "repeatIteration": 1550777954005, + "repeatPanelId": 49, + "scopedVars": { + "routeId": { + "selected": false, + "text": "msnext-sample", + "value": "msnext-sample" + } + }, "seriesOverrides": [], "spaceLength": 10, - "span": 4, "stack": false, "steppedLine": false, "targets": [ @@ -392,24 +710,33 @@ } ], "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": true, "title": "Request Processing Time", - "titleSize": "h2" + "type": "row" }, { - "collapse": true, - "height": 250, + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 2 + }, + "id": 52, "panels": [ { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, - "datasource": "${DS_PROMETHEUS}", + "datasource": "prometheus", "description": "", "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 0, + "y": 4 + }, "id": 2, "legend": { "avg": false, @@ -430,9 +757,306 @@ "points": false, "renderer": "flot", "repeat": "routeId", + "scopedVars": { + "routeId": { + "selected": false, + "text": "ms-test", + "value": "ms-test" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "gateway_requests_seconds_count{outcome=\"SUCCESSFUL\", routeId=~\"$routeId\", job=~\"$gatewayService\"}", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ job }} / {{ routeUri }}", + "metric": "gateway_requests_seconds_count", + "refId": "A", + "step": 240 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "$routeId Success API Gateway Calls", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "cumulative" + }, + "transparent": false, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "description": "", + "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 6, + "y": 4 + }, + "id": 73, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "minSpan": null, + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": null, + "repeatIteration": 1550777954005, + "repeatPanelId": 2, + "scopedVars": { + "routeId": { + "selected": false, + "text": "msnext", + "value": "msnext" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "gateway_requests_seconds_count{outcome=\"SUCCESSFUL\", routeId=~\"$routeId\", job=~\"$gatewayService\"}", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ job }} / {{ routeUri }}", + "metric": "gateway_requests_seconds_count", + "refId": "A", + "step": 240 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "$routeId Success API Gateway Calls", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "cumulative" + }, + "transparent": false, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "description": "", + "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 12, + "y": 4 + }, + "id": 74, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "minSpan": null, + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": null, + "repeatIteration": 1550777954005, + "repeatPanelId": 2, + "scopedVars": { + "routeId": { + "selected": false, + "text": "msnext-a3s", + "value": "msnext-a3s" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "gateway_requests_seconds_count{outcome=\"SUCCESSFUL\", routeId=~\"$routeId\", job=~\"$gatewayService\"}", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ job }} / {{ routeUri }}", + "metric": "gateway_requests_seconds_count", + "refId": "A", + "step": 240 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "$routeId Success API Gateway Calls", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "cumulative" + }, + "transparent": false, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "description": "", + "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 18, + "y": 4 + }, + "id": 75, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "minSpan": null, + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": null, + "repeatIteration": 1550777954005, + "repeatPanelId": 2, + "scopedVars": { + "routeId": { + "selected": false, + "text": "msnext-sample", + "value": "msnext-sample" + } + }, "seriesOverrides": [], "spaceLength": 10, - "span": 4, "stack": true, "steppedLine": false, "targets": [ @@ -487,24 +1111,33 @@ } ], "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": true, "title": "Successful API Calls", - "titleSize": "h2" + "type": "row" }, { - "collapse": true, - "height": 250, + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 3 + }, + "id": 53, "panels": [ { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, - "datasource": "${DS_PROMETHEUS}", + "datasource": "prometheus", "description": "", "fill": 1, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 14 + }, "id": 3, "legend": { "avg": false, @@ -526,7 +1159,6 @@ "repeat": "routeId", "seriesOverrides": [], "spaceLength": 10, - "span": 4, "stack": true, "steppedLine": false, "targets": [ @@ -579,24 +1211,33 @@ } ], "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": true, "title": "Unsuccessful API Calls", - "titleSize": "h2" + "type": "row" }, { - "collapse": false, - "height": 250, + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 4 + }, + "id": 54, "panels": [ { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, - "datasource": "${DS_PROMETHEUS}", + "datasource": "prometheus", "description": "", "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 0, + "y": 15 + }, "id": 35, "legend": { "avg": false, @@ -616,9 +1257,297 @@ "points": false, "renderer": "flot", "repeat": "routeId", + "scopedVars": { + "routeId": { + "selected": false, + "text": "ms-test", + "value": "ms-test" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(gateway_requests_seconds_count{routeId=~\"$routeId\", job=~\"$gatewayService\"}) by (job, status)", + "format": "time_series", + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ job }} / {{ status }}", + "metric": "gateway_requests_seconds_count", + "refId": "A", + "step": 240 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "$routeId", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "description": "", + "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 6, + "y": 15 + }, + "id": 58, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": null, + "repeatIteration": 1550775166360, + "repeatPanelId": 35, + "scopedVars": { + "routeId": { + "selected": false, + "text": "msnext", + "value": "msnext" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(gateway_requests_seconds_count{routeId=~\"$routeId\", job=~\"$gatewayService\"}) by (job, status)", + "format": "time_series", + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ job }} / {{ status }}", + "metric": "gateway_requests_seconds_count", + "refId": "A", + "step": 240 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "$routeId", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "description": "", + "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 12, + "y": 15 + }, + "id": 59, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": null, + "repeatIteration": 1550775166360, + "repeatPanelId": 35, + "scopedVars": { + "routeId": { + "selected": false, + "text": "msnext-a3s", + "value": "msnext-a3s" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(gateway_requests_seconds_count{routeId=~\"$routeId\", job=~\"$gatewayService\"}) by (job, status)", + "format": "time_series", + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ job }} / {{ status }}", + "metric": "gateway_requests_seconds_count", + "refId": "A", + "step": 240 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "$routeId", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "description": "", + "fill": 1, + "gridPos": { + "h": 7, + "w": 6, + "x": 18, + "y": 15 + }, + "id": 60, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": null, + "repeatIteration": 1550775166360, + "repeatPanelId": 35, + "scopedVars": { + "routeId": { + "selected": false, + "text": "msnext-sample", + "value": "msnext-sample" + } + }, "seriesOverrides": [], "spaceLength": 10, - "span": 4, "stack": false, "steppedLine": false, "targets": [ @@ -671,14 +1600,392 @@ } ], "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": true, "title": "API / HTTP Status", - "titleSize": "h2" + "type": "row" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 5 + }, + "id": 64, + "panels": [], + "title": "JVM", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_PROMETHEUS}", + "fill": 1, + "gridPos": { + "h": 9, + "w": 6, + "x": 0, + "y": 6 + }, + "id": 62, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "process_cpu_usage{job=~\"$gatewayService\"}", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{ instance }}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "CPU Usage", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_PROMETHEUS}", + "fill": 1, + "gridPos": { + "h": 9, + "w": 6, + "x": 6, + "y": 6 + }, + "id": 69, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(jvm_memory_used_bytes{job=~\"$gatewayService\"}) by (job, instance)", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{ instance }}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Memory Used", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_PROMETHEUS}", + "fill": 1, + "gridPos": { + "h": 9, + "w": 6, + "x": 12, + "y": 6 + }, + "id": 77, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "jvm_threads_live{job=~\"$gatewayService\"}", + "format": "time_series", + "hide": false, + "intervalFactor": 1, + "legendFormat": "{{ instance }}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Live Threads", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "alert": { + "conditions": [ + { + "evaluator": { + "params": [ + 0.3 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "frequency": "60s", + "handler": 1, + "name": "Memory Saturation alert", + "noDataState": "no_data", + "notifications": [] + }, + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_PROMETHEUS}", + "fill": 1, + "gridPos": { + "h": 9, + "w": 6, + "x": 18, + "y": 6 + }, + "id": 79, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "jvm_gc_memory_promoted_bytes_total/jvm_gc_memory_allocated_bytes_total", + "format": "time_series", + "hide": false, + "intervalFactor": 1, + "legendFormat": "{{ instance }}", + "refId": "A" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 0.3 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Memory Saturation", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] } ], - "schemaVersion": 14, + "refresh": "1m", + "schemaVersion": 16, "style": "dark", "tags": [], "templating": { @@ -756,5 +2063,6 @@ }, "timezone": "", "title": "Spring Cloud Gateway", - "version": 1 + "uid": "7voUGKrik", + "version": 5 } From 0492df444361c4029a1d7be74358531dd9b0f370 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Fri, 22 Feb 2019 15:55:32 +0000 Subject: [PATCH 2/5] Update SNAPSHOT to 2.0.3.RELEASE --- docs/pom.xml | 2 +- pom.xml | 8 ++++---- spring-cloud-gateway-core/pom.xml | 2 +- spring-cloud-gateway-dependencies/pom.xml | 4 ++-- spring-cloud-gateway-mvc/pom.xml | 2 +- spring-cloud-gateway-sample/pom.xml | 2 +- spring-cloud-gateway-webflux/pom.xml | 2 +- spring-cloud-starter-gateway/pom.xml | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index 05d56b55..74d763d9 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.3.RELEASE spring-cloud-gateway-docs pom diff --git a/pom.xml b/pom.xml index 1eb033c0..8cea815e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.3.RELEASE pom Spring Cloud Gateway @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-build - 2.0.5.BUILD-SNAPSHOT + 2.0.5.RELEASE @@ -48,8 +48,8 @@ UTF-8 UTF-8 1.8 - 2.0.1.BUILD-SNAPSHOT - 2.0.1.BUILD-SNAPSHOT + 2.0.3.RELEASE + 2.0.3.RELEASE 0.6 diff --git a/spring-cloud-gateway-core/pom.xml b/spring-cloud-gateway-core/pom.xml index 974b0909..9c657d77 100644 --- a/spring-cloud-gateway-core/pom.xml +++ b/spring-cloud-gateway-core/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.3.RELEASE .. spring-cloud-gateway-core diff --git a/spring-cloud-gateway-dependencies/pom.xml b/spring-cloud-gateway-dependencies/pom.xml index fed07fa0..60a99011 100644 --- a/spring-cloud-gateway-dependencies/pom.xml +++ b/spring-cloud-gateway-dependencies/pom.xml @@ -5,12 +5,12 @@ spring-cloud-dependencies-parent org.springframework.cloud - 2.0.5.BUILD-SNAPSHOT + 2.0.5.RELEASE spring-cloud-gateway-dependencies - 2.0.3.BUILD-SNAPSHOT + 2.0.3.RELEASE pom spring-cloud-gateway-dependencies diff --git a/spring-cloud-gateway-mvc/pom.xml b/spring-cloud-gateway-mvc/pom.xml index 50edc79f..f018b174 100644 --- a/spring-cloud-gateway-mvc/pom.xml +++ b/spring-cloud-gateway-mvc/pom.xml @@ -10,7 +10,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.3.RELEASE .. diff --git a/spring-cloud-gateway-sample/pom.xml b/spring-cloud-gateway-sample/pom.xml index 2a66cae2..354358c1 100644 --- a/spring-cloud-gateway-sample/pom.xml +++ b/spring-cloud-gateway-sample/pom.xml @@ -16,7 +16,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.3.RELEASE .. diff --git a/spring-cloud-gateway-webflux/pom.xml b/spring-cloud-gateway-webflux/pom.xml index 19b63469..730614f8 100644 --- a/spring-cloud-gateway-webflux/pom.xml +++ b/spring-cloud-gateway-webflux/pom.xml @@ -10,7 +10,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.3.RELEASE diff --git a/spring-cloud-starter-gateway/pom.xml b/spring-cloud-starter-gateway/pom.xml index ab501c12..ed24e342 100644 --- a/spring-cloud-starter-gateway/pom.xml +++ b/spring-cloud-starter-gateway/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.3.RELEASE .. spring-cloud-starter-gateway From 95166db1f883a3de14aec52a4c2fc76a8ed57a19 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Fri, 22 Feb 2019 15:57:17 +0000 Subject: [PATCH 3/5] Going back to snapshots --- docs/pom.xml | 2 +- pom.xml | 8 ++++---- spring-cloud-gateway-core/pom.xml | 2 +- spring-cloud-gateway-dependencies/pom.xml | 4 ++-- spring-cloud-gateway-mvc/pom.xml | 2 +- spring-cloud-gateway-sample/pom.xml | 2 +- spring-cloud-gateway-webflux/pom.xml | 2 +- spring-cloud-starter-gateway/pom.xml | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index 74d763d9..05d56b55 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.RELEASE + 2.0.3.BUILD-SNAPSHOT spring-cloud-gateway-docs pom diff --git a/pom.xml b/pom.xml index 8cea815e..1eb033c0 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.RELEASE + 2.0.3.BUILD-SNAPSHOT pom Spring Cloud Gateway @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-build - 2.0.5.RELEASE + 2.0.5.BUILD-SNAPSHOT @@ -48,8 +48,8 @@ UTF-8 UTF-8 1.8 - 2.0.3.RELEASE - 2.0.3.RELEASE + 2.0.1.BUILD-SNAPSHOT + 2.0.1.BUILD-SNAPSHOT 0.6 diff --git a/spring-cloud-gateway-core/pom.xml b/spring-cloud-gateway-core/pom.xml index 9c657d77..974b0909 100644 --- a/spring-cloud-gateway-core/pom.xml +++ b/spring-cloud-gateway-core/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.RELEASE + 2.0.3.BUILD-SNAPSHOT .. spring-cloud-gateway-core diff --git a/spring-cloud-gateway-dependencies/pom.xml b/spring-cloud-gateway-dependencies/pom.xml index 60a99011..fed07fa0 100644 --- a/spring-cloud-gateway-dependencies/pom.xml +++ b/spring-cloud-gateway-dependencies/pom.xml @@ -5,12 +5,12 @@ spring-cloud-dependencies-parent org.springframework.cloud - 2.0.5.RELEASE + 2.0.5.BUILD-SNAPSHOT spring-cloud-gateway-dependencies - 2.0.3.RELEASE + 2.0.3.BUILD-SNAPSHOT pom spring-cloud-gateway-dependencies diff --git a/spring-cloud-gateway-mvc/pom.xml b/spring-cloud-gateway-mvc/pom.xml index f018b174..50edc79f 100644 --- a/spring-cloud-gateway-mvc/pom.xml +++ b/spring-cloud-gateway-mvc/pom.xml @@ -10,7 +10,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.RELEASE + 2.0.3.BUILD-SNAPSHOT .. diff --git a/spring-cloud-gateway-sample/pom.xml b/spring-cloud-gateway-sample/pom.xml index 354358c1..2a66cae2 100644 --- a/spring-cloud-gateway-sample/pom.xml +++ b/spring-cloud-gateway-sample/pom.xml @@ -16,7 +16,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.RELEASE + 2.0.3.BUILD-SNAPSHOT .. diff --git a/spring-cloud-gateway-webflux/pom.xml b/spring-cloud-gateway-webflux/pom.xml index 730614f8..19b63469 100644 --- a/spring-cloud-gateway-webflux/pom.xml +++ b/spring-cloud-gateway-webflux/pom.xml @@ -10,7 +10,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.RELEASE + 2.0.3.BUILD-SNAPSHOT diff --git a/spring-cloud-starter-gateway/pom.xml b/spring-cloud-starter-gateway/pom.xml index ed24e342..ab501c12 100644 --- a/spring-cloud-starter-gateway/pom.xml +++ b/spring-cloud-starter-gateway/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.RELEASE + 2.0.3.BUILD-SNAPSHOT .. spring-cloud-starter-gateway From 9d43e083f62dd1f5b83fc661b0e3afe7be28fbfd Mon Sep 17 00:00:00 2001 From: buildmaster Date: Fri, 22 Feb 2019 15:57:17 +0000 Subject: [PATCH 4/5] Bumping versions to 2.0.4.BUILD-SNAPSHOT after release --- docs/pom.xml | 2 +- pom.xml | 2 +- spring-cloud-gateway-core/pom.xml | 2 +- spring-cloud-gateway-dependencies/pom.xml | 2 +- spring-cloud-gateway-mvc/pom.xml | 2 +- spring-cloud-gateway-sample/pom.xml | 2 +- spring-cloud-gateway-webflux/pom.xml | 2 +- spring-cloud-starter-gateway/pom.xml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index 05d56b55..5605c6ab 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.4.BUILD-SNAPSHOT spring-cloud-gateway-docs pom diff --git a/pom.xml b/pom.xml index 1eb033c0..25fadc85 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.4.BUILD-SNAPSHOT pom Spring Cloud Gateway diff --git a/spring-cloud-gateway-core/pom.xml b/spring-cloud-gateway-core/pom.xml index 974b0909..dcb68188 100644 --- a/spring-cloud-gateway-core/pom.xml +++ b/spring-cloud-gateway-core/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.4.BUILD-SNAPSHOT .. spring-cloud-gateway-core diff --git a/spring-cloud-gateway-dependencies/pom.xml b/spring-cloud-gateway-dependencies/pom.xml index fed07fa0..9d99e3b4 100644 --- a/spring-cloud-gateway-dependencies/pom.xml +++ b/spring-cloud-gateway-dependencies/pom.xml @@ -10,7 +10,7 @@ spring-cloud-gateway-dependencies - 2.0.3.BUILD-SNAPSHOT + 2.0.4.BUILD-SNAPSHOT pom spring-cloud-gateway-dependencies diff --git a/spring-cloud-gateway-mvc/pom.xml b/spring-cloud-gateway-mvc/pom.xml index 50edc79f..eccc068a 100644 --- a/spring-cloud-gateway-mvc/pom.xml +++ b/spring-cloud-gateway-mvc/pom.xml @@ -10,7 +10,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.4.BUILD-SNAPSHOT .. diff --git a/spring-cloud-gateway-sample/pom.xml b/spring-cloud-gateway-sample/pom.xml index 2a66cae2..cff08dd5 100644 --- a/spring-cloud-gateway-sample/pom.xml +++ b/spring-cloud-gateway-sample/pom.xml @@ -16,7 +16,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.4.BUILD-SNAPSHOT .. diff --git a/spring-cloud-gateway-webflux/pom.xml b/spring-cloud-gateway-webflux/pom.xml index 19b63469..35fd47de 100644 --- a/spring-cloud-gateway-webflux/pom.xml +++ b/spring-cloud-gateway-webflux/pom.xml @@ -10,7 +10,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.4.BUILD-SNAPSHOT diff --git a/spring-cloud-starter-gateway/pom.xml b/spring-cloud-starter-gateway/pom.xml index ab501c12..ab5f156b 100644 --- a/spring-cloud-starter-gateway/pom.xml +++ b/spring-cloud-starter-gateway/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-gateway - 2.0.3.BUILD-SNAPSHOT + 2.0.4.BUILD-SNAPSHOT .. spring-cloud-starter-gateway From 9f9454b91fbeb00fafad39380ff90139703457cc Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Mon, 25 Feb 2019 13:26:30 -0500 Subject: [PATCH 5/5] Only tests for management port if it's different than server.port. fixes gh-854 --- .../handler/RoutePredicateHandlerMapping.java | 53 +++++++++++--- ...ingSameManagementPortIntegrationTests.java | 69 +++++++++++++++++++ 2 files changed, 113 insertions(+), 9 deletions(-) create mode 100644 spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMappingSameManagementPortIntegrationTests.java diff --git a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMapping.java b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMapping.java index 2b1d9ac0..491a892c 100644 --- a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMapping.java +++ b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMapping.java @@ -29,6 +29,9 @@ import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.reactive.handler.AbstractHandlerMapping; import org.springframework.web.server.ServerWebExchange; +import static org.springframework.cloud.gateway.handler.RoutePredicateHandlerMapping.ManagementPortType.DIFFERENT; +import static org.springframework.cloud.gateway.handler.RoutePredicateHandlerMapping.ManagementPortType.DISABLED; +import static org.springframework.cloud.gateway.handler.RoutePredicateHandlerMapping.ManagementPortType.SAME; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_HANDLER_MAPPER_ATTR; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_PREDICATE_ROUTE_ATTR; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR; @@ -40,25 +43,39 @@ public class RoutePredicateHandlerMapping extends AbstractHandlerMapping { private final FilteringWebHandler webHandler; private final RouteLocator routeLocator; - private final Integer managmentPort; + private final Integer managementPort; + private final ManagementPortType managementPortType; public RoutePredicateHandlerMapping(FilteringWebHandler webHandler, RouteLocator routeLocator, GlobalCorsProperties globalCorsProperties, Environment environment) { this.webHandler = webHandler; this.routeLocator = routeLocator; - if (environment.containsProperty("management.server.port")) { - managmentPort = new Integer(environment.getProperty("management.server.port")); - } else { - managmentPort = null; - } - setOrder(1); + this.managementPort = getPortProperty(environment, "management.server."); + this.managementPortType = getManagementPortType(environment); + setOrder(1); setCorsConfigurations(globalCorsProperties.getCorsConfigurations()); } + private ManagementPortType getManagementPortType(Environment environment) { + Integer serverPort = getPortProperty(environment, "server."); + if (this.managementPort != null && this.managementPort < 0) { + return DISABLED; + } + return ((this.managementPort == null + || (serverPort == null && this.managementPort.equals(8080)) + || (this.managementPort != 0 && this.managementPort.equals(serverPort))) ? SAME + : DIFFERENT); + } + + private static Integer getPortProperty(Environment environment, String prefix) { + return environment.getProperty(prefix + "port", Integer.class); + } + @Override protected Mono getHandlerInternal(ServerWebExchange exchange) { - // don't handle requests on the management port if set - if (managmentPort != null && exchange.getRequest().getURI().getPort() == managmentPort.intValue()) { + // don't handle requests on management port if set and different than server port + if (this.managementPortType == DIFFERENT && this.managementPort != null + && exchange.getRequest().getURI().getPort() == this.managementPort) { return Mono.empty(); } exchange.getAttributes().put(GATEWAY_HANDLER_MAPPER_ATTR, getSimpleName()); @@ -149,4 +166,22 @@ public class RoutePredicateHandlerMapping extends AbstractHandlerMapping { protected String getSimpleName() { return "RoutePredicateHandlerMapping"; } + + public enum ManagementPortType { + + /** + * The management port has been disabled. + */ + DISABLED, + + /** + * The management port is the same as the server port. + */ + SAME, + + /** + * The management port and server port are different. + */ + DIFFERENT; + } } diff --git a/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMappingSameManagementPortIntegrationTests.java b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMappingSameManagementPortIntegrationTests.java new file mode 100644 index 00000000..dae5336e --- /dev/null +++ b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMappingSameManagementPortIntegrationTests.java @@ -0,0 +1,69 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.springframework.cloud.gateway.handler; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.gateway.test.BaseWebClientTests; +import org.springframework.context.annotation.Import; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.util.SocketUtils; + +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = DEFINED_PORT) +@DirtiesContext +public class RoutePredicateHandlerMappingSameManagementPortIntegrationTests extends BaseWebClientTests { + + private static int samePort; + + @BeforeClass + public static void beforeClass() { + samePort = SocketUtils.findAvailableTcpPort(); + System.setProperty("server.port", String.valueOf(samePort)); + System.setProperty("management.server.port", String.valueOf(samePort)); + } + + @AfterClass + public static void afterClass() { + System.clearProperty("server.port"); + System.clearProperty("management.server.port"); + } + + @Test + public void requestsToGatewaySucceed() { + testClient.mutate().baseUrl("http://localhost:"+ samePort).build() + .get().uri("/get") + .exchange() + .expectStatus().isOk(); + } + + @EnableAutoConfiguration + @SpringBootConfiguration + @Import(DefaultTestConfig.class) + public static class TestConfig { } + +}