feat: Add granted label pg_locks collector#1246
Open
eugercek wants to merge 1 commit intoprometheus-community:masterfrom
Open
feat: Add granted label pg_locks collector#1246eugercek wants to merge 1 commit intoprometheus-community:masterfrom
eugercek wants to merge 1 commit intoprometheus-community:masterfrom
Conversation
Signed-off-by: Emin Umut Gercek <eumutgercek@gmail.com>
201b3fe to
9264e87
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
This PR adds
grantedlabel topg_locks_countmetric.Implements and Closes #657.
Implementation Choices:
Postgres version compatibility: I believe
pg_locks.grantedexists since postgres started to using Git. This is the commit thatsrc/backend/catalog/system_views.sqlfile is added andpg_locks.grantedexists at that time too. Nov 11 2003. Also in 7.3.0 release notespg_locksis mentioned. So It'll be available since 7.3.0, because of these I did not useinstance.version.GElike check, it's too old.Metric format: I did not touch current format it'll be cartesian product,
value=0will be exists. Only addedgrantedlabel.How bool is implemented: Since we already use data point's value for count of the current data point, like in below metric we know that there are 9 locks for
granted="true",mode="accesssharelock", I can't use the metric's value likepg_replication_slot_slot_is_active, so used a new label calledgranted.Because we use count value I couldn't use this standard. Found open-telemetry/opentelemetry-dotnet#4822 standard looks like using lowercase
"true" "false"so used that.Cardinality and Metric Count: Cardinality will be 2, just
granted="true|false". But metric count will be doubled because of the added 2 new dimension.Tests
Unit Test:
go test ./collector -run TestPGLocksCollector -v === RUN TestPGLocksCollector Metrics comparison ✔ 1 total assertion --- PASS: TestPGLocksCollector (0.00s) PASS ok github.com/prometheus-community/postgres_exporter/collector (cached)Manual test
Ran below:
curl -s http://localhost:9187/metrics | grep pg_locks | grep fooOutput