diff --git a/packages/common/src/controllers/prometheus.controller.ts b/packages/common/src/controllers/prometheus.controller.ts index b9af2e1..39401a5 100644 --- a/packages/common/src/controllers/prometheus.controller.ts +++ b/packages/common/src/controllers/prometheus.controller.ts @@ -1,11 +1,12 @@ import { Controller, Get, Res } from '@nestjs/common'; import { FastifyReply } from 'fastify'; import { register } from 'prom-client'; + @Controller() export class PrometheusController { @Get('metrics') async metrics(@Res() response: FastifyReply) { - response.headers({ 'Content-Type': register.contentType }); + response.header('Content-Type', register.contentType); response.send(await register.metrics()); } } diff --git a/packages/common/src/interceptors/response-time.interceptor.ts b/packages/common/src/interceptors/response-time.interceptor.ts index 1aeeb4d..131bc33 100644 --- a/packages/common/src/interceptors/response-time.interceptor.ts +++ b/packages/common/src/interceptors/response-time.interceptor.ts @@ -1,45 +1,65 @@ -import { - Injectable, - NestInterceptor, - ExecutionContext, - CallHandler, - Logger, -} from '@nestjs/common'; +import { Injectable, NestInterceptor, ExecutionContext, CallHandler, Logger } from '@nestjs/common'; import { Observable, throwError } from 'rxjs'; import { catchError, tap } from 'rxjs/operators'; import { Histogram, exponentialBuckets } from 'prom-client'; -import * as fs from 'fs'; -import { generateBaseJSON, generateRow } from './utils'; +import axios from 'axios'; + +import { + generateBaseJSON, + generateRow, + getDashboardByUID, + getDashboardJSON, +} from './utils'; @Injectable() export class ResponseTimeInterceptor implements NestInterceptor { private histogram: Histogram; private logger: Logger; + private dashboardUid: string; + private grafanaBaseURL: string; + private apiToken: string; - constructor(histogramTitle: string, jsonPath: string) { + constructor( + histogramTitle: string, + grafanaBaseURL: string, + apiToken: string, + ) { const name = histogramTitle + '_response_time'; this.logger = new Logger(name + '_interceptor'); + this.dashboardUid = null; + this.grafanaBaseURL = grafanaBaseURL; + this.apiToken = apiToken; + this.init(histogramTitle, grafanaBaseURL); + } + async init(histogramTitle: string, grafanaBaseURL: string) { + const name = histogramTitle + '_response_time'; this.histogram = new Histogram({ name: name, help: 'Response time of APIs', buckets: exponentialBuckets(1, 1.5, 30), labelNames: ['statusCode', 'endpoint'], }); - - // updating the grafana JSON with the row for this panel + console.log("apiToken", this.apiToken); + console.log("grafanaBaseURL", grafanaBaseURL); try { - // check if the path exists or not? - if (!fs.existsSync(jsonPath)) { - fs.writeFileSync(jsonPath, JSON.stringify(generateBaseJSON()), 'utf8'); // create file if not exists - } + const dashboardJSONSearchResp = await getDashboardJSON( + this.apiToken, + histogramTitle, + grafanaBaseURL, + ); + this.dashboardUid = + dashboardJSONSearchResp.length > 0 + ? dashboardJSONSearchResp[0]['uid'] + : undefined; + let parsedContent: any; - const parsedContent = JSON.parse(fs.readFileSync(jsonPath, 'utf8')); + if (this.dashboardUid === null || !this.dashboardUid) { + parsedContent = generateBaseJSON(histogramTitle); + + let isPresent = false; - // skip creating the row if it already exists -- prevents multiple panels/rows on app restarts - let isPresent = false; - parsedContent.panels.forEach((panel: any) => { - // TODO: Make this verbose and add types -- convert the grafana JSON to TS Types/interface + parsedContent.dashboard.panels.forEach((panel: any) => { if ( panel.title.trim() === name @@ -52,13 +72,43 @@ export class ResponseTimeInterceptor implements NestInterceptor { } }); if (isPresent) return; + parsedContent.dashboard.panels.push(generateRow(name)); + } else { + parsedContent = await getDashboardByUID(this.dashboardUid, grafanaBaseURL, this.apiToken); + + + let isPresent = false; + parsedContent.panels.forEach((panel: any) => { + if ( + panel.title.trim() === + name + .split('_') + .map((str) => str.charAt(0).toUpperCase() + str.slice(1)) + .join(' ') + .trim() + ) { + isPresent = true; + } + }); + if (isPresent) return; + + parsedContent.panels.push(generateRow(name)); + } + - parsedContent.panels.push(generateRow(name)); - // write back to file - fs.writeFileSync(jsonPath, JSON.stringify(parsedContent)); + + const FINAL_JSON = parsedContent; + await axios.post(`${grafanaBaseURL}/api/dashboards/db`, FINAL_JSON, { + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${this.apiToken}` + } + }); + this.logger.log('Successfully added histogram to dashboard!'); } catch (err) { - this.logger.error('Error updating grafana JSON!', err); + console.error('Error updating grafana JSON!', err); } } @@ -70,7 +120,6 @@ export class ResponseTimeInterceptor implements NestInterceptor { const startTime = performance.now(); return next.handle().pipe( tap(() => { - // handles when there is no error propagating from the services to the controller const endTime = performance.now(); const responseTime = endTime - startTime; const statusCode = response.statusCode; @@ -78,14 +127,10 @@ export class ResponseTimeInterceptor implements NestInterceptor { this.histogram.labels({ statusCode, endpoint }).observe(responseTime); }), catchError((err) => { - // handles when an exception is to be returned to the client - this.logger.error('error: ', err); const endTime = performance.now(); const responseTime = endTime - startTime; const endpoint = request.url; - this.histogram - .labels({ statusCode: err.status, endpoint }) - .observe(responseTime); + this.histogram.labels({ statusCode: err.status, endpoint }).observe(responseTime); return throwError(() => { throw err; }); @@ -93,3 +138,6 @@ export class ResponseTimeInterceptor implements NestInterceptor { ); } } + + + diff --git a/packages/common/src/interceptors/utils.ts b/packages/common/src/interceptors/utils.ts index ac9af71..d5ab617 100644 --- a/packages/common/src/interceptors/utils.ts +++ b/packages/common/src/interceptors/utils.ts @@ -1,54 +1,90 @@ -export const generateBaseJSON = () => { +import axios from 'axios'; + +export const generateBaseJSON = (histogramTitle) => { return { - annotations: { - list: [ - { - builtIn: 1, - datasource: { - type: 'grafana', - uid: '-- Grafana --', - }, - enable: true, - hide: true, - iconColor: 'rgba(0, 211, 255, 1)', - name: 'Annotations & Alerts', - type: 'dashboard', + meta: { + type: "db", + canSave: true, + canEdit: true, + canAdmin: true, + canStar: true, + canDelete: true, + slug: histogramTitle, + url: `/d/ec1b884b/${histogramTitle}`, + expires: "0001-01-01T00:00:00Z", + created: "2024-07-03T04:01:29Z", + updated: "2024-07-03T04:01:29Z", + updatedBy: "admin", + createdBy: "admin", + version: 1, + hasAcl: false, + isFolder: false, + folderId: 0, + folderUid: "", + folderTitle: "General", + folderUrl: "", + provisioned: false, + provisionedExternalId: "", + annotationsPermissions: { + dashboard: { + canAdd: true, + canEdit: true, + canDelete: true, }, - ], - }, - description: 'Dashboard for API response time visualisations\n', - editable: true, - fiscalYearStartMonth: 0, - graphTooltip: 0, - id: 5, - links: [], - liveNow: false, - panels: [], - refresh: '', - schemaVersion: 38, - tags: [], - templating: { - list: [], + organization: { + canAdd: true, + canEdit: true, + canDelete: true, + }, + }, }, - time: { - from: 'now-6h', - to: 'now', + dashboard: { + annotations: { + list: [ + { + builtIn: 1, + datasource: { + type: 'grafana', + uid: '-- Grafana --', + }, + enable: true, + hide: true, + iconColor: 'rgba(0, 211, 255, 1)', + name: 'Annotations & Alerts', + type: 'dashboard', + }, + ], + }, + description: 'Dashboard for API response time visualisations\n', + editable: true, + fiscalYearStartMonth: 0, + graphTooltip: 0, + id: null, + links: [], + liveNow: false, + panels: [], + refresh: '', + schemaVersion: 38, + tags: [], + templating: { + list: [], + }, + time: { + from: 'now-6h', + to: 'now', + }, + timepicker: {}, + timezone: '', + title: histogramTitle, + uid: null, + version: 1, + weekStart: '', }, - timepicker: {}, - timezone: '', - title: 'Response Times', - uid: 'ec1b884b-753e-405f-8f4b-e0a5d97cf167', - version: 6, - weekStart: '', }; }; + export const generateRow = (name: string) => { - const textPanel = generateTextPanel( - name, - // `# ${name} Response Time Information\n`, - name, - ); const gauagePanel = generateGaugePanel(name); const heatmap = generateHeatmap(name); const successfulUnsuccessful = generateSuccessfulUnSuccessfulPanel(name); @@ -570,3 +606,46 @@ export const generateAverageResponseTimePanel = (label: string) => { type: 'timeseries', }; }; + + + + + +export const getDashboardByUID = async ( + uid: string, + grafanaBaseURL: string, + apiToken : string +) => { + try { + const resp = await axios.get(grafanaBaseURL + `/api/dashboards/uid/${uid}`, { + headers: { + 'Authorization': `Bearer ${apiToken}` + } + }); + return resp.data.dashboard; + } catch (err) { + console.error('error getting dashboard by uid: ', err); + } + return ; +}; + +export const getDashboardJSON = async ( + token: string, + dashboardTitle: string, + grafanaBaseURL: string, +) => { + try { + const resp: any = await axios.get(grafanaBaseURL + '/api/search', { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + return (resp.data as any[]).filter((item) => { + return item.title && item.title === dashboardTitle; + }); + } catch (err) { + console.error('Error searching dashboards: ', err); + } + return; +}; + diff --git a/packages/nestjs-monitor/monitor/grafana/provisioning/dashboards/response_times.json b/packages/nestjs-monitor/monitor/grafana/provisioning/dashboards/response_times.json deleted file mode 100644 index 1162d78..0000000 --- a/packages/nestjs-monitor/monitor/grafana/provisioning/dashboards/response_times.json +++ /dev/null @@ -1 +0,0 @@ -{"annotations":{"list":[{"builtIn":1,"datasource":{"type":"grafana","uid":"-- Grafana --"},"enable":true,"hide":true,"iconColor":"rgba(0, 211, 255, 1)","name":"Annotations & Alerts","type":"dashboard"}]},"description":"Dashboard for API response time visualisations\n","editable":true,"fiscalYearStartMonth":0,"graphTooltip":0,"id":5,"links":[],"liveNow":false,"panels":[{"collapsed":true,"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":27,"panels":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":1},"id":25,"options":{"minVizHeight":75,"minVizWidth":75,"orientation":"auto","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showThresholdLabels":false,"showThresholdMarkers":true},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum (class_response_time_count) by (endpoint)","instant":false,"legendFormat":"__auto","range":true,"refId":"A"}],"title":"Total Requests by endpoint","type":"gauge"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"custom":{"hideFrom":{"legend":false,"tooltip":false,"viz":false},"scaleDistribution":{"type":"linear"}}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":1},"id":21,"options":{"calculate":false,"cellGap":1,"color":{"exponent":0.5,"fill":"dark-orange","mode":"scheme","reverse":false,"scale":"exponential","scheme":"Spectral","steps":64},"exemplars":{"color":"rgba(255,0,255,0.7)"},"filterValues":{"le":1e-9},"legend":{"show":true},"rowsFrame":{"layout":"auto"},"tooltip":{"show":true,"yHistogram":false},"yAxis":{"axisPlacement":"left","reverse":false,"unit":"s"}},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (le) (rate(class_response_time_bucket[30s]))","format":"heatmap","instant":false,"legendFormat":"{{le}}","range":true,"refId":"A"}],"title":"Response Time Heatmap","type":"heatmap"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":9},"id":24,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (statusCode) (rate(class_response_time_count{statusCode=~\"2..\"}[1h]))\n","instant":false,"legendFormat":"Successful","range":true,"refId":"A"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","exemplar":false,"expr":"sum by (statusCode) (\n rate(class_response_time_count{statusCode=~\"4..\"}[1h])\n) + ignoring(statusCode) group_left sum by (statusCode) (\n rate(class_response_time_count{statusCode=~\"5..\"}[1h])\n)","hide":false,"instant":false,"legendFormat":"Unsuccessful","range":true,"refId":"B"}],"title":"# Unsuccessful and Successful requests","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":10},"id":22,"unit":"s","options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (statusCode)(class_response_time_count)","format":"time_series","hide":false,"instant":false,"legendFormat":"{{statusCode}}","range":true,"refId":"B"}],"title":"# requests by status codes","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]},"unit":"s"},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":18},"id":23,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum(rate(class_response_time_sum[30s]))/sum(rate(class_response_time_count[30s]))","instant":false,"legendFormat":"average response time","range":true,"refId":"A"}],"title":"Average request response time","type":"timeseries"}],"title":"Class Response Time","type":"row"},{"collapsed":true,"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":27,"panels":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":1},"id":25,"options":{"minVizHeight":75,"minVizWidth":75,"orientation":"auto","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showThresholdLabels":false,"showThresholdMarkers":true},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum (monitoring_response_time_count) by (endpoint)","instant":false,"legendFormat":"__auto","range":true,"refId":"A"}],"title":"Total Requests by endpoint","type":"gauge"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"custom":{"hideFrom":{"legend":false,"tooltip":false,"viz":false},"scaleDistribution":{"type":"linear"}}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":1},"id":21,"options":{"calculate":false,"cellGap":1,"color":{"exponent":0.5,"fill":"dark-orange","mode":"scheme","reverse":false,"scale":"exponential","scheme":"Spectral","steps":64},"exemplars":{"color":"rgba(255,0,255,0.7)"},"filterValues":{"le":1e-9},"legend":{"show":true},"rowsFrame":{"layout":"auto"},"tooltip":{"show":true,"yHistogram":false},"yAxis":{"axisPlacement":"left","reverse":false,"unit":"s"}},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (le) (rate(monitoring_response_time_bucket[30s]))","format":"heatmap","instant":false,"legendFormat":"{{le}}","range":true,"refId":"A"}],"title":"Response Time Heatmap","type":"heatmap"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":9},"id":24,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (statusCode) (rate(monitoring_response_time_count{statusCode=~\"2..\"}[1h]))\n","instant":false,"legendFormat":"Successful","range":true,"refId":"A"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","exemplar":false,"expr":"sum by (statusCode) (\n rate(monitoring_response_time_count{statusCode=~\"4..\"}[1h])\n) + ignoring(statusCode) group_left sum by (statusCode) (\n rate(monitoring_response_time_count{statusCode=~\"5..\"}[1h])\n)","hide":false,"instant":false,"legendFormat":"Unsuccessful","range":true,"refId":"B"}],"title":"# Unsuccessful and Successful requests","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":10},"id":22,"unit":"s","options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (statusCode)(monitoring_response_time_count)","format":"time_series","hide":false,"instant":false,"legendFormat":"{{statusCode}}","range":true,"refId":"B"}],"title":"# requests by status codes","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]},"unit":"s"},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":18},"id":23,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum(rate(monitoring_response_time_sum[30s]))/sum(rate(monitoring_response_time_count[30s]))","instant":false,"legendFormat":"average response time","range":true,"refId":"A"}],"title":"Average request response time","type":"timeseries"}],"title":"Monitoring Response Time","type":"row"},{"collapsed":true,"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":27,"panels":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":1},"id":25,"options":{"minVizHeight":75,"minVizWidth":75,"orientation":"auto","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showThresholdLabels":false,"showThresholdMarkers":true},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum (random_response_time_count) by (endpoint)","instant":false,"legendFormat":"__auto","range":true,"refId":"A"}],"title":"Total Requests by endpoint","type":"gauge"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"custom":{"hideFrom":{"legend":false,"tooltip":false,"viz":false},"scaleDistribution":{"type":"linear"}}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":1},"id":21,"options":{"calculate":false,"cellGap":1,"color":{"exponent":0.5,"fill":"dark-orange","mode":"scheme","reverse":false,"scale":"exponential","scheme":"Spectral","steps":64},"exemplars":{"color":"rgba(255,0,255,0.7)"},"filterValues":{"le":1e-9},"legend":{"show":true},"rowsFrame":{"layout":"auto"},"tooltip":{"show":true,"yHistogram":false},"yAxis":{"axisPlacement":"left","reverse":false,"unit":"s"}},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (le) (rate(random_response_time_bucket[30s]))","format":"heatmap","instant":false,"legendFormat":"{{le}}","range":true,"refId":"A"}],"title":"Response Time Heatmap","type":"heatmap"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":9},"id":24,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (statusCode) (rate(random_response_time_count{statusCode=~\"2..\"}[1h]))\n","instant":false,"legendFormat":"Successful","range":true,"refId":"A"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","exemplar":false,"expr":"sum by (statusCode) (\n rate(random_response_time_count{statusCode=~\"4..\"}[1h])\n) + ignoring(statusCode) group_left sum by (statusCode) (\n rate(random_response_time_count{statusCode=~\"5..\"}[1h])\n)","hide":false,"instant":false,"legendFormat":"Unsuccessful","range":true,"refId":"B"}],"title":"# Unsuccessful and Successful requests","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":10},"id":22,"unit":"s","options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (statusCode)(random_response_time_count)","format":"time_series","hide":false,"instant":false,"legendFormat":"{{statusCode}}","range":true,"refId":"B"}],"title":"# requests by status codes","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]},"unit":"s"},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":18},"id":23,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum(rate(random_response_time_sum[30s]))/sum(rate(random_response_time_count[30s]))","instant":false,"legendFormat":"average response time","range":true,"refId":"A"}],"title":"Average request response time","type":"timeseries"}],"title":"Random Response Time","type":"row"},{"collapsed":true,"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":27,"panels":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":1},"id":25,"options":{"minVizHeight":75,"minVizWidth":75,"orientation":"auto","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showThresholdLabels":false,"showThresholdMarkers":true},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum (test_response_time_count) by (endpoint)","instant":false,"legendFormat":"__auto","range":true,"refId":"A"}],"title":"Total Requests by endpoint","type":"gauge"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"custom":{"hideFrom":{"legend":false,"tooltip":false,"viz":false},"scaleDistribution":{"type":"linear"}}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":1},"id":21,"options":{"calculate":false,"cellGap":1,"color":{"exponent":0.5,"fill":"dark-orange","mode":"scheme","reverse":false,"scale":"exponential","scheme":"Spectral","steps":64},"exemplars":{"color":"rgba(255,0,255,0.7)"},"filterValues":{"le":1e-9},"legend":{"show":true},"rowsFrame":{"layout":"auto"},"tooltip":{"show":true,"yHistogram":false},"yAxis":{"axisPlacement":"left","reverse":false,"unit":"s"}},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (le) (rate(test_response_time_bucket[30s]))","format":"heatmap","instant":false,"legendFormat":"{{le}}","range":true,"refId":"A"}],"title":"Response Time Heatmap","type":"heatmap"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":9},"id":24,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (statusCode) (rate(test_response_time_count{statusCode=~\"2..\"}[1h]))\n","instant":false,"legendFormat":"Successful","range":true,"refId":"A"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","exemplar":false,"expr":"sum by (statusCode) (\n rate(test_response_time_count{statusCode=~\"4..\"}[1h])\n) + ignoring(statusCode) group_left sum by (statusCode) (\n rate(test_response_time_count{statusCode=~\"5..\"}[1h])\n)","hide":false,"instant":false,"legendFormat":"Unsuccessful","range":true,"refId":"B"}],"title":"# Unsuccessful and Successful requests","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":10},"id":22,"unit":"s","options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (statusCode)(test_response_time_count)","format":"time_series","hide":false,"instant":false,"legendFormat":"{{statusCode}}","range":true,"refId":"B"}],"title":"# requests by status codes","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]},"unit":"s"},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":18},"id":23,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum(rate(test_response_time_sum[30s]))/sum(rate(test_response_time_count[30s]))","instant":false,"legendFormat":"average response time","range":true,"refId":"A"}],"title":"Average request response time","type":"timeseries"}],"title":"Test Response Time","type":"row"},{"collapsed":true,"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":27,"panels":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"thresholds"},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":1},"id":25,"options":{"minVizHeight":75,"minVizWidth":75,"orientation":"auto","reduceOptions":{"calcs":["lastNotNull"],"fields":"","values":false},"showThresholdLabels":false,"showThresholdMarkers":true},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum (global_interceptor_response_time_count) by (endpoint)","instant":false,"legendFormat":"__auto","range":true,"refId":"A"}],"title":"Total Requests by endpoint","type":"gauge"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"custom":{"hideFrom":{"legend":false,"tooltip":false,"viz":false},"scaleDistribution":{"type":"linear"}}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":1},"id":21,"options":{"calculate":false,"cellGap":1,"color":{"exponent":0.5,"fill":"dark-orange","mode":"scheme","reverse":false,"scale":"exponential","scheme":"Spectral","steps":64},"exemplars":{"color":"rgba(255,0,255,0.7)"},"filterValues":{"le":1e-9},"legend":{"show":true},"rowsFrame":{"layout":"auto"},"tooltip":{"show":true,"yHistogram":false},"yAxis":{"axisPlacement":"left","reverse":false,"unit":"s"}},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (le) (rate(global_interceptor_response_time_bucket[30s]))","format":"heatmap","instant":false,"legendFormat":"{{le}}","range":true,"refId":"A"}],"title":"Response Time Heatmap","type":"heatmap"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":9},"id":24,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (statusCode) (rate(global_interceptor_response_time_count{statusCode=~\"2..\"}[1h]))\n","instant":false,"legendFormat":"Successful","range":true,"refId":"A"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","exemplar":false,"expr":"sum by (statusCode) (\n rate(global_interceptor_response_time_count{statusCode=~\"4..\"}[1h])\n) + ignoring(statusCode) group_left sum by (statusCode) (\n rate(global_interceptor_response_time_count{statusCode=~\"5..\"}[1h])\n)","hide":false,"instant":false,"legendFormat":"Unsuccessful","range":true,"refId":"B"}],"title":"# Unsuccessful and Successful requests","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":12,"y":10},"id":22,"unit":"s","options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum by (statusCode)(global_interceptor_response_time_count)","format":"time_series","hide":false,"instant":false,"legendFormat":"{{statusCode}}","range":true,"refId":"B"}],"title":"# requests by status codes","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]},"unit":"s"},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":18},"id":23,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"pluginVersion":"10.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"code","expr":"sum(rate(global_interceptor_response_time_sum[30s]))/sum(rate(global_interceptor_response_time_count[30s]))","instant":false,"legendFormat":"average response time","range":true,"refId":"A"}],"title":"Average request response time","type":"timeseries"}],"title":"Global Interceptor Response Time","type":"row"}],"refresh":"","schemaVersion":38,"tags":[],"templating":{"list":[]},"time":{"from":"now-6h","to":"now"},"timepicker":{},"timezone":"","title":"Response Times","uid":"ec1b884b-753e-405f-8f4b-e0a5d97cf167","version":6,"weekStart":""} \ No newline at end of file diff --git a/packages/nestjs-monitor/monitor/response_times_base.json b/packages/nestjs-monitor/monitor/response_times_base.json deleted file mode 100644 index 14b5c81..0000000 --- a/packages/nestjs-monitor/monitor/response_times_base.json +++ /dev/null @@ -1 +0,0 @@ -{"annotations":{"list":[{"builtIn":1,"datasource":{"type":"grafana","uid":"-- Grafana --"},"enable":true,"hide":true,"iconColor":"rgba(0, 211, 255, 1)","name":"Annotations & Alerts","type":"dashboard"}]},"description":"Dashboard for API response time visualisations\n","editable":true,"fiscalYearStartMonth":0,"graphTooltip":0,"id":4,"links":[],"liveNow":false,"panels":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"class_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"class_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"monitoring_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"monitoring_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"random_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"random_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"global_interceptor_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"global_interceptor_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"class_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"class_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"monitoring_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"monitoring_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"random_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"random_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"global_interceptor_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"global_interceptor_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"class_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"class_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"monitoring_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"monitoring_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"random_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"random_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"global_interceptor_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"global_interceptor_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"class_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"class_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"monitoring_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"monitoring_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"random_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"random_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"global_interceptor_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"global_interceptor_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"class_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"class_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"monitoring_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"monitoring_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"random_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"random_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"global_interceptor_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"global_interceptor_response_time Interceptor Response Times","type":"timeseries"}],"refresh":"","schemaVersion":38,"tags":[],"templating":{"list":[]},"time":{"from":"now-6h","to":"now"},"timepicker":{},"timezone":"","title":"Response Times","uid":"ec1b884b-753e-405f-8f4b-e0a5d97cf167","version":1,"weekStart":""} \ No newline at end of file diff --git a/sample/02-monitoring/env-example b/sample/02-monitoring/env-example new file mode 100644 index 0000000..cb1542a --- /dev/null +++ b/sample/02-monitoring/env-example @@ -0,0 +1,3 @@ + +GRAFANA_API_TOKEN="" #your grafana api token +GRAFANA_BASE_URL="http://localhost:7889" \ No newline at end of file diff --git a/sample/02-monitoring/monitor/response_times_base.json b/sample/02-monitoring/monitor/response_times_base.json deleted file mode 100644 index 14b5c81..0000000 --- a/sample/02-monitoring/monitor/response_times_base.json +++ /dev/null @@ -1 +0,0 @@ -{"annotations":{"list":[{"builtIn":1,"datasource":{"type":"grafana","uid":"-- Grafana --"},"enable":true,"hide":true,"iconColor":"rgba(0, 211, 255, 1)","name":"Annotations & Alerts","type":"dashboard"}]},"description":"Dashboard for API response time visualisations\n","editable":true,"fiscalYearStartMonth":0,"graphTooltip":0,"id":4,"links":[],"liveNow":false,"panels":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"class_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"class_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"monitoring_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"monitoring_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"random_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"random_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"global_interceptor_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"global_interceptor_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"class_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"class_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"monitoring_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"monitoring_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"random_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"random_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"global_interceptor_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"global_interceptor_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"class_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"class_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"monitoring_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"monitoring_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"random_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"random_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"global_interceptor_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"global_interceptor_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"class_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"class_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"monitoring_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"monitoring_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"random_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"random_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"global_interceptor_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"global_interceptor_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"class_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"class_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"monitoring_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"monitoring_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"random_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"random_response_time Interceptor Response Times","type":"timeseries"},{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"disableTextWrap":false,"editorMode":"builder","expr":"global_interceptor_response_time_bucket","fullMetaSearch":false,"includeNullMetadata":true,"instant":false,"legendFormat":"__auto","range":true,"refId":"A","useBackend":false}],"title":"global_interceptor_response_time Interceptor Response Times","type":"timeseries"}],"refresh":"","schemaVersion":38,"tags":[],"templating":{"list":[]},"time":{"from":"now-6h","to":"now"},"timepicker":{},"timezone":"","title":"Response Times","uid":"ec1b884b-753e-405f-8f4b-e0a5d97cf167","version":1,"weekStart":""} \ No newline at end of file diff --git a/sample/02-monitoring/src/app.controller.ts b/sample/02-monitoring/src/app.controller.ts index 370cb5a..39a3117 100644 --- a/sample/02-monitoring/src/app.controller.ts +++ b/sample/02-monitoring/src/app.controller.ts @@ -1,13 +1,9 @@ import { Controller, Get, UseInterceptors } from '@nestjs/common'; import { AppService } from './app.service'; -import { ResponseTimeInterceptor } from './response.interceptor'; + @Controller() @UseInterceptors( - new ResponseTimeInterceptor( - 'app_controller_interceptor', - 'http://localhost:7889', - ), ) export class AppController { constructor(private readonly appService: AppService) {} diff --git a/sample/02-monitoring/src/app.module.ts b/sample/02-monitoring/src/app.module.ts index a485da3..174ab2d 100644 --- a/sample/02-monitoring/src/app.module.ts +++ b/sample/02-monitoring/src/app.module.ts @@ -2,9 +2,10 @@ import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { PrometheusController, MonitoringModule } from '@samagra-x/stencil'; +import { ConfigModule } from '@nestjs/config'; @Module({ - imports: [MonitoringModule], + imports: [MonitoringModule,ConfigModule.forRoot()], controllers: [AppController, PrometheusController], providers: [AppService], }) diff --git a/sample/02-monitoring/src/main.ts b/sample/02-monitoring/src/main.ts index 4a815cc..67ccb76 100644 --- a/sample/02-monitoring/src/main.ts +++ b/sample/02-monitoring/src/main.ts @@ -1,16 +1,22 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; -import { ResponseTimeInterceptor } from './response.interceptor'; -// import { ResponseTimeInterceptor } from '@samagra-x/stencil'; +import { ResponseTimeInterceptor } from '@samagra-x/stencil'; +import { ConfigService } from '@nestjs/config'; async function bootstrap() { const app = await NestFactory.create(AppModule); + const configService = app.get(ConfigService); + const grafanaBaseURL = configService.get('GRAFANA_BASE_URL'); + const apiToken = configService.get('GRAFANA_API_TOKEN'); + app.useGlobalInterceptors( new ResponseTimeInterceptor( - 'test_global_interceptor', - 'http://localhost:7889', + 'Response_Times', + grafanaBaseURL, + apiToken, ), ); await app.listen(3000); } bootstrap(); + diff --git a/sample/02-monitoring/src/response.interceptor.ts b/sample/02-monitoring/src/response.interceptor.ts deleted file mode 100644 index 5823252..0000000 --- a/sample/02-monitoring/src/response.interceptor.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { - Injectable, - NestInterceptor, - ExecutionContext, - CallHandler, - Logger, -} from '@nestjs/common'; -import { Observable, throwError } from 'rxjs'; -import { catchError, tap } from 'rxjs/operators'; -import { Histogram, exponentialBuckets } from 'prom-client'; -import { - generateBaseJSON, - generateRow, - getDashboardByUID, - getDashboardJSON, - updateDashboard, -} from './utils'; - -@Injectable() -export class ResponseTimeInterceptor implements NestInterceptor { - private histogram: Histogram; - private logger: Logger; - private dashboardUid: string; - private dashboardId: string; - - constructor(histogramTitle: string, grafanaBaseURL: string) { - const name = histogramTitle + '_response_time'; - this.logger = new Logger(name + '_interceptor'); - this.dashboardUid = null; - this.init(histogramTitle, grafanaBaseURL); - } - - async init(histogramTitle: string, grafanaBaseURL: string) { - const name = histogramTitle + '_response_time'; - this.histogram = new Histogram({ - name: name, - help: 'Response time of APIs', - buckets: exponentialBuckets(1, 1.5, 30), - labelNames: ['statusCode', 'endpoint'], - }); - - // updating the grafana JSON with the row for this panel - try { - // check to see if a dashboard titled "Response Times" already exists or not - const dashboardJSONSearchResp = await getDashboardJSON( - 'glsa_81xg6BnRNIuLvTcgPgplYNvlwa0TieZS_87bbe96a', - 'Response Times', - grafanaBaseURL, - ); - console.log('dashboardJSONSearchResp: ', dashboardJSONSearchResp); - this.dashboardUid = - dashboardJSONSearchResp.length > 0 - ? dashboardJSONSearchResp[0]['uid'] - : undefined; - let parsedContent: any; - console.log('this.dashboardUid: ', this.dashboardUid); - if (this.dashboardUid === null || !this.dashboardUid) { - parsedContent = generateBaseJSON(); - // this.dashboardUid = uuidv4(); - // parsedContent['uid'] = this.dashboardUid; - } else { - parsedContent = await getDashboardByUID( - this.dashboardUid, - grafanaBaseURL, - ); - if (parsedContent === undefined) parsedContent = generateBaseJSON(); - } - // const parsedContent = JSON.parse(fs.readFileSync(jsonPath, 'utf8')); - - // skip creating the row if it already exists -- prevents multiple panels/rows on app restarts - let isPresent = false; - parsedContent.panels.forEach((panel: any) => { - // TODO: Make this verbose and add types -- convert the grafana JSON to TS Types/interface - if ( - panel.title.trim() === - name - .split('_') - .map((str) => str.charAt(0).toUpperCase() + str.slice(1)) - .join(' ') - .trim() - ) { - isPresent = true; - } - }); - if (isPresent) return; - - parsedContent.panels.push(generateRow(name)); - // write back to file - // fs.writeFileSync(jsonPath, JSON.stringify(parsedContent)); - parsedContent['uid'] = this.dashboardUid; - const createResp = await updateDashboard( - parsedContent, - 'glsa_81xg6BnRNIuLvTcgPgplYNvlwa0TieZS_87bbe96a', - grafanaBaseURL, - ); - this.dashboardUid = createResp['uid']; - this.dashboardId = createResp['id']; - console.log('createResp: ', createResp); - this.logger.log('Successfully added histogram to dashboard!'); - } catch (err) { - console.error('Error updating grafana JSON!', err); - // this.logger.error('Error updating grafana JSON!', err); - } - } - - intercept(context: ExecutionContext, next: CallHandler): Observable { - const httpContext = context.switchToHttp(); - const request = httpContext.getRequest(); - const response = httpContext.getResponse(); - - const startTime = performance.now(); - return next.handle().pipe( - tap(() => { - // handles when there is no error propagating from the services to the controller - const endTime = performance.now(); - const responseTime = endTime - startTime; - const statusCode = response.statusCode; - const endpoint = request.url; - this.histogram.labels({ statusCode, endpoint }).observe(responseTime); - }), - catchError((err) => { - // handles when an exception is to be returned to the client - this.logger.error('error: ', err); - const endTime = performance.now(); - const responseTime = endTime - startTime; - const endpoint = request.url; - this.histogram - .labels({ statusCode: err.status, endpoint }) - .observe(responseTime); - return throwError(() => { - throw err; - }); - }), - ); - } -} diff --git a/sample/02-monitoring/src/utils.ts b/sample/02-monitoring/src/utils.ts deleted file mode 100644 index 9c39dfd..0000000 --- a/sample/02-monitoring/src/utils.ts +++ /dev/null @@ -1,645 +0,0 @@ -export const generateBaseJSON = () => { - return { - annotations: { - list: [ - { - builtIn: 1, - datasource: { - type: 'grafana', - uid: '-- Grafana --', - }, - enable: true, - hide: true, - iconColor: 'rgba(0, 211, 255, 1)', - name: 'Annotations & Alerts', - type: 'dashboard', - }, - ], - }, - description: 'Dashboard for API response time visualisations\n', - editable: true, - fiscalYearStartMonth: 0, - graphTooltip: 0, - id: null, - links: [], - liveNow: false, - panels: [], - refresh: '', - schemaVersion: 38, - tags: [], - templating: { - list: [], - }, - time: { - from: 'now-6h', - to: 'now', - }, - timepicker: {}, - timezone: '', - title: 'Response Times', - uid: 'ec1b884b-753e-405f-8f4b-e0a5d97cf167', - version: 6, - weekStart: '', - }; -}; - -export const generateRow = (name: string) => { - const gauagePanel = generateGaugePanel(name); - const heatmap = generateHeatmap(name); - const successfulUnsuccessful = generateSuccessfulUnSuccessfulPanel(name); - const byStatusCode = generateByStatusCode(name); - const averageReponseTimePanel = generateAverageResponseTimePanel(name); - - return { - collapsed: true, - gridPos: { - h: 1, - w: 24, - x: 0, - y: 0, - }, - id: 27, - panels: [ - // textPanel, - gauagePanel, - heatmap, - successfulUnsuccessful, - byStatusCode, - averageReponseTimePanel, - ], - title: name - .split('_') - .map((str) => str.charAt(0).toUpperCase() + str.slice(1)) - .join(' '), - type: 'row', - }; -}; - -export const generateTextPanel = (title: string, text: string) => { - return { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - gridPos: { - h: 1, - w: 24, - x: 0, - y: 0, - }, - id: 26, - options: { - code: { - language: 'plaintext', - showLineNumbers: false, - showMiniMap: false, - }, - content: text, - mode: 'markdown', - }, - pluginVersion: '10.2.0', - title: title, - type: 'text', - }; -}; - -export const generateGaugePanel = (label: string) => { - return { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - fieldConfig: { - defaults: { - color: { - mode: 'thresholds', - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - }, - overrides: [], - }, - gridPos: { - h: 8, - w: 12, - x: 0, - y: 1, - }, - id: 25, - options: { - minVizHeight: 75, - minVizWidth: 75, - orientation: 'auto', - reduceOptions: { - calcs: ['lastNotNull'], - fields: '', - values: false, - }, - showThresholdLabels: false, - showThresholdMarkers: true, - }, - pluginVersion: '10.2.0', - targets: [ - { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - editorMode: 'code', - expr: `sum (${label}_count) by (endpoint)`, - instant: false, - legendFormat: '__auto', - range: true, - refId: 'A', - }, - ], - title: 'Total Requests by endpoint', - type: 'gauge', - }; -}; - -export const generateHeatmap = (label: string) => { - return { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - fieldConfig: { - defaults: { - custom: { - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - scaleDistribution: { - type: 'linear', - }, - }, - }, - overrides: [], - }, - gridPos: { - h: 8, - w: 12, - x: 12, - y: 1, - }, - id: 21, - options: { - calculate: false, - cellGap: 1, - color: { - exponent: 0.5, - fill: 'dark-orange', - mode: 'scheme', - reverse: false, - scale: 'exponential', - scheme: 'Spectral', - steps: 64, - }, - exemplars: { - color: 'rgba(255,0,255,0.7)', - }, - filterValues: { - le: 1e-9, - }, - legend: { - show: true, - }, - rowsFrame: { - layout: 'auto', - }, - tooltip: { - show: true, - yHistogram: false, - }, - yAxis: { - axisPlacement: 'left', - reverse: false, - unit: 's', - }, - }, - pluginVersion: '10.2.0', - targets: [ - { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - editorMode: 'code', - expr: `sum by (le) (rate(${label}_bucket[30s]))`, - format: 'heatmap', - instant: false, - legendFormat: '{{le}}', - range: true, - refId: 'A', - }, - ], - title: `Response Time Heatmap`, - type: 'heatmap', - }; -}; - -export const generateSuccessfulUnSuccessfulPanel = (label: string) => { - return { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisBorderShow: false, - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - insertNulls: false, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - }, - overrides: [], - }, - gridPos: { - h: 8, - w: 12, - x: 0, - y: 9, - }, - id: 24, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, - targets: [ - { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - editorMode: 'code', - expr: `sum by (statusCode) (rate(${label}_count{statusCode=~"2.."}[1h]))\n`, - instant: false, - legendFormat: 'Successful', - range: true, - refId: 'A', - }, - { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - editorMode: 'code', - exemplar: false, - expr: `sum by (statusCode) (\n rate(${label}_count{statusCode=~"4.."}[1h])\n) + ignoring(statusCode) group_left sum by (statusCode) (\n rate(${label}_count{statusCode=~"5.."}[1h])\n)`, - hide: false, - instant: false, - legendFormat: 'Unsuccessful', - range: true, - refId: 'B', - }, - ], - title: '# Unsuccessful and Successful requests', - type: 'timeseries', - }; -}; - -export const generateByStatusCode = (label: string) => { - return { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisBorderShow: false, - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - insertNulls: false, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - }, - overrides: [], - }, - gridPos: { - h: 8, - w: 12, - x: 12, - y: 10, - }, - id: 22, - unit: 's', - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, - targets: [ - { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - editorMode: 'code', - expr: `sum by (statusCode)(${label}_count)`, - format: 'time_series', - hide: false, - instant: false, - legendFormat: '{{statusCode}}', - range: true, - refId: 'B', - }, - ], - title: `# requests by status codes`, - type: 'timeseries', - }; -}; - -export const generateAverageResponseTimePanel = (label: string) => { - return { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisBorderShow: false, - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - insertNulls: false, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - unit: 's', - }, - overrides: [], - }, - gridPos: { - h: 8, - w: 12, - x: 0, - y: 18, - }, - id: 23, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, - pluginVersion: '10.2.0', - targets: [ - { - datasource: { - type: 'prometheus', - uid: 'PBFA97CFB590B2093', - }, - editorMode: 'code', - expr: `sum(rate(${label}_sum[30s]))/sum(rate(${label}_count[30s]))`, - instant: false, - legendFormat: 'average response time', - range: true, - refId: 'A', - }, - ], - title: 'Average request response time', - type: 'timeseries', - }; -}; - -import axios from 'axios'; - -export const updateDashboard = async ( - dashboardJSON: any, - token: string, - grafanaBaseURL: string, -) => { - try { - console.log('dashboardJSON: ', dashboardJSON); - const resp = await axios.post( - grafanaBaseURL + '/api/dashboards/db', - { - dashboard: dashboardJSON, - message: 'update the response time dashboard', - overwrite: true, - }, - { - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - }, - ); - /*.then((res) => { - console.log('response after successful updation of dashboard using grafana api: ', res); - return res.data; - }).catch((err) => { - console.error('error updating the dashboard using grafana api: ', err); - });*/ - console.log('resp: ', resp.data); - return resp.data; - } catch (err) { - console.error('Error updating the dashboard via API Call: ', err); - } - return; -}; - -export const getDashboardByUID = async ( - uid: string, - grafanaBaseURL: string, -) => { - try { - const resp = await axios.get(grafanaBaseURL + `/api/dashboards/uid/${uid}`); - console.log('resp: ', resp.data); - return resp.data.dashboard; - /*.then((res) => { - console.log('fetched the dashboard json: ', res); - return res.data.dashboard; - }).catch((err) => { - console.log('error getting dashboard by uid: ', err); - })*/ - } catch (err) { - console.error('error getting dashboard by uid: ', err); - } - return; -}; - -export const getDashboardJSON = async ( - token: string, - dashboardTitle: string, - grafanaBaseURL: string, -) => { - try { - const resp: any = await axios.get(grafanaBaseURL + '/api/search', { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - return (resp.data as any[]).filter((item) => { - return item.title && item.title === dashboardTitle; - }); - } catch (err) { - console.error('Error searching dashboards: ', err); - } - return; -};