Sign inSign up

datasentinel/postgres-template

By datasentinel

•Updated about 5 years ago

Image
0

173

datasentinel/postgres-template repository overview

Datasentinel

⁠Datasentinel⁠ is a unique and innovative performance tool for Postgres. Explore all the features on our Live Demo⁠ site
⁠Docker image

Example image with PostgreSQL 13 including the extensions used by Datasentinel

  • pg_stat_statements (required)
  • pg_store_plans (optional)
  • datasentinel (optional)
⁠Image
FROM postgres:13

ENV PG_SERVER_VERSION=13


RUN apt-get clean && rm -rf /var/lib/apt/lists/partial \
   && apt-get update -o Acquire::CompressionTypes::Order::=gz \
   && apt-get install --no-install-recommends -y wget make gcc unzip sudo git \
       curl libc6-dev apt-transport-https ca-certificates pgxnclient bc \
       build-essential libevent-dev libssl-dev krb5-multidev lsb-release \
   && apt-get install --no-install-recommends -y postgresql-server-dev-${PG_SERVER_VERSION} \
   # pg_store_plans extension
   && git clone https://github.com/ossc-db/pg_store_plans.git \
   && cd pg_store_plans \
   && export USE_PGXS=1 \
   && make \
   && make install \ 
   && cd .. \
   && rm -rf pg_store_plans \
   # datasentinel extension
   && git clone https://github.com/datasentinel/datasentinel_extension.git \
   && cd datasentinel_extension/src \
   && make \
   && make install \
   && cd ../.. \
   && rm -rf datasentinel_extension \
   && cd / \
   && rm -rf /tmp/* \ 
   && apt-get purge -y --auto-remove gcc \
      make wget unzip curl libc6-dev apt-transport-https git \
      postgresql-server-dev-${PG_SERVER_VERSION} pgxnclient build-essential \
      libssl-dev krb5-multidev comerr-dev krb5-multidev lsb-release \
      libgssrpc4 libkadm5clnt-mit11 libkadm5srv-mit11 \
   && apt-get clean -y autoclean \
   && rm -rf /var/lib/apt/lists/*

COPY init-postgres.sh /docker-entrypoint-initdb.d

EXPOSE 5432

CMD ["postgres"]
⁠Shell script init-postgres.sh
#!/bin/bash

# Add extension parameters
cat <<EOF >>/var/lib/postgresql/data/postgresql.conf
shared_preload_libraries = 'pg_stat_statements,pg_store_plans,datasentinel'
track_activity_query_size = 65536
pg_stat_statements.track = all
pg_store_plans.log_analyze = false
pg_store_plans.log_timing = false
pg_store_plans.max=1000
pg_store_plans.track=all
pg_store_plans.plan_format=text
pg_store_plans.min_duration=0
pg_store_plans.log_buffers=false
pg_store_plans.log_triggers=false
pg_store_plans.verbose=false
pg_store_plans.save=false
EOF

# Add entry in pg_hba.conf for user datasentinel
# You should restrict the access depending on your configuration 
cat <<EOF >>/var/lib/postgresql/data/pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             datasentinel    0.0.0.0/0             md5
EOF


psql <<EOF
CREATE EXTENSION PG_STAT_STATEMENTS;
CREATE EXTENSION PG_STORE_PLANS;
CREATE EXTENSION DATASENTINEL;
create user datasentinel password '${POSTGRES_PASSWORD}';
grant pg_monitor,pg_read_all_settings,pg_read_all_stats to datasentinel;

EOF

See Complete Documentation⁠


Active Session history


Top queries


Top tables

Tag summary

Content type

Image

Digest

Size

112.9 MB

Last updated

about 5 years ago

docker pull datasentinel/postgres-template