-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: grafonnet-lib -based Postgres query charts
- Loading branch information
1 parent
b9a8429
commit ed8043d
Showing
9 changed files
with
162 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
local grafana = import 'grafonnet-lib/grafana.libsonnet'; | ||
local panels = import 'panels/panels.libsonnet'; | ||
|
||
local dashboard = grafana.dashboard; | ||
local row = grafana.row; | ||
local annotation = grafana.annotation; | ||
local layout = grafana.layout; | ||
|
||
local ds = { | ||
prometheus: { | ||
type: 'prometheus', | ||
uid: std.extVar('prometheus_uid'), | ||
}, | ||
cloudwatch: { | ||
type: 'cloudwatch', | ||
uid: std.extVar('cloudwatch_uid'), | ||
}, | ||
}; | ||
local vars = { | ||
namespace: 'Push', | ||
environment: std.extVar('environment'), | ||
notifications: std.parseJson(std.extVar('notifications')), | ||
}; | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
local height = 8; | ||
local pos = grafana.layout.pos(height); | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
dashboard.new( | ||
title = std.extVar('dashboard_title'), | ||
uid = std.extVar('dashboard_uid'), | ||
editable = true, | ||
graphTooltip = dashboard.graphTooltips.sharedCrosshair, | ||
timezone = dashboard.timezones.utc, | ||
) | ||
.addAnnotation( | ||
annotation.new( | ||
target = { | ||
limit: 100, | ||
matchAny: false, | ||
tags: [], | ||
type: 'dashboard', | ||
}, | ||
) | ||
) | ||
|
||
.addPanels(layout.generate_grid([ | ||
////////////////////////////////////////////////////////////////////////////// | ||
row.new('Application'), | ||
panels.app.postgres_query_rate(ds, vars) { gridPos: pos._6 }, | ||
panels.app.postgres_query_latency(ds, vars) { gridPos: pos._6 }, | ||
])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
terraform/monitoring/panels/app/postgres_query_latency.libsonnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
local grafana = import '../../grafonnet-lib/grafana.libsonnet'; | ||
local defaults = import '../../grafonnet-lib/defaults.libsonnet'; | ||
|
||
local panels = grafana.panels; | ||
local targets = grafana.targets; | ||
|
||
{ | ||
new(ds, vars):: | ||
panels.timeseries( | ||
title = 'Postgres Query Latency', | ||
datasource = ds.prometheus, | ||
) | ||
.configure( | ||
defaults.configuration.timeseries | ||
.withUnit('ms') | ||
) | ||
|
||
.addTarget(targets.prometheus( | ||
datasource = ds.prometheus, | ||
expr = 'sum by (aws_ecs_task_revision, name) (rate(postgres_query_latency_sum[$__rate_interval])) / sum by (aws_ecs_task_revision, name) (rate(postgres_query_latency_count[$__rate_interval]))', | ||
legendFormat = '{{name}} r{{aws_ecs_task_revision}}', | ||
exemplar = false, | ||
refId = 'PostgresQueryLatency', | ||
)) | ||
} |
33 changes: 33 additions & 0 deletions
33
terraform/monitoring/panels/app/postgres_query_rate.libsonnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
local grafana = import '../../grafonnet-lib/grafana.libsonnet'; | ||
local defaults = import '../../grafonnet-lib/defaults.libsonnet'; | ||
|
||
local panels = grafana.panels; | ||
local targets = grafana.targets; | ||
|
||
{ | ||
new(ds, vars):: | ||
panels.timeseries( | ||
title = 'Postgres Query Rate', | ||
datasource = ds.prometheus, | ||
) | ||
.configure( | ||
defaults.configuration.timeseries | ||
.withUnit('cps') | ||
) | ||
|
||
.addTarget(targets.prometheus( | ||
datasource = ds.prometheus, | ||
expr = 'sum by (aws_ecs_task_revision, name) (rate(postgres_queries_total[$__rate_interval]))', | ||
legendFormat = '{{name}} r{{aws_ecs_task_revision}}', | ||
exemplar = true, | ||
refId = 'PostgresQueryRate', | ||
)) | ||
|
||
.addTarget(targets.prometheus( | ||
datasource = ds.prometheus, | ||
expr = 'sum(rate(postgres_queries_total[$__rate_interval]))', | ||
legendFormat = 'r{{aws_ecs_task_revision}}', | ||
exemplar = true, | ||
refId = 'PostgresQueryRateTotal', | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
local panels = (import '../grafonnet-lib/defaults.libsonnet').panels; | ||
|
||
{ | ||
app: { | ||
postgres_query_rate: (import 'app/postgres_query_rate.libsonnet' ).new, | ||
postgres_query_latency: (import 'app/postgres_query_latency.libsonnet' ).new, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters