diff --git a/deployment/grafana-dashboards/Hive-Vitals.json b/deployment/grafana-dashboards/Hive-Vitals.json index b4b62f132..e202cdedf 100644 --- a/deployment/grafana-dashboards/Hive-Vitals.json +++ b/deployment/grafana-dashboards/Hive-Vitals.json @@ -3637,9 +3637,229 @@ { "collapsed": false, "datasource": { - "type": "datasource", - "uid": "grafana" + "type": "prometheus", + "uid": "grafanacloud-prom" }, + "description": "Handler - the async function that runs after the request is parsed\n\nRequest - from receiving to responding", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "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": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 143 + }, + "id": 79, + "options": { + "legend": { + "calcs": ["mean", "min", "max"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "grafanacloud-prom" + }, + "editorMode": "code", + "expr": "histogram_quantile(0.999, sum(rate(usage_http_request_duration_seconds_bucket[$__rate_interval])) by (le, pod))", + "hide": false, + "legendFormat": "Request - {{pod}}", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "grafanacloud-prom" + }, + "editorMode": "code", + "expr": "histogram_quantile(0.999, sum(rate(usage_http_request_handler_duration_seconds_bucket[$__rate_interval])) by (le, pod))", + "hide": false, + "instant": false, + "legendFormat": "Handler - {{pod}}", + "range": true, + "refId": "A" + } + ], + "title": "HTTP Request and handler duration per pod", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "grafanacloud-prom" + }, + "description": "Handler - the async function that runs after the request is parsed\n\nRequest - from receiving to responding", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "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": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 143 + }, + "id": 80, + "options": { + "legend": { + "calcs": ["mean", "min", "max"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "11.5.0-80683", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "grafanacloud-prom" + }, + "editorMode": "code", + "expr": "histogram_quantile(0.999, sum(rate(usage_http_request_duration_seconds_bucket[$__rate_interval])) by (le))", + "hide": false, + "legendFormat": "Request", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "grafanacloud-prom" + }, + "editorMode": "code", + "expr": "histogram_quantile(0.999, sum(rate(usage_http_request_handler_duration_seconds_bucket[$__rate_interval])) by (le))", + "hide": false, + "instant": false, + "legendFormat": "Handler", + "range": true, + "refId": "A" + } + ], + "title": "HTTP Request and handler duration", + "type": "timeseries" + }, + { "gridPos": { "h": 1, "w": 24, diff --git a/packages/services/usage/src/metrics.ts b/packages/services/usage/src/metrics.ts index 57d51bcfa..8255d5fd9 100644 --- a/packages/services/usage/src/metrics.ts +++ b/packages/services/usage/src/metrics.ts @@ -9,12 +9,14 @@ export const tokensDuration = new metrics.Histogram({ name: 'usage_tokens_duration_seconds', help: 'Duration of an HTTP Request to Tokens service in seconds', labelNames: ['status'], + buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 3, 4, 5, 7, 10], }); export const rateLimitDuration = new metrics.Histogram({ name: 'usage_rate_limit_duration_seconds', help: 'Duration of an HTTP Request to Rate Limit service in seconds', labelNames: ['type'], + buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 3, 4, 5, 7, 10], }); export const httpRequests = new metrics.Counter({ @@ -25,11 +27,13 @@ export const httpRequests = new metrics.Counter({ export const httpRequestDuration = new metrics.Histogram({ name: 'usage_http_request_duration_seconds', help: 'Duration of an HTTP Request in seconds', + buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 3, 4, 5, 7, 10], }); export const httpRequestHandlerDuration = new metrics.Histogram({ name: 'usage_http_request_handler_duration_seconds', help: 'Duration of an HTTP Request handler in seconds', + buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 3, 4, 5, 7, 10], }); export const httpRequestsWithoutToken = new metrics.Counter({