canonical / canonical/script-exporter-operator

Add tutorial for monitoring postgresql certificate expiry

Open
#48 2 comments 1 reaction 0 assignees View on GitHub
Status: Triage Type: Enhancement
Dominant language
Python
Stars
1
Forks
2
Avg merge
4h 2m
Merged PRs (30d)
1

Description

### Enhancement Proposal

Since [blackbox exporter currently does not support postgres tcp](https://github.com/canonical/blackbox-exporter-k8s-operator/issues/75), we could document how to achieve the same using script-exporter.

For example, given the following bundle, we can obtain the seconds remaining until certificate expires using:
```bash
echo | openssl s_client -starttls postgres -connect 10.113.46.168:5432 2>/dev/null \
| openssl x509 -noout -enddate \
| cut -d= -f2 \
| xargs -I{} date -d "{}" +%s \
| awk -v now=$(date +%s) '{print $1 - now}'
```

```yaml
default-base: ubuntu@24.04/stable
applications:
pg:
charm: postgresql
channel: 14/stable
revision: 936
base: ubuntu@22.04/stable
num_units: 1
to:
- "0"
ssc:
charm: self-signed-certificates
channel: 1/stable
revision: 317
num_units: 1
to:
- "1"
machines:
"0":
constraints: arch=amd64
base: ubuntu@22.04/stable
"1":
constraints: arch=amd64
relations:
- - ssc:certificates
- pg:certificates
```
```
Model Controller Cloud/Region Version SLA Timestamp
pg lxd localhost/localhost 3.6.11 unsupported 18:50:59-04:00

App Version Status Scale Charm Channel Rev Exposed Message
pg 14.19 active 1 postgresql 14/stable 936 no
ssc active 1 self-signed-certificates 1/stable 317 no

Unit Workload Agent Machine Public address Ports Message
pg/0* active idle 0 10.113.46.168 5432/tcp Primary
ssc/0* active idle 1 10.113.46.85

Machine State Address Inst id Base AZ Message
0 started 10.113.46.168 juju-a841b7-0 ubuntu@22.04 postgres-cert Running
1 started 10.113.46.85 juju-a841b7-1 ubuntu@24.04 postgres-cert Running

Integration provider Requirer Interface Type Message
pg:database-peers pg:database-peers postgresql_peers peer
pg:restart pg:restart rolling_op peer
pg:upgrade pg:upgrade upgrade peer
ssc:certificates pg:certificates tls-certificates regular
```

Ideally the metric name should be called the same way blackbox-exporter calls it.

References:
- https://canonical-charmed-postgresql.readthedocs-hosted.com/14/how-to/enable-tls/

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.