
Introduction
With the recent release of Fujitsu Enterprise Postgres 17, monitoring capabilities with Amazon CloudWatch have been introduced. This allows customers hosting Fujitsu Enterprise Postgres on the AWS cloud to utilize the observability solutions provided by AWS.
The Fujitsu Enterprise Postgres 17 server includes a sample shell script that facilitates the collection of database metrics and the subsequent transmission of this data to Amazon CloudWatch.
Location of sample metrics collection script: /opt/fsepv17server64/share/putting-metrics-to-monitoring-tool.sh.sample
Note: The shell script can be customized to suit your requirements.
The shell script facilitates the following tasks:
- Querying the catalog tables using psql commands
- Converting the SQL command output to JSON format
- Forwarding the metric data in JSON format to CloudWatch using AWS CLI
How to configure monitoring using Amazon CloudWatch
Follow the below steps to monitor Fujitsu Enterprise Postgres database using Amazon CloudWatch.
1 Install AWS CLI
To install the AWS CLI v2, run the following commands (AWS CLI version must be 2.x or later).
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip sudo ./aws/install aws –-version
2 Create an IAM role
Create an IAM role and attach to the EC2 instance where the Fujitsu Enterprise Postgres database is hosted. Assign permission CloudWatchAgentServerPolicy to forward metric data to AWS CloudWatch.
3 Prepare the metrics collection script
Copy the sample metrics collection script to the desired location and make necessary changes to connect to the database.
cp /opt/fsepv17server64/share/putting-metrics-to-monitoring-tool.sh.sample
/fep/monitor/put-metrics-to-cloudwatch.sh
Update the values to the environment variables below in the metric collection script.
export PGUSER="fepuser" export PGDATABASE="postgres" export PGHOST="localhost" export PGPORT="27500"
Also, you can update the Namespace and Dimension value with meaningful values or application names.
export NAMESPACE="FEP17_METRICS"
DIMENSION_VALUE="Demo"
4 Create database extension
Create the database extension pg_stat_statements to collect the statistics for the SQL statements executed.
CREATE EXTENSION IF NOT EXISTS pg_stat_statements ;
5 Schedule metrics collection script
In the final step, schedule the metrics collection script to run periodically using crontab.
Set the environment and schedule the script to run every 10 minutes.
export PATH=/opt/fsepv17server64/bin:/awscli/bin:$PATH
[fepuser@fep17-server: ~]$ crontab -l
# Job to collect metrics every 10 mins
*/10 * * * * /fep/monitor/put-metrics-to-cloudwatch.sh
Dashboard
In Amazon CloudWatch, all the collected metrics are displayed under the defined namespace FEP17_METRICS, as below:
This image shows all the tablespaces and their growth.
Alerts
Additionally, alerting can be configured to notify users via email or other methods when the metric value exceeds the defined threshold. The image below illustrates the tablespace alarm, which was triggered when usage surpassed the 2GiB threshold.