Viewing metrics and logs from Azure

BigAnimal sends all metrics and logs from Postgres clusters to Azure. You can view metrics and logs directly from Azure. The following describes the metrics and logs that are sent and how to view them.

Azure log analytics

When BigAnimal deploys workloads on Azure, the logs from the Postgres clusters are forwarded to the Azure Log Workspace. To query BigAnimal logs, you must use Azure Log Analytics and Kusto Query language.

Query Postgres cluster logs

All logs from your Postgres clusters are stored in the Customer Log Analytics workspace. To find your Customer Log Analytics workspace.

  1. Sign in to the Azure portal.

  2. Select Resource Groups.

  3. Select the resource group corresponding to the region where you choose to deploy your BigAnimal cluster. You see resources included in that resource group.

  4. Select the resource of type Log Analytics workspace with the prefix log-workspace-.

  5. Select the logs in the menu on the left in the General section.

  6. Close the dashboard with prebuilt queries. This brings you to the KQL Editor.

The following tables containing BigAnimal logs are available in the Customer Log Analytic workspace.

Table nameDescriptionLogger
PostgresLogs_CLLogs of the customer clusters databases (all Postgres-related logs)logger = postgres
PostgresAuditLogs_CLAudit logs of the customer clusters databaseslogger = pgaudit or edb_audit

Logs are split into structured fields matching those of the Postgres csvlog format with a record_ prefix and a type-suffix. For example, the application_name is in the record_application_name_s log field. The pg_cluster_id_s field identifies the specific Postgres cluster that originated the log message.

You can use the KQL Query editor to compose your queries over these tables. For example,

PostgresLogs_CL
| project record_log_time_s, record_error_severity_s, record_detail_s
| sort by record_log_time_s desc

PostgresAuditLogs_CL
| where logger_s == "pgaudit"
| project record_log_time_s, record_error_severity_s, record_audit_statement_s
| sort by record_log_time_s desc

PostgresAuditLogs_CL
| where logger_s == "edb_audit"
| project record_log_time_s, record_error_severity_s, record_message_s
| sort by record_log_time_s desc

Metrics

BigAnimal collects a wide set of metrics about Postgres instances into the DpMetrics_CL log analytics table. Most of these metrics are acquired directly from Postgres system tables, views, and functions. The Postgres documentation serves as the main reference for these metrics.

Available metrics

The following tables in the Customer Log Analytic workspace contain metrics specific to BigAnimal:

Table nameDescription
DpMetrics_CLMetrics streams from BigAnimal Prometheus.

You can use the KQL Query editor in the Log Workspace view to compose queries over these tables.

The forwarded Prometheus metrics use structured JSON fields, particularly the Message and Message.labels fields. To query these fields you need to use the KQL function todynamic() in your queries.

At time of writing, all metrics forwarded from Prometheus are in the DpMetrics_CL table. This might change in a future release.

The available set of metrics is subject to change. Metrics might be added, removed or renamed. Where feasible, an effort will be made not to change the meaning or type of existing metrics without also changing the metric name.

Metrics labels

All Postgres metrics share a common labelling scheme. Entries generally have at least the following labels:

NameDescription
instanceIP address of the host the metric originated from
postgresqlBigAnimal postgres cluster identifier, e.g., p-abcdef012345
rolePostgres instance role, "primary" or "standby replica"
datnamePostgres database name (where applicable)
podk8s pod name
aks_cluster_nameAKS cluster name

When querying for labels, for best performance apply filters that don't require inspection of labels (for example, filters by metric name) before label-based filters.

The labels field of a metrics entry is a nested field under the JSON-typed Message field. To query the field for individual values you JSON parse the Message field and dot reference (m.labels) the labels property. Some uses of values might require explicit casts to another type, for example, tostring(...).

Example usage:

DpMetrics_CL
| where Message has "cnp_"
| extend m = todynamic(Message)
| where m.labels.role == "primary"
| project postgres_cluster_id = tostring(m.labels.postgresql), metric_name = m.name, metric_value = m.value

A detailed list of available metrics are found at metrics.

Workbooks

You can view logs from your Postgres clusters using Azure Workbooks. See Azure Monitor Workbooks for information on using Azure Workbooks.

To access Azure Workbooks:

  1. Sign in to the Azure portal.

  2. Search for "workbooks".

  3. Filter the search results, as needed. For example, you might need to filter by subscription if your account has more than one and the location that corresponds with the region where you deployed your cluster. You can either use the filter controls or search to narrow the search results.

  4. Select the workbook link in the Name column to open the workbook details. Names have the format ${GUID} (xxx-rg-${region}-management-xxx-customer). For example 62b6d449-e0e5-480a-9809-cae2ff6510e9 (123-rg-australiaeast-management-abcd-customer).

  5. Select Open Workbook in the workbook details to launch an interactive workbook with various metrics for your deployed clusters.