Top
Enterprise Postgres 18 for Kubernetes User's Guide

4.5.3 Forwarding Custom Metrics

If you want to forward metrics other than "5.7.2.5 Metrics Collected by CloudWatch" to CloudWatch, specify a file containing a query in spec.fep.externalMonitoring.cloudWatch.customMetrics. The query in the file can be read and executed, and the results can be forwarded to CloudWatch. Below is an example of a ConfigMap definition.

Example of ConfigMap "config-map-query" definition

kind: ConfigMap
apiVersion: v1
metadata:
  name: config-map-query
data:
  metricsName: <Any name>
  dimensionColumns: |
    - <Columns that can be obtained with metricsQuery>
    - <Columns that can be obtained with metricsQuery>
  metricsColumns: |
    - <Columns that can be obtained with metricsQuery>: <Metrics unit>
    - <Columns that can be obtained with metricsQuery>: <Metrics unit>
  metricsQuery.sql: |
    SELECT <Columns specified in dimension_columns and metrics_columns> FROM …

Create a ConfigMap that defines custom metrics for each query.

Details of each parameter specified in the ConfigMap are shown below.

Item

Description

metricsName

Optional

Specify any metrics name.

Metrics will be forwarded to CloudWatch with the metrics name <metricsName>_<metricsColumns>.

dimensionColumns

Optional

Specify the column to be used for the Dimension from the column obtained by the query specified in metricsQuery. The column name is used as the key, and the value obtained by the query is used as the value, and the dimension is registered in CloudWatch.

metricsColumns

Specify the columns to be used as metrics from the columns retrieved by the query specified in metricsQuery in the following format.

  - Column name: Metrics unit

If a column name or metricsName is specified, <metricsName>_<column name> will be transferred to CloudWatch as the metric name.

metricsQuery.sql

Define the query to get metrics from PostgreSQL. Create the query so that the columns of the retrieved data include the columns specified in dimensionColumns and metricsColumns.