-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
172 additions
and
13 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,10 @@ | ||
go_library( | ||
name = "model", | ||
srcs = [ | ||
"model.go", | ||
], | ||
visibility = ["PUBLIC"], | ||
deps = [ | ||
"//third_party/go:pgtype", | ||
], | ||
) |
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
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,45 @@ | ||
package db | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/odonate/postgres-exporter/exporter/db/model" | ||
) | ||
|
||
const sqlSelectPgStatStatements = ` | ||
SELECT | ||
t2.rolname, | ||
t3.datname, | ||
queryid, | ||
calls, | ||
total_time / 1000 as total_time_seconds, | ||
min_time / 1000 as min_time_seconds, | ||
max_time / 1000 as max_time_seconds, | ||
mean_time / 1000 as mean_time_seconds, | ||
stddev_time / 1000 as stddev_time_seconds, | ||
rows, | ||
shared_blks_hit, | ||
shared_blks_read, | ||
shared_blks_dirtied, | ||
shared_blks_written, | ||
local_blks_hit, | ||
local_blks_read, | ||
local_blks_dirtied, | ||
local_blks_written, | ||
temp_blks_read, | ||
temp_blks_written, | ||
blk_read_time / 1000 as blk_read_time_seconds, | ||
blk_write_time / 1000 as blk_write_time_seconds | ||
FROM pg_stat_statements t1 | ||
JOIN pg_roles t2 ON (t1.userid=t2.oid) | ||
JOIN pg_database t3 ON (t1.dbid=t3.oid) | ||
WHERE t2.rolname != 'rdsadmin'` | ||
|
||
// SelectPgStatStatements selects stats on user tables. | ||
func (db *Client) SelectPgStatStatements(ctx context.Context) ([]*model.PgStatStatement, error) { | ||
pgStatStatements := []*model.PgStatStatement{} | ||
if err := db.Select(ctx, &pgStatStatements, sqlSelectPgStatStatements); err != nil { | ||
return nil, err | ||
} | ||
return pgStatStatements, nil | ||
} |
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,3 @@ | ||
|
||
|
||
gofmt -w ~/postgres-exporter |