MCPcopy
hub / github.com/prometheus-community/postgres_exporter

github.com/prometheus-community/postgres_exporter @v0.20.0 sqlite

repository ↗ · DeepWiki ↗ · release v0.20.0 ↗
347 symbols 1,346 edges 69 files 86 documented · 25%
README

Using Postgres-Exporter with AWS:RDS

When using postgres-exporter with Amazon Web Services' RDS, the

rolname "rdsadmin" and datname "rdsadmin" must be excluded.

I had success running docker container 'quay.io/prometheuscommunity/postgres-exporter:latest' with queries.yaml as the PG_EXPORTER_EXTEND_QUERY_PATH. errors mentioned in issue#335 appeared and I had to modify the 'pg_stat_statements' query with the following: WHERE t2.rolname != 'rdsadmin'

Running postgres-exporter in a container like so: DBNAME='postgres' PGUSER='postgres' PGPASS='psqlpasswd123' PGHOST='name.blahblah.us-east-1.rds.amazonaws.com' docker run --rm --detach \ --name "postgresql_exporter_rds" \ --publish 9187:9187 \ --volume=/etc/prometheus/postgresql-exporter/queries.yaml:/var/lib/postgresql/queries.yaml \ -e DATA_SOURCE_NAME="postgresql://${PGUSER}:${PGPASS}@${PGHOST}:5432/${DBNAME}?sslmode=disable" \ -e PG_EXPORTER_EXCLUDE_DATABASES=rdsadmin \ -e PG_EXPORTER_DISABLE_DEFAULT_METRICS=true \ -e PG_EXPORTER_EXTEND_QUERY_PATH='/var/lib/postgresql/queries.yaml' \ quay.io/prometheuscommunity/postgres-exporter \ --no-collector.settings

Expected changes to RDS:

  • see stackoverflow notes (https://stackoverflow.com/questions/43926499/amazon-postgres-rds-pg-stat-statements-not-loaded#43931885)
  • you must also use a specific RDS parameter_group that includes the following: shared_preload_libraries = "pg_stat_statements,pg_hint_plan"
  • lastly, you must reboot the RDS instance.

Extension points exported contracts — how you extend this code

Collector (Interface)
(no doc) [26 implementers]
collector/collector.go
ExporterOpt (FuncType)
ExporterOpt configures Exporter.
exporter/postgres_exporter.go
ServerOpt (FuncType)
ServerOpt configures a server.
exporter/server.go
Option (FuncType)
(no doc)
collector/collector.go

Core symbols most depended-on inside this repo

Close
called by 96
collector/instance.go
Error
called by 37
exporter/postgres_exporter.go
getDB
called by 30
collector/instance.go
registerCollector
called by 26
collector/collector.go
Update
called by 17
collector/pg_stat_statements.go
String
called by 17
config/dsn.go
String
called by 8
exporter/server.go
stringValue
called by 7
collector/pg_stat_activity.go

Shape

Function 202
Method 83
Struct 53
TypeAlias 5
FuncType 3
Interface 1

Languages

Go100%

Modules by API surface

exporter/postgres_exporter.go34 symbols
collector/pg_stat_statements_test.go17 symbols
exporter/postgres_exporter_test.go16 symbols
collector/collector.go16 symbols
exporter/server.go13 symbols
collector/pg_replication_slots.go13 symbols
config/config.go12 symbols
exporter/postgres_exporter_integration_test.go8 symbols
collector/pg_stat_replication.go8 symbols
collector/pg_setting.go8 symbols
config/dsn.go7 symbols
collector/pg_replication_slots_test.go7 symbols

Dependencies from manifests, versioned

github.com/alecthomas/unitsv0.0.0-2024092700094 · 1×
github.com/beorn7/perksv1.0.1 · 1×
github.com/blang/semver/v4v4.0.0 · 1×
github.com/cespare/xxhash/v2v2.3.0 · 1×
github.com/jpillora/backoffv1.0.0 · 1×
github.com/jtolds/glsv4.20.0+incompatible · 1×

Datastores touched

circle_testDatabase · 1 repos
nothingDatabase · 1 repos
postgresDatabase · 1 repos
somevalueDatabase · 1 repos
tsdbDatabase · 1 repos

For agents

$ claude mcp add postgres_exporter \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact