diff --git a/example/observability_infrastructure/docker-compose.yml b/example/observability_infrastructure/docker-compose.yml new file mode 100644 index 0000000..7980721 --- /dev/null +++ b/example/observability_infrastructure/docker-compose.yml @@ -0,0 +1,28 @@ +version: '3' +services: + influxdb: + image: influxdb:1.8 + environment: + - INFLUXDB_DB=locust + ports: + - "8086:8086" + volumes: + - influxdb-data:/var/lib/influxdb + + grafana: + image: grafana/grafana:latest + ports: + - "80:3000" + - "443:3000" + environment: + GF_SERVER_ROOT_URL: "%(protocol)s://%(domain)s:%(http_port)s/" + GF_AUTH_ANONYMOUS_ENABLED: "true" + GF_AUTH_ANONYMOUS_ORG_ROLE: "Viewer" + GF_PATHS_PROVISIONING: "/etc/grafana/provisioning" + volumes: + - grafana-data:/var/lib/grafana + - ./provisioning:/etc/grafana/provisioning + +volumes: + influxdb-data: + grafana-data: \ No newline at end of file diff --git a/example/observability_infrastructure/provisioning/dashboards/dasboards.yaml b/example/observability_infrastructure/provisioning/dashboards/dasboards.yaml new file mode 100644 index 0000000..194e288 --- /dev/null +++ b/example/observability_infrastructure/provisioning/dashboards/dasboards.yaml @@ -0,0 +1,10 @@ +apiVersion: 1 +providers: + - name: 'default' + orgId: 1 + folder: '' + type: file + disableDeletion: false + editable: true + options: + path: /etc/grafana/provisioning/dashboards \ No newline at end of file diff --git a/example/observability_infrastructure/provisioning/dashboards/example_grafana_dashboard.json b/example/observability_infrastructure/provisioning/dashboards/example_grafana_dashboard.json new file mode 100644 index 0000000..bcaa142 --- /dev/null +++ b/example/observability_infrastructure/provisioning/dashboards/example_grafana_dashboard.json @@ -0,0 +1,1422 @@ +{ + "annotations": { + "list": [ + { + "$$hashKey": "object:10", + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 1, + "id": 10, + "iteration": 1678226744476, + "links": [], + "liveNow": false, + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 58, + "panels": [], + "title": "Custom Trends and Checks", + "type": "row" + }, + { + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "points", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 1 + }, + "id": 39, + "options": { + "legend": { + "calcs": [ + "mean", + "min", + "max" + ], + "displayMode": "table", + "placement": "right" + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.4.4", + "targets": [ + { + "alias": " $tag_name", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "query": "SELECT DISTINCT \"response_time\"\nFROM \"locust_requests\"\nWHERE $timeFilter and \"request_type\"='CUSTOM'\nGROUP BY \"name\"", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series" + } + ], + "title": "Custom Trends", + "type": "timeseries" + }, + { + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "orange", + "value": 0.5 + }, + { + "color": "green", + "value": 0.95 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 7, + "x": 0, + "y": 9 + }, + "id": 59, + "options": { + "displayMode": "basic", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "text": {} + }, + "pluginVersion": "8.4.4", + "targets": [ + { + "alias": "$tag_check_name", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "query": "SELECT mean(\"check_passed\") FROM \"locust_checks\" WHERE $timeFilter GROUP BY \"check_name\"\n", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series" + } + ], + "title": "Check success rates", + "type": "bargauge" + }, + { + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "transparent", + "mode": "fixed" + }, + "mappings": [ + { + "options": { + "No data": { + "index": 0, + "text": "0" + } + }, + "type": "value" + } + ], + "min": 0, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "purple", + "value": null + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 5, + "x": 7, + "y": 9 + }, + "id": 61, + "options": { + "colorMode": "none", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "8.4.4", + "targets": [ + { + "alias": "$tag_check_name", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "query": "SELECT count(\"check_passed\") FROM \"locust_checks\" WHERE \"check_passed\" = 1 and $timeFilter GROUP BY \"check_name\"\n", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series" + } + ], + "title": "Checks Passed | Total Count", + "type": "stat" + }, + { + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "red", + "mode": "fixed" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "points", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 0.95 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 12, + "x": 12, + "y": 9 + }, + "id": 60, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.4.4", + "targets": [ + { + "alias": "FAILED: $tag_check_name", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "query": "SELECT count(\"check_passed\") FROM \"locust_checks\" WHERE (check_passed = 0) and $timeFilter GROUP BY time($__interval), \"check_name\"\n", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series" + } + ], + "title": "Check failures over time", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 56, + "panels": [], + "title": "HTTP requests", + "type": "row" + }, + { + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "points", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 0, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 2, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 15, + "w": 18, + "x": 0, + "y": 21 + }, + "id": 43, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "alias": "$tag_name", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "query": "SELECT DISTINCT \"response_time\"\nFROM \"locust_requests\"\nWHERE $timeFilter AND (\"success\"='True') AND (\"request_type\"!='custom') AND (\"request_type\"!='CUSTOM')\nGROUP BY time(1ms), \"name\"", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series" + } + ], + "title": "Request Response Times (ms)", + "type": "timeseries" + }, + { + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "color": "green", + "index": 0, + "text": "0" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 18, + "y": 21 + }, + "id": 64, + "options": { + "colorMode": "none", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "8.4.4", + "targets": [ + { + "alias": "$tag_exception", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "query": "SELECT count(\"response_time\") FROM \"locust_requests\" WHERE $timeFilter\n", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series" + } + ], + "title": "Total HTTP Requests", + "type": "stat" + }, + { + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "color": "green", + "index": 0, + "text": "0" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "dark-red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 18, + "y": 25 + }, + "id": 63, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "8.4.4", + "targets": [ + { + "alias": "$tag_exception", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "query": "SELECT count(\"response_time\") FROM \"locust_requests\" WHERE $timeFilter and \"code\"=~/[45]\\d\\d/\n", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series" + } + ], + "title": "HTTP Errors", + "type": "stat" + }, + { + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 2, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 36 + }, + "id": 68, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "alias": "user count", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "query": "SELECT \"user_count\"\nFROM \"locust_requests\"\nWHERE $timeFilter", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series" + } + ], + "title": "Number of users", + "type": "timeseries" + }, + { + "datasource": { + "type": "influxdb", + "uid": "$DB_SOURCE" + }, + "description": "Requests Per Second over time", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 46 + }, + "id": 26, + "links": [], + "options": { + "legend": { + "calcs": [ + "mean" + ], + "displayMode": "table", + "placement": "right" + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "8.4.4", + "targets": [ + { + "alias": "RPS", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT c\nFROM (\nSELECT count(response_time) as c \nFROM \"locust_requests\"\nWHERE $timeFilter\nGROUP BY time(1s))", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "title": "RPS (Requests per Second)", + "transformations": [], + "type": "timeseries" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "influxdb", + "uid": "$DB_SOURCE" + }, + "description": "Number of requests per second over time.", + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 46 + }, + "hiddenSeries": false, + "id": 25, + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideEmpty": true, + "hideZero": true, + "max": false, + "min": false, + "rightSide": true, + "show": false, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.4.4", + "pointradius": 2, + "points": true, + "renderer": "flot", + "seriesOverrides": [ + { + "$$hashKey": "object:65" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_name", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT count(\"response_time\")\nFROM \"locust_requests\"\nWHERE $timeFilter and \"code\"=~/[45]\\d\\d/\nGROUP BY time($__interval), \"name\", \"code\"", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeRegions": [], + "title": "HTTP errors over time", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "transformations": [], + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:4502", + "decimals": 0, + "format": "none", + "label": "", + "logBase": 1, + "min": "1", + "show": true + }, + { + "$$hashKey": "object:4503", + "format": "short", + "logBase": 1, + "min": "0", + "show": false + } + ], + "yaxis": { + "align": false + } + }, + { + "columns": [], + "datasource": { + "type": "influxdb", + "uid": "$DB_SOURCE" + }, + "fontSize": "100%", + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 54 + }, + "id": 29, + "pageSize": 10, + "scroll": true, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Error", + "align": "auto", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "Metric", + "preserveFormat": false, + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Total", + "align": "auto", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value", + "thresholds": [], + "type": "number", + "unit": "none" + } + ], + "targets": [ + { + "alias": "$tag_request_type $tag_name: $tag_exception", + "datasource": { + "type": "influxdb", + "uid": "uzwl2Msnk" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT count(\"counter\")\nFROM \"locust_requests\"\nWHERE $timeFilter and \"code\"=~/[45]\\d\\d/\nGROUP BY \"request_type\", \"name\", \"exception\"\nLIMIT 200", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "title": "Request Errors", + "transform": "timeseries_to_rows", + "type": "table-old" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 63 + }, + "id": 54, + "panels": [], + "title": "Locust events and errors", + "type": "row" + }, + { + "columns": [], + "datasource": { + "uid": "$DB_SOURCE" + }, + "description": "Hatching Events", + "fontSize": "100%", + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 64 + }, + "id": 24, + "interval": "", + "pageSize": 10, + "scroll": true, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "", + "align": "auto", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "Time", + "thresholds": [], + "type": "date", + "unit": "short" + }, + { + "alias": "Event", + "align": "auto", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "locust_events.event", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Node ID", + "align": "auto", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "locust_events.node_id", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "User Count", + "align": "auto", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "locust_events.user_count", + "thresholds": [], + "type": "number", + "unit": "short" + } + ], + "targets": [ + { + "alias": "", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT \"time\", \"event\", \"node_id\", \"user_count\"\nFROM \"locust_events\" \nWHERE $timeFilter\nAND event <> 'papaya'", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "title": "Hatching Events", + "transform": "timeseries_to_columns", + "type": "table-old" + }, + { + "columns": [], + "datasource": { + "uid": "$DB_SOURCE" + }, + "fontSize": "100%", + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 72 + }, + "id": 22, + "pageSize": 10, + "scroll": true, + "showHeader": true, + "sort": { + "col": 2, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "align": "auto", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Error", + "align": "auto", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "link": false, + "pattern": "exception_tag", + "preserveFormat": true, + "sanitize": true, + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Total", + "align": "auto", + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "count", + "thresholds": [], + "type": "number", + "unit": "none" + } + ], + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT count(\"exception\")\nFROM \"locust_exceptions\" \nWHERE $timeFilter\nGROUP BY \"exception_tag\"", + "rawQuery": true, + "refId": "A", + "resultFormat": "table", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "title": "Locust Errors", + "transform": "table", + "type": "table-old" + } + ], + "refresh": "", + "schemaVersion": 35, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "InfluxDB locust", + "value": "InfluxDB locust" + }, + "hide": 1, + "includeAll": false, + "label": "DB_SOURCE", + "multi": false, + "name": "DB_SOURCE", + "options": [], + "query": "influxdb", + "queryValue": "", + "refresh": 1, + "regex": "/.*locust*/", + "skipUrlSync": false, + "type": "datasource" + } + ] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "2s", + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "browser", + "title": "Grasshopper | Example Dashboard", + "uid": "9u1ewkaVz", + "version": 3, + "weekStart": "" +} \ No newline at end of file diff --git a/example/observability_infrastructure/provisioning/datasources/datasources.yaml b/example/observability_infrastructure/provisioning/datasources/datasources.yaml new file mode 100644 index 0000000..3b86031 --- /dev/null +++ b/example/observability_infrastructure/provisioning/datasources/datasources.yaml @@ -0,0 +1,8 @@ +apiVersion: 1 +datasources: + - name: influxdb + type: influxdb + access: proxy + url: http://localhost:8086 + database: locust + isDefault: true \ No newline at end of file diff --git a/src/grasshopper/lib/grasshopper.py b/src/grasshopper/lib/grasshopper.py index 4542b49..7052680 100644 --- a/src/grasshopper/lib/grasshopper.py +++ b/src/grasshopper/lib/grasshopper.py @@ -6,8 +6,9 @@ """ import logging import os -import resource import signal +if os.name == "posix": + import resource # pylint: disable=import-error from typing import Dict, List, Optional, Type, Union import gevent @@ -198,22 +199,23 @@ def load_shape(shape_name: str, **kwargs) -> LoadTestShape: def set_ulimit(): """Increase the maximum number of open files allowed.""" # Adapted from locust source code, main function in locust.main. - try: - minimum_open_file_limit = 10000 - current_open_file_limit = resource.getrlimit(resource.RLIMIT_NOFILE)[0] - if current_open_file_limit < minimum_open_file_limit: - # Increasing the limit to 10000 within a running process - # should work on at least MacOS. It does not work on all OS:es, - # but we should be no worse off for trying. - resource.setrlimit( - resource.RLIMIT_NOFILE, - [minimum_open_file_limit, resource.RLIM_INFINITY], + if os.name == "posix": + try: + minimum_open_file_limit = 10000 + current_open_file_limit = resource.getrlimit(resource.RLIMIT_NOFILE)[0] + if current_open_file_limit < minimum_open_file_limit: + # Increasing the limit to 10000 within a running process + # should work on at least MacOS. It does not work on all OS:es, + # but we should be no worse off for trying. + resource.setrlimit( + resource.RLIMIT_NOFILE, + [minimum_open_file_limit, resource.RLIM_INFINITY], + ) + except BaseException: + logger.warning( + f"""System open file limit '{current_open_file_limit}' is below minimum + setting '{minimum_open_file_limit}'. It's not high enough for load + testing, and the OS didn't allow locust to increase it by itself. See + https://github.com/locustio/locust/wiki/Installation#increasing-maximum-number-of-open-files-limit + for more info.""" ) - except BaseException: - logger.warning( - f"""System open file limit '{current_open_file_limit}' is below minimum - setting '{minimum_open_file_limit}'. It's not high enough for load - testing, and the OS didn't allow locust to increase it by itself. See - https://github.com/locustio/locust/wiki/Installation#increasing-maximum-number-of-open-files-limit - for more info.""" - )