Skip to content

feat: the same run, as numbers a node_exporter can pick up - #40

Closed
AlexeyShalaev wants to merge 1 commit into
feat/command-hooksfrom
feat/cli-metrics
Closed

AlexeyShalaev wants to merge 1 commit into
feat/command-hooksfrom
feat/cli-metrics

Conversation

@AlexeyShalaev

Copy link
Copy Markdown
Member

Not in #32; argued for in the status comment. The OSS survey in docs/design/oss-research.md says most systems that partition PostgreSQL have no monitoring of it at all — they find out at 03:00, from an insert PostgreSQL rejected. A CronJob already runs this tool on a schedule, so the cheapest monitoring available is for that run to leave a textfile behind:

pg-partsmith plan -c partitions.yaml --output metrics > /var/lib/node_exporter/textfile/partsmith.prom
Command Series
plan pending_operations{table,kind}, pending_relations{table}, findings{table,severity}
inspect partitioned{table}, partitions{table}, detached_partitions{table}, oldest_detached_age_seconds{table}
validate config_valid{table}
apply applied_operations{table,operation}, issues{table}

All prefixed pg_partsmith_, all gauges — a one-shot job cannot own a counter, since the next run is a new process with no memory of this one. Every run stamps pg_partsmith_run_timestamp_seconds{command} so a textfile nothing refreshed reads as stale rather than as good news, and a converged table reports zeroes rather than nothing: a missing series and a zero are different alerts.

The numbers are read off the same envelope the JSON is, so a metric cannot disagree with what the same run printed. CommandResult.render now takes output= rather than a boolean, which is the only signature that moved.

The docs list the three alerts worth having, in the order they will save you. 10 unit tests + 1 against a real PostgreSQL.

Stacked on #39.

Most systems that partition PostgreSQL have no monitoring of it at all --
they find out at 03:00, from an insert PostgreSQL rejected. A CronJob
already runs this on a schedule, so the cheapest monitoring available is for
that run to leave a textfile behind.

--output metrics renders any command as Prometheus text exposition. plan
emits pending operations by kind and findings by severity, inspect the size
of the tree and the age of the oldest orphan, validate whether each table
still matches its configuration, apply what it did and what it could not.

Everything is a gauge: a one-shot job cannot own a counter, because the next
run is a new process with no memory of this one. Every run stamps
run_timestamp_seconds so a textfile nothing refreshed reads as stale rather
than as good news, and a converged table reports zeroes rather than nothing
-- a missing series and a zero are different alerts.

The numbers are read off the same envelope the JSON is, so a metric cannot
disagree with what the same run printed.
@AlexeyShalaev

Copy link
Copy Markdown
Member Author

Folded into #43, one PR for the whole epic; this branch stays for history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant