diff --git a/README.md b/README.md index 926fb50..4b4a541 100644 --- a/README.md +++ b/README.md @@ -490,6 +490,14 @@ dashboards: - default ``` +Using external API Gateway: +```yaml +alarms: + dashboards: true + dashboardConfig: + apiName: 'my-api-name-here' +``` + ## License MIT © [A Cloud Guru](https://acloud.guru/) diff --git a/src/dashboards/index.js b/src/dashboards/index.js index 1b82d2e..654f989 100644 --- a/src/dashboards/index.js +++ b/src/dashboards/index.js @@ -5,7 +5,14 @@ const dashboards = { vertical: require('./configs/vertical.json'), }; -const createDashboard = (service, stage, region, functions, name) => { +const createDashboard = ( + service, + stage, + region, + functions, + name, + dashboardConfig +) => { const dashboard = dashboards[name]; if (!dashboard) { @@ -21,6 +28,7 @@ const createDashboard = (service, stage, region, functions, name) => { coordinates: w.coordinates, title: w.title, functions, + dashboardConfig, }; return widget.createWidget(config); diff --git a/src/dashboards/widgets/api-gw/latency/numbers.js b/src/dashboards/widgets/api-gw/latency/numbers.js index f8564d7..757b2c6 100644 --- a/src/dashboards/widgets/api-gw/latency/numbers.js +++ b/src/dashboards/widgets/api-gw/latency/numbers.js @@ -1,5 +1,7 @@ const createWidget = (config) => { - const apiName = `${config.stage}-${config.service}`; + const apiName = config.dashboardConfig.apiName + ? config.dashboardConfig.apiName + : `${config.stage}-${config.service}`; const widget = { type: 'metric', diff --git a/src/dashboards/widgets/api-gw/latency/time-series.js b/src/dashboards/widgets/api-gw/latency/time-series.js index 6e7e6cf..6821d88 100644 --- a/src/dashboards/widgets/api-gw/latency/time-series.js +++ b/src/dashboards/widgets/api-gw/latency/time-series.js @@ -1,5 +1,7 @@ const createWidget = (config) => { - const apiName = `${config.stage}-${config.service}`; + const apiName = config.dashboardConfig.apiName + ? config.dashboardConfig.apiName + : `${config.stage}-${config.service}`; const widget = { type: 'metric', diff --git a/src/dashboards/widgets/api-gw/requests/numbers.js b/src/dashboards/widgets/api-gw/requests/numbers.js index 71cc70a..3fdc692 100644 --- a/src/dashboards/widgets/api-gw/requests/numbers.js +++ b/src/dashboards/widgets/api-gw/requests/numbers.js @@ -1,5 +1,7 @@ const createWidget = (config) => { - const apiName = `${config.stage}-${config.service}`; + const apiName = config.dashboardConfig.apiName + ? config.dashboardConfig.apiName + : `${config.stage}-${config.service}`; const widget = { type: 'metric', diff --git a/src/dashboards/widgets/api-gw/requests/time-series.js b/src/dashboards/widgets/api-gw/requests/time-series.js index 7bb34f8..42f9b4d 100644 --- a/src/dashboards/widgets/api-gw/requests/time-series.js +++ b/src/dashboards/widgets/api-gw/requests/time-series.js @@ -1,5 +1,7 @@ const createWidget = (config) => { - const apiName = `${config.stage}-${config.service}`; + const apiName = config.dashboardConfig.apiName + ? config.dashboardConfig.apiName + : `${config.stage}-${config.service}`; const widget = { type: 'metric', diff --git a/src/index.js b/src/index.js index 6609061..cb8c6c1 100644 --- a/src/index.js +++ b/src/index.js @@ -482,6 +482,7 @@ class AlertsPlugin { const provider = service.provider; const stage = this.options.stage; const region = this.options.region || provider.region; + const config = this.getConfig(); const dashboardTemplates = this.getDashboardTemplates( configDashboards, stage @@ -497,7 +498,8 @@ class AlertsPlugin { stage, region, functions, - d + d, + config.dashboardConfig ? config.dashboardConfig : {} ); const cfResource =