-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1210 from EnterpriseDB/release/2021-04-07
Former-commit-id: 5363a19
- Loading branch information
Showing
4,230 changed files
with
88,346 additions
and
33,828 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
if [ -z "$husky_skip_init" ]; then | ||
debug () { | ||
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1" | ||
} | ||
|
||
readonly hook_name="$(basename "$0")" | ||
debug "starting $hook_name..." | ||
|
||
if [ "$HUSKY" = "0" ]; then | ||
debug "HUSKY env variable is set to 0, skipping hook" | ||
exit 0 | ||
fi | ||
|
||
if [ -f ~/.huskyrc ]; then | ||
debug "sourcing ~/.huskyrc" | ||
. ~/.huskyrc | ||
fi | ||
|
||
export readonly husky_skip_init=1 | ||
sh -e "$0" "$@" | ||
exitCode="$?" | ||
|
||
if [ $exitCode != 0 ]; then | ||
echo "husky - $hook_name hook exited with code $exitCode (error)" | ||
exit $exitCode | ||
fi | ||
|
||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
advocacy_docs/kubernetes/cloud_native_postgresql/images/architecture-read-only.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
advocacy_docs/kubernetes/cloud_native_postgresql/monitoring.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
title: 'Monitoring' | ||
originalFilePath: 'src/monitoring.md' | ||
product: 'Cloud Native Operator' | ||
--- | ||
|
||
For each PostgreSQL instance, the operator provides an exporter of metrics for | ||
[Prometheus](https://prometheus.io/) via HTTP, on port 8000. | ||
The operator comes with a predefined set of metrics, as well as a highly | ||
configurable and customizable system to define additional queries via one or | ||
more `ConfigMap` objects - and, future versions, `Secret` too. | ||
|
||
The exporter can be accessed as follows: | ||
|
||
```shell | ||
curl http://<pod ip>:8000/metrics | ||
``` | ||
|
||
All monitoring queries are: | ||
|
||
- transactionally atomic (one transaction per query) | ||
- executed with the `pg_monitor` role | ||
|
||
Please refer to the | ||
["Default roles" section in PostgreSQL documentation](https://www.postgresql.org/docs/current/default-roles.html) | ||
for details on the `pg_monitor` role. | ||
|
||
## User defined metrics | ||
|
||
Users will be able to define metrics through the available interface | ||
that the operator provides. This interface is currently in *beta* state and | ||
only supports definition of custom queries as `ConfigMap` and `Secret` objects | ||
using a YAML file that is inspired by the [queries.yaml file](https://github.com/prometheus-community/postgres_exporter/blob/main/queries.yaml) | ||
of the PostgreSQL Prometheus Exporter. | ||
|
||
Queries must be defined in a `ConfigMap` to be referenced in the `monitoring` | ||
section of the `Cluster` definition, as in the following example: | ||
|
||
```yaml | ||
apiVersion: postgresql.k8s.enterprisedb.io/v1 | ||
kind: Cluster | ||
metadata: | ||
name: cluster-example | ||
spec: | ||
instances: 3 | ||
|
||
storage: | ||
size: 1Gi | ||
|
||
monitoring: | ||
customQueriesConfigMap: | ||
- name: example-monitoring | ||
key: custom-queries | ||
``` | ||
Specifically, the `monitoring` section looks for an array with the name | ||
`customQueriesConfigMap`, which, as the name suggests, needs a list of | ||
`ConfigMap` key references to be used as the source of custom queries. | ||
|
||
For example: | ||
|
||
```yaml | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
namespace: default | ||
name: example-monitoring | ||
data: | ||
custom-queries: | | ||
pg_replication: | ||
query: "SELECT CASE WHEN NOT pg_is_in_recovery() | ||
THEN 0 | ||
ELSE GREATEST (0, | ||
EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))) | ||
END AS lag" | ||
primary: true | ||
metrics: | ||
- lag: | ||
usage: "GAUGE" | ||
description: "Replication lag behind primary in seconds" | ||
``` | ||
|
||
The object must have a name and be in the same namespace as the `Cluster`. | ||
Note that the above query will be executed on the `primary` node, with the | ||
following output. | ||
|
||
```text | ||
# HELP custom_pg_replication_lag Replication lag behind primary in seconds | ||
# TYPE custom_pg_replication_lag gauge | ||
custom_pg_replication_lag 0 | ||
``` | ||
|
||
This framework enables the definition of custom metrics to monitor the database | ||
or the application inside the PostgreSQL cluster. |
Oops, something went wrong.