Skip to content

Commit

Permalink
define new gcp load balancer dashboard in csp-mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
yduartep committed Aug 30, 2024
1 parent 1132fd7 commit ae00176
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 0 deletions.
1 change: 1 addition & 0 deletions csp-mixin/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
blobstore: (import './signals/blobstore.libsonnet')(this),
azureelasticpool: (import './signals/azureelasticpool.libsonnet')(this),
azuresqldb: (import './signals/azuresqldb.libsonnet')(this),
loadbalancer: (import './signals/loadbalancer.libsonnet')(this),
},
blobStorage: {
enableAvailability: false,
Expand Down
22 changes: 22 additions & 0 deletions csp-mixin/dashboards.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ local commonlib = import 'common-lib/common/main.libsonnet';
),
}
+
{
[csplib.config.uid + '-loadbalancer.json']:
local variables = csplib.signals.loadbalancer.getVariablesMultiChoice();
g.dashboard.new(csplib.config.dashboardNamePrefix + 'Load Balancing')
+ g.dashboard.withUid(csplib.config.uid + '-loadbalancer')
+ g.dashboard.withTags(csplib.config.dashboardTags)
+ g.dashboard.withTimezone(csplib.config.dashboardTimezone)
+ g.dashboard.withRefresh(csplib.config.dashboardRefresh)
+ g.dashboard.timepicker.withTimeOptions(csplib.config.dashboardPeriod)
+ g.dashboard.withVariables([
if std.asciiLower(v.label) == std.asciiLower(csplib.config.blobStorage.bucketLabel) //v.label == 'Bucket_name'
then v { label: 'Bucket Name' }
else v
for v in variables
])
+ g.dashboard.withPanels(
g.util.grid.wrapPanels(
csplib.grafana.rows.glb_requests
)
),
}
+
if csplib.config.uid == 'azure' then
{
[csplib.config.uid + '-elasticpool.json']:
Expand Down
1 change: 1 addition & 0 deletions csp-mixin/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local commonlib = import 'common-lib/common/main.libsonnet';
blobstore: commonlib.signals.unmarshallJsonMulti(this.config.signals.blobstore, type=this.config.metricsSource),
azureelasticpool: commonlib.signals.unmarshallJsonMulti(this.config.signals.azureelasticpool, type=this.config.metricsSource),
azuresqldb: commonlib.signals.unmarshallJsonMulti(this.config.signals.azuresqldb, type=this.config.metricsSource),
loadbalancer: commonlib.signals.unmarshallJsonMulti(this.config.signals.loadbalancer, type=this.config.metricsSource),
},
grafana: {
panels: (import './panels.libsonnet').new(this),
Expand Down
16 changes: 16 additions & 0 deletions csp-mixin/panels.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -383,5 +383,21 @@ local commonlib = import 'common-lib/common/main.libsonnet';
],
'DTU utilization and limits by database'
) + self._asql_tableCommon(),

glb_reqsec:
this.signals.loadbalancer.requestsByStatus.asTimeSeries()
+ commonlib.panels.generic.timeSeries.base.stylize(),

glb_reqcountry:
this.signals.loadbalancer.requestsByCountry.asTimeSeries()
+ commonlib.panels.generic.timeSeries.base.stylize(),

glb_reqcache:
this.signals.loadbalancer.requestsByCache.asTimeSeries()
+ commonlib.panels.generic.timeSeries.base.stylize(),

glb_reqprotocol:
this.signals.loadbalancer.requestsByProtocol.asTimeSeries()
+ commonlib.panels.generic.timeSeries.base.stylize(),
},
}
19 changes: 19 additions & 0 deletions csp-mixin/rows.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,24 @@ local g = import './g.libsonnet';
+ g.panel.timeSeries.gridPos.withW(12)
+ g.panel.timeSeries.gridPos.withH(8),
],

glb_requests: [
g.panel.row.new('Load Balancer Requests'),
this.grafana.panels.glb_reqsec
+ g.panel.timeSeries.gridPos.withW(12)
+ g.panel.timeSeries.gridPos.withH(8),

this.grafana.panels.glb_reqcountry
+ g.panel.timeSeries.gridPos.withW(12)
+ g.panel.timeSeries.gridPos.withH(8),

this.grafana.panels.glb_reqcache
+ g.panel.timeSeries.gridPos.withW(12)
+ g.panel.timeSeries.gridPos.withH(8),

this.grafana.panels.glb_reqprotocol
+ g.panel.timeSeries.gridPos.withW(12)
+ g.panel.timeSeries.gridPos.withH(8),
],
},
}
61 changes: 61 additions & 0 deletions csp-mixin/signals/loadbalancer.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
local commonlib = import 'common-lib/common/main.libsonnet';
function(this)
{
local s = self,
filteringSelector: this.filteringSelector,
groupLabels: this.groupLabels,
instanceLabels: this.instanceLabels,
aggLevel: 'instance',
discoveryMetric: {
stackdriver: 'stackdriver_https_lb_rule_loadbalancing_googleapis_com_https_request_count'
},
signals: {
requestsByStatus: {
name: 'Requests / sec',
description: 'The number of requests per second by status code.',
type: 'raw',
sources: {
stackdriver: {
expr: 'label_replace(sum by (response_code_class) (rate(stackdriver_https_lb_rule_loadbalancing_googleapis_com_https_request_count{%(queriesSelector)s}[$__rate_interval])),"response_code_class","${1}xx","response_code_class","([0-9])00")',
legendCustomTemplate: '{{response_code_class}}',
},
},
},

requestsByCountry: {
name: 'Requests by Country',
description: 'The number of requests per second by client country.',
type: 'raw',
sources: {
stackdriver: {
expr: 'sum by (backend_target_name, client_country) (rate(stackdriver_https_lb_rule_loadbalancing_googleapis_com_https_request_count{%(queriesSelector)s}[$__rate_interval]))',
legendCustomTemplate: '{{client_country}}',
},
},
},

requestsByCache: {
name: 'Requests by Cache Results',
description: 'The cache results per second of requests.',
type: 'raw',
sources: {
stackdriver: {
expr: 'sum by (backend_target_name, cache_result) (rate(stackdriver_https_lb_rule_loadbalancing_googleapis_com_https_request_count{%(queriesSelector)s}[$__rate_interval]))',
legendCustomTemplate: '{{cache_result}}',
},
},
},

requestsByProtocol: {
name: 'Requests by protocol',
description: 'Requests per second by protocol.',
type: 'raw',
sources: {
stackdriver: {
expr: 'sum by (backend_target_name, protocol) (rate(stackdriver_https_lb_rule_loadbalancing_googleapis_com_https_request_count{%(queriesSelector)s}[$__rate_interval]))',
legendCustomTemplate: '{{protocol}}',
},
},
},
},
}

0 comments on commit ae00176

Please sign in to comment.