Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework postgres_mixin dashboard #911

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
/.metrics.*.removed
/tools/src
/vendor
vendor/
3 changes: 3 additions & 0 deletions postgres_mixin/config.libsonnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
_config+:: {
postgresExporterSelector: '',

dashboardNamePrefix: 'Postgres Exporter / ',
dashboardTags: ['postgres-exporter-mixin'],
},
}
3 changes: 3 additions & 0 deletions postgres_mixin/dashboards.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
local dashboards = (import 'mixin.libsonnet').grafanaDashboards;

{ [name]: dashboards[name] for name in std.objectFields(dashboards)}
40 changes: 38 additions & 2 deletions postgres_mixin/dashboards/dashboards.libsonnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
local g = import 'g.libsonnet';

local dashboard = g.dashboard;
local row = g.panel.row;

local panels = import './panels.libsonnet';
local variables = import './variables.libsonnet';
local queries = import './queries.libsonnet';

// import config
local c = import '../config.libsonnet';

{
grafanaDashboards+:: {
'postgres-overview.json': (import 'postgres-overview.json'),
},
'overview.json':
dashboard.new('%s Overview' % $._config.dashboardNamePrefix)
+ dashboard.withTags($._config.dashboardTags)
+ dashboard.withRefresh('1m')
+ dashboard.time.withFrom(value='now-1h')
+ dashboard.graphTooltip.withSharedCrosshair()
+ dashboard.withVariables([
variables.datasource,
])
+ dashboard.withPanels(
g.util.grid.makeGrid([
row.new('Overview')
+ row.withPanels([
panels.stat.qps('QPS', queries.qps),
panels.timeSeries.ratio1('Cache Hit Ratio', queries.cacheHitRatio),
panels.timeSeries.base('Active Connections', queries.activeConnections)
]),
row.new('server')
+ row.withPanels([
panels.timeSeries.base('Conflicts/Deadlocks', [queries.conflicts, queries.deadlocks]),
panels.timeSeries.base('Buffers', [queries.buffersAlloc, queries.buffersBackendFsync, queries.buffersBackend, queries.buffersClean, queries.buffersCheckpoint]),
panels.timeSeries.base('Rows', [queries.databaseTupFetched, queries.databaseTupReturned, queries.databaseTupInserted, queries.databaseTupUpdated, queries.databaseTupDeleted]),
]),
])
)
}
}
1 change: 1 addition & 0 deletions postgres_mixin/dashboards/g.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'
30 changes: 30 additions & 0 deletions postgres_mixin/dashboards/panels.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local g = import 'g.libsonnet';

{
stat: {
local stat = g.panel.stat,

base(title, targets):
stat.new(title)
+stat.queryOptions.withTargets(targets),

qps: self.base,
},

timeSeries: {
local timeSeries = g.panel.timeSeries,

base(title, targets):
timeSeries.new(title)
+timeSeries.queryOptions.withTargets(targets),

ratio(title, targets):
self.base(title, targets)
+ timeSeries.standardOptions.withUnit('percentunit'),

ratio1(title, targets):
self.ratio(title, targets)
+ timeSeries.standardOptions.withUnit('percentunit')
+ timeSeries.standardOptions.withMax(1)
}
}
Loading