This page lists the tools you can use to monitor your AlloyDB Omni instance.
Monitoring tools
The following table lists the tools you can choose and install to monitor your AlloyDB Omni instance:
| To | Use | Description |
|---|---|---|
| Monitor performance and availability | Datadog | Monitor the performance, availability, and health of your AlloyDB Omni instance. |
| Export observability data from your instance | Postgres Exporter | Export the results of observability queries. To install Postgres Exporter |
| Retrieve observability data in a readable format | Prometheus | Monitoring system to return the observability data in a readable format. To install Prometheus |
| Display data in a dashboard | Grafana | Create a dashboard to display metrics. To install Grafana |
| Retrieve performance data for analysis | Performance snapshot reports | Retrieve performance data to identify the cause of performance issues. |
Install Postgres Exporter
Postgres Exporter is a tool that exports observability queries in a format that Prometheus, a monitoring system, can read. The exporter comes with many standard queries built in it and you can add additional queries and rules depending on your needs. Additional security options, such as SSL and user authentication, can be configured as well. For this example, only the basic configuration options are used.
Install
Create a directory for Postgres Exporter.
sudo mkdir /opt/postgres_exportersudo chown USER_ACCOUNT:USER_ACCOUNT /opt/postgres_exportercd /opt/postgres_exporterDownload Postgres Exporter.
wget https://github.com/prometheus-community/postgres_exporter/releases/download/v0.15.0/postgres_exporter-0.15.0.linux-amd64.tar.gz
Extract Postgres Exporter.
tar -xzvf postgres_exporter-0.15.0.linux-amd64.tar.gz
Copy Postgres Exporter to the directory you created.
cd postgres_exporter-0.15.0.linux-amd64sudo cp postgres_exporter /usr/local/binCreate an appropriate
.envfile for Postgres Exporter.cd /opt/postgres_exportersudo vi postgres_exporter.envAdd data sources to
/opt/postgres_exporter/postgres_exporter.envto monitor one or more databases.To monitor a single database, add the following line:
DATA_SOURCE_NAME="postgresql://USERNAME:PASSWORD@POSTGRES_IP_ADDRESS:PORT/DATABASE_NAME?sslmode=disable"To monitor all databases, add the following line:
DATA_SOURCE_NAME="postgresql://USERNAME:PASSWORD@POSTGRES_IP_ADDRESS:PORT/?sslmode=disable"Replace the following variables:
USERNAME: Username to sign in to the database.PASSWORD: Password for the user account.POSTGRES_IP_ADDRESS: IP address of the AlloyDB Omni instance.PORT: Port the database is hosted on.DATABASE_NAME: Name of the database.
Add the following information to
/etc/systemd/system/postgres_exporter.serviceso Postgres Exporter survives reboots.[Unit] Description=Prometheus exporter for Postgresql Wants=network-online.target After=network-online.target [Service] User=postgres Group=postgres WorkingDirectory=/opt/postgres_exporter EnvironmentFile=/opt/postgres_exporter/postgres_exporter.env ExecStart=/usr/local/bin/postgres_exporter --web.listen-address=:POSTGRES_EXPORTER_PORT --web.telemetry-path=/metrics Restart=always [Install] WantedBy=multi-user.targetReplace the following variable:
POSTGRES_EXPORTER_PORT: Port Postgres Exporter is hosted on. We recommend using port9187.
Reload Postgres Exporter.
sudo systemctl daemon-reload
Start Postgres Exporter.
sudo systemctl start postgres_exportersudo systemctl enable postgres_exportersudo systemctl status postgres_exporter
Postgres Exporter should now be available at the following URL:
http://POSTGRES_EXPORTER_HOST_IP_ADDRESS:POSTGRES_EXPORTER_PORT/metrics
Replace the following variables:
POSTGRES_EXPORTER_HOST_IP_ADDRESS: IP address of your machine.POSTGRES_EXPORTER_PORT: Port you used in step 7.
Prometheus
Prometheus is a monitoring system that can be used to query Postgres Exporter and return the observability data in a readable format.
Install
Create a
prometheususer.sudo groupadd --system prometheussudo useradd -s /sbin/nologin --system -g prometheus prometheusCreate directories for Prometheus.
sudo mkdir /etc/prometheussudo mkdir /var/lib/prometheusDownload Prometheus.
wget https://github.com/prometheus/prometheus/releases/download/v2.52.0/prometheus-2.52.0.linux-amd64.tar.gz
Extract Prometheus.
sudo tar xvf prometheus*.tar.gzcd prometheus*/sudo mv prometheus /usr/local/binsudo mv promtool /usr/local/binSet ownership of Prometheus to the
prometheususer.sudo chown prometheus:prometheus /usr/local/bin/prometheussudo chown prometheus:prometheus /usr/local/bin/promtoolMove the configuration files to the correct location.
sudo mv consoles /etc/prometheussudo mv console_libraries /etc/prometheussudo mv prometheus.yml /etc/prometheusSet ownership of the Prometheus directories to the
prometheususer.sudo chown prometheus:prometheus /etc/prometheussudo chown prometheus:prometheus /etc/prometheus/*sudo chown -R prometheus:prometheus /etc/prometheus/consolessudo chown -R prometheus:prometheus /etc/prometheus/console_librariessudo chown -R prometheus:prometheus /var/lib/prometheusAdd the following information to
/etc/prometheus/prometheus.ymlso that Prometheus can query Postgres Exporter.global: scrape_interval: 15s scrape_configs: - job_name: postgres static_configs: - targets: ['POSTGRES_EXPORTER_MACHINE_IP_ADDRESS:9187']Add the following information to
/etc/systemd/system/prometheus.serviceso Prometheus survives reboots.[Unit] Description=Prometheus Wants=network-online.target After=network-online.target [Service] User=prometheus Group=prometheus Type=simple ExecStart=/usr/local/bin/prometheus \ --config.file /etc/prometheus/prometheus.yml \ --storage.tsdb.path /var/lib/prometheus/ \ --web.console.templates=/etc/prometheus/consoles \ --web.console.libraries=/etc/prometheus/console_libraries [Install] WantedBy=multi-user.targetReload Prometheus.
sudo systemctl daemon-reload
Start Prometheus.
sudo systemctl start prometheussudo systemctl enable prometheussudo systemctl status prometheus
Prometheus should now be available at the following URL:
http://PROMETHEUS_HOST_IP_ADDRESS:9090
Replace the following variable:
PROMETHEUS_HOST_IP_ADDRESS: IP address of your machine.
Grafana
Grafana is a dashboarding tool that exposes Prometheus metrics to an end user
through a dashboard. Multiple standard dashboards are available for Postgres
Exporter and this observability example leverages those available dashboards.
Grafana is available through normal apt and yum repositories and we use
those to install this product.
Install
Install Grafana.
For Ubuntu and Debian systems, run the following commands:
sudo apt-get updatesudo apt-get install grafanaFor RHEL, CentOS, or Rocky Linux systems, complete the following tasks:
Import the GPG key.
wget -q -O gpg.key https://rpm.grafana.com/gpg.keysudo rpm --import gpg.keyCreate the
/etc/yum.repos.d/grafana.repofile with the following content:[grafana] name=grafana baseurl=https://rpm.grafana.com repo_gpgcheck=1 enabled=1 gpgcheck=1 gpgkey=https://rpm.grafana.com/gpg.key sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crtInstall Grafana.
sudo dnf install grafana
Reload Grafana.
sudo systemctl daemon-reload
Start Grafana.
sudo systemctl start grafana-serversudo systemctl enable grafana-serversudo systemctl status grafana-server
Grafana should now be available at the following URL:
http://GRAFANA_HOST_IP_ADDRESS:9090
Replace the following variable:
GRAFANA_HOST_IP_ADDRESS: IP address of your machine.
Load a dashboard
You can find general instructions on how to configure and operate Grafana on Set up Grafana. There are many public dashboards available, but we recommend the following PostgreSQL statistics dashboard.
To load a dashboard, complete the following tasks:
Set up Grafana.
Open the Grafana console using the URL address from Grafana's Install section. The default username and password is
admin.Change the default password.
If the Prometheus data source is not added, navigate to Home > Data sources.
Click Add new data source.
Select Prometheus.
In the Prometheus server URL field, enter the URL address from Prometheus' Install section.
Change the following configuration settings:
- Prometheus type: Select Prometheus.
- Prometheus version: Select > 2.5.x.
Click Save & test.
Create a new dashboard.
Navigate to Home > Dashboards.
Click New.
Select New dashboard.
Click Import dashboard.
Enter the following URL: https://grafana.com/grafana/dashboards/13494-postgresql-statistics/.
Click Load.
Change the Name of the dashboard to
PRODUCT_NAME PostgreSQL statistics.Replace
PRODUCT_NAMEwith the name of your product.Select your data source from the Prometheus field.
Click Import.
Performance snapshot reports
Performance snapshot reports are a built-in AlloyDB Omni tool that captures and analyzes performance data to help you identify the cause of performance issues. This tool complements other AlloyDB Omni observability features like systems insights, query insights, and the Metrics Explorer, which provide real-time metrics about your instance.
For more information, see Optimize database performance by comparing performance snapshots.