[Using GCP] Stackdriver Third-party Appication Monitoring (6.PostgreSQL)

글쓴이 : 윤성재 (공작명왕)
E-mail : <gongjak@gmail.com>
Facebook : < https://www.facebook.com/sungjae.yun >

PostgreSQL Plugin

1.PostgreSQL 설치와 시작

< Debian 8 >

sudo apt-get install postgresql

< CentOS 7 >

sudo yum install postgresql-server postgresql-contrib
sudo postgresql-setup initdb
sudo systemctl start postgresql

2.사전 준비

모니터링을 위해 DB 사용자를 추가해줘야 한다. ID와 Password는 반드시 수정해서 입력하길 바란다.

sudo su - postgres
psql
postgres=# CREATE ROLE stackuser LOGIN PASSWORD ‘stack1234’ SUPERUSER;
postgres=# \q

pg_hba.conf 파일에 앞에 생성한 stackdriver 유저로 접근할 수 있도록 접근 권한을 줘야 한다. 다음 내용을 추가해준다.

< Debian 8 >

/etc/postgresql/9.4/main/pg_hba.conf

host all stackuser 127.0.0.1/32 md5

< CentOS 7 >

/var/lib/pgsql/data/pg_hba.conf

host all stackuser ::1/128 md5
host all stackuser 127.0.0.1/32 md5

postgresql 서버를 재기동 한 후, 잘 접속 되는지 확인해본다.

psql -U stackuser -W -h localhost -d postgres

3.Plugin 설치

cd /opt/stackdriver/collectd/etc/collectd.d/ && sudo curl -O https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/postgresql.conf

postgresql.conf 파일을 열어서 다음 내용으로 수정해준다.

DATABASE_NAME ==> postgres
#Host "localhost" ==> Host "localhost"
STATS_USER ==> stackuser
STATS_PASS ==> stack1234

4.Stackdriver Agent 재시작

< Debian 8 >

sudo service stackdriver-agent restart

< CentOS 7 >

sudo systemctl restart stackdriver-agent

5.Monitoring 확인

Monitoring -> Resources -> Instances

각 서버를 클릭해보자. stackdriver agent가 plugin이 정상으로 동작하여 정보를 제대로 가져온다면 Monitoring의 오른쪽 그래프 윗부분에서 다음과 같은 화면을 볼 수 있다.

stackdriver-2-image00

[ 출처: Flickr, gongjak1 ]

6.현재 모니터링 가능한 항목

  • Connections (count): Number of connections to PostgreSQL.
  • Disk Usage (byte): Number of bytes currently being used on disk.
  • Commits (count/s): Number of commits per second.
  • Rollbacks (count/s): Number of rollbacks per second.
  • Heap Blocks Read Rate (count/s): Number of blocks read from the heap.
  • Heap Cache Hit Rate (count/s): Number of blocks read directly out of the cache.
  • Index Blocks Read Rate (count/s): Number of blocks read from the index.
  • Index Cache Hit Rate (count/s): Number of index blocks read directly out of the cache.
  • Toast Blocks Read Rate (count/s): Number of reads from the toast blocks.
  • Toast Cache Hit Rate (count/s): Number of toast blocks read directly out of the cache.
  • Toast Index Blocks Read Rate (count/s): Number of blocks read from the toast index.
  • Toast Index Cache Hit Rate (count/s): Number of toast index blocks read directly out of the cache.
  • Operations [delete, insert, update, heap only update] (count/s): Number of rows [deleted, inserted, updated, heap only updated] in the db.
  • Dead Tuples (count): Number of tuples that are dead in the db.
  • Live Tuples (count): Number of tuples that are live in the db.

답글 남기기

아래 항목을 채우거나 오른쪽 아이콘 중 하나를 클릭하여 로그 인 하세요:

WordPress.com 로고

WordPress.com의 계정을 사용하여 댓글을 남깁니다. 로그아웃 /  변경 )

Facebook 사진

Facebook의 계정을 사용하여 댓글을 남깁니다. 로그아웃 /  변경 )

%s에 연결하는 중

%d 블로거가 이것을 좋아합니다: