Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

identity: Update metrics to follow OpenMetrics best practices #2617

Merged
merged 4 commits into from
Jan 5, 2024

Conversation

olix0r
Copy link
Member

@olix0r olix0r commented Jan 5, 2024

In preparation to add SPIRE integration, this change extracts the identity certificate metrics from the control plane client, moving them into the linkerd-identity crate, as an implementation of Credentials trait (which is updated to include an expiry value). The app::identity module is updated to instrument the credentials store with metrics.

A identity_cert_refresh_timestamp_seconds metric is added to report the time when the identity certificate was last updated.

Breaking changes: identity_cert_refresh_count is renamed to dentity_cert_refreshes_total to follow OpenMetrics best practices, where counters must end with _total.

I've searched GitHub, and the only external references to this metric are in our documentation (which will have to be updated).


# HELP identity_cert_expiration_timestamp_seconds Time when the this proxy's current mTLS identity certificate will expire (in seconds since the UNIX epoch).
# TYPE identity_cert_expiration_timestamp_seconds gauge
# UNIT identity_cert_expiration_timestamp_seconds seconds
identity_cert_expiration_timestamp_seconds 1704500155.0
# HELP identity_cert_refresh_timestamp_seconds Time when the this proxy's current mTLS identity certificate were last updated.
# TYPE identity_cert_refresh_timestamp_seconds gauge
# UNIT identity_cert_refresh_timestamp_seconds seconds
identity_cert_refresh_timestamp_seconds 1704413735.7489427
# HELP identity_cert_refreshes The total number of times this proxy's mTLS identity certificate has been refreshed by the Identity provider..
# TYPE identity_cert_refreshes counter
identity_cert_refreshes_total{result="ok"} 1
identity_cert_refreshes_total{result="error"} 0

In preparation to add SPIRE integration, this change extracts the identity
certificate metrics from the control plane client, moving them into the
linkerd-identity crate, as an implementation of Credentials trait (which is
updated to include an expiry value). The app::identity module is updated to
instrument the credentials store with metrics.

A `identity_cert_refresh_timestamp_seconds` metric is added to report the time
when the identity certificate was last updated.

**Backwards-incompatible changes**: `identity_cert_refresh_count` is renamed to
`dentity_cert_refreshes_total` to follow OpenMetrics best practices, where
counters must end with `_total`.

I've searched GitHub, and the only external references to this metric are in our
documentation (which will have to be updated).

---

    # HELP identity_cert_expiration_timestamp_seconds Time when the this proxy's current mTLS identity certificate will expire (in seconds since the UNIX epoch).
    # TYPE identity_cert_expiration_timestamp_seconds gauge
    # UNIT identity_cert_expiration_timestamp_seconds seconds
    identity_cert_expiration_timestamp_seconds 1704500155.0
    # HELP identity_cert_refresh_timestamp_seconds Time when the this proxy's current mTLS identity certificate were last updated.
    # TYPE identity_cert_refresh_timestamp_seconds gauge
    # UNIT identity_cert_refresh_timestamp_seconds seconds
    identity_cert_refresh_timestamp_seconds 1704413735.7489427
    # HELP identity_cert_refreshes The total number of times this proxy's mTLS identity certificate has been refreshed by the Identity provider..
    # TYPE identity_cert_refreshes counter
    identity_cert_refreshes_total 1
@olix0r olix0r requested a review from a team as a code owner January 5, 2024 00:34
Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Merging #2617 (3f4b7ae) into main (81cbb58) will decrease coverage by 0.04%.
Report is 10 commits behind head on main.
The diff coverage is 91.48%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2617      +/-   ##
==========================================
- Coverage   67.85%   67.82%   -0.04%     
==========================================
  Files         328      328              
  Lines       14980    14994      +14     
==========================================
+ Hits        10164    10169       +5     
- Misses       4816     4825       +9     
Files Coverage Δ
linkerd/app/src/identity.rs 90.47% <100.00%> (ø)
linkerd/app/src/lib.rs 88.57% <100.00%> (-0.11%) ⬇️
linkerd/identity/src/credentials.rs 0.00% <ø> (ø)
linkerd/identity/src/lib.rs 100.00% <ø> (ø)
linkerd/meshtls/boring/src/creds/store.rs 95.00% <ø> (ø)
linkerd/meshtls/rustls/src/creds/store.rs 92.42% <ø> (ø)
linkerd/meshtls/src/creds.rs 100.00% <100.00%> (ø)
linkerd/meshtls/tests/util.rs 96.83% <100.00%> (+0.06%) ⬆️
linkerd/proxy/identity-client/src/certify.rs 89.18% <100.00%> (-0.43%) ⬇️
linkerd/identity/src/metrics.rs 86.66% <86.66%> (ø)

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81cbb58...3f4b7ae. Read the comment docs.

Copy link
Member

@zaharidichev zaharidichev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a small comment. Making that a wrapper that implemented Credentials is quite neat

linkerd/identity/src/metrics.rs Outdated Show resolved Hide resolved
@olix0r olix0r merged commit 97bb771 into main Jan 5, 2024
27 checks passed
@olix0r olix0r deleted the ver/id-metrics branch January 5, 2024 17:05
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Jan 26, 2024
* build(deps): bump itertools from 0.10.5 to 0.11.0 (linkerd/linkerd2-proxy#2594)
* build(deps): bump async-trait from 0.1.68 to 0.1.75 (linkerd/linkerd2-proxy#2595)
* pool: Decompose the pool and balancer crates (linkerd/linkerd2-proxy#2597)
* balance: Move endpoint state gauge into balancer (linkerd/linkerd2-proxy#2598)
* cargo: Remove cyclic meshtls dependency (linkerd/linkerd2-proxy#2602)
* build(deps): bump mime from 0.3.16 to 0.3.17 (linkerd/linkerd2-proxy#2599)
* build(deps): bump parking_lot_core from 0.9.5 to 0.9.9 (linkerd/linkerd2-proxy#2600)
* build(deps): bump prost-build from 0.12.1 to 0.12.3 (linkerd/linkerd2-proxy#2601)
* outbound: Update route backend metrics implementation (linkerd/linkerd2-proxy#2603)
* deps: Update to indexmap v2 (linkerd/linkerd2-proxy#2604)
* build(deps): bump actions/download-artifact from 3.0.2 to 4.1.0 (linkerd/linkerd2-proxy#2569)
* deps: h2 v0.3.22 (linkerd/linkerd2-proxy#2605)
* tracing: Ensure that INFO-level spans are preserved (linkerd/linkerd2-proxy#2611)
* build(deps): bump serde from 1.0.185 to 1.0.193 (linkerd/linkerd2-proxy#2606)
* build(deps): bump tokio-boring from 3.0.4 to 3.1.0 (linkerd/linkerd2-proxy#2607)
* build(deps): bump deranged from 0.3.10 to 0.3.11 (linkerd/linkerd2-proxy#2608)
* build(deps): bump axum from 0.6.11 to 0.6.20 (linkerd/linkerd2-proxy#2609)
* build(deps): bump proc-macro2 from 1.0.69 to 1.0.74 (linkerd/linkerd2-proxy#2610)
* build(deps): bump ahash from 0.8.6 to 0.8.7 (linkerd/linkerd2-proxy#2612)
* build(deps): bump cc from 1.0.79 to 1.0.83 (linkerd/linkerd2-proxy#2613)
* build(deps): bump scopeguard from 1.1.0 to 1.2.0 (linkerd/linkerd2-proxy#2614)
* build(deps): bump io-lifetimes from 1.0.10 to 1.0.11 (linkerd/linkerd2-proxy#2616)
* build(deps): bump pem from 3.0.2 to 3.0.3 (linkerd/linkerd2-proxy#2615)
* build(deps): bump anyhow from 1.0.76 to 1.0.79 (linkerd/linkerd2-proxy#2619)
* build(deps): bump socket2 from 0.4.9 to 0.5.5 (linkerd/linkerd2-proxy#2622)
* build(deps): bump libfuzzer-sys from 0.4.6 to 0.4.7 (linkerd/linkerd2-proxy#2620)
* build(deps): bump tempfile from 3.5.0 to 3.6.0 (linkerd/linkerd2-proxy#2621)
* build(deps): bump ryu from 1.0.13 to 1.0.16 (linkerd/linkerd2-proxy#2623)
* identity: Update metrics to follow OpenMetrics best practices (linkerd/linkerd2-proxy#2617)
* build(deps): bump tokio from 1.34.0 to 1.35.1 (linkerd/linkerd2-proxy#2627)
* build(deps): bump tracing from 0.1.37 to 0.1.40 (linkerd/linkerd2-proxy#2628)
* build(deps): bump slab from 0.4.8 to 0.4.9 (linkerd/linkerd2-proxy#2629)
* build(deps): bump unicode-bidi from 0.3.11 to 0.3.14 (linkerd/linkerd2-proxy#2630)
* build(deps): bump tokio-stream from 0.1.12 to 0.1.14 (linkerd/linkerd2-proxy#2632)
* build(deps): bump boring-sys from 3.0.4 to 3.1.0 (linkerd/linkerd2-proxy#2633)
* build(deps): bump rcgen from 0.11.3 to 0.12.0 (linkerd/linkerd2-proxy#2635)
* build(deps): bump trust-dns-resolver from 0.22.0 to 0.23.2 (linkerd/linkerd2-proxy#2631)
* build(deps): bump memchr from 2.6.4 to 2.7.1 (linkerd/linkerd2-proxy#2637)
* build(deps): bump pin-project from 1.0.12 to 1.1.3 (linkerd/linkerd2-proxy#2638)
* build(deps): bump futures from 0.3.28 to 0.3.30 (linkerd/linkerd2-proxy#2639)
* build(deps): bump rangemap from 1.3.0 to 1.4.0 (linkerd/linkerd2-proxy#2640)
* build(deps): bump actions/download-artifact from 4.1.0 to 4.1.1 (linkerd/linkerd2-proxy#2636)
* build(deps): bump thingbuf from 0.1.3 to 0.1.4 (linkerd/linkerd2-proxy#2642)
* build(deps): bump rustix from 0.36.16 to 0.36.17 (linkerd/linkerd2-proxy#2643)
* build(deps): bump httpdate from 1.0.2 to 1.0.3 (linkerd/linkerd2-proxy#2645)
* build(deps): bump num_cpus from 1.15.0 to 1.16.0 (linkerd/linkerd2-proxy#2646)
* Change inbound port check log level to debug. (linkerd/linkerd2-proxy#2625)
* docs: Fix bad reference link (linkerd/linkerd2-proxy#2647)
* identity: add spire identity client (linkerd/linkerd2-proxy#2580)
* config:add spire client config (linkerd/linkerd2-proxy#2641)
* discovery: consume server_name and UriLikeIdentity from proto (linkerd/linkerd2-proxy#2618)
* build(deps): bump h2 from 0.3.22 to 0.3.24 (linkerd/linkerd2-proxy#2660)
* build(deps): bump procfs from 0.15.1 to 0.16.0 (linkerd/linkerd2-proxy#2649)
* build(deps): bump async-trait from 0.1.75 to 0.1.77 (linkerd/linkerd2-proxy#2650)
* build(deps): bump semver from 1.0.20 to 1.0.21 (linkerd/linkerd2-proxy#2651)
* build(deps): bump smallvec from 1.10.0 to 1.13.1 (linkerd/linkerd2-proxy#2661)
* build(deps): bump either from 1.8.1 to 1.9.0 (linkerd/linkerd2-proxy#2652)
* build(deps): bump actions/upload-artifact from 4.0.0 to 4.2.0 (linkerd/linkerd2-proxy#2658)
* build(deps): bump shlex from 1.1.0 to 1.3.0 (linkerd/linkerd2-proxy#2664)
* build(deps): bump DavidAnson/markdownlint-cli2-action (linkerd/linkerd2-proxy#2656)
* build(deps): bump EmbarkStudios/cargo-deny-action from 1.5.5 to 1.5.10 (linkerd/linkerd2-proxy#2665)
* build(deps): bump serde from 1.0.193 to 1.0.195 (linkerd/linkerd2-proxy#2670)
* build(deps): bump clang-sys from 1.6.0 to 1.7.0 (linkerd/linkerd2-proxy#2668)
* build(deps): bump zerocopy from 0.7.31 to 0.7.32 (linkerd/linkerd2-proxy#2666)
* build(deps): bump unicode-ident from 1.0.6 to 1.0.12 (linkerd/linkerd2-proxy#2667)
* build(deps): bump actions/upload-artifact from 4.2.0 to 4.3.0 (linkerd/linkerd2-proxy#2671)
* build(deps): bump prettyplease from 0.2.15 to 0.2.16 (linkerd/linkerd2-proxy#2673)
* build(deps): bump getrandom from 0.2.8 to 0.2.12 (linkerd/linkerd2-proxy#2674)
* build(deps): bump which from 4.4.0 to 4.4.2 (linkerd/linkerd2-proxy#2675)
* build(deps): bump sharded-slab from 0.1.4 to 0.1.7 (linkerd/linkerd2-proxy#2676)
* build(deps): bump EmbarkStudios/cargo-deny-action from 1.5.10 to 1.5.11 (linkerd/linkerd2-proxy#2672)
* build(deps): bump tj-actions/changed-files from 41.0.1 to 42.0.0 (linkerd/linkerd2-proxy#2657)

Signed-off-by: Oliver Gould <[email protected]>
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Jan 26, 2024
* proxy: v2.220.0

* build(deps): bump itertools from 0.10.5 to 0.11.0 (linkerd/linkerd2-proxy#2594)
* build(deps): bump async-trait from 0.1.68 to 0.1.75 (linkerd/linkerd2-proxy#2595)
* pool: Decompose the pool and balancer crates (linkerd/linkerd2-proxy#2597)
* balance: Move endpoint state gauge into balancer (linkerd/linkerd2-proxy#2598)
* cargo: Remove cyclic meshtls dependency (linkerd/linkerd2-proxy#2602)
* build(deps): bump mime from 0.3.16 to 0.3.17 (linkerd/linkerd2-proxy#2599)
* build(deps): bump parking_lot_core from 0.9.5 to 0.9.9 (linkerd/linkerd2-proxy#2600)
* build(deps): bump prost-build from 0.12.1 to 0.12.3 (linkerd/linkerd2-proxy#2601)
* outbound: Update route backend metrics implementation (linkerd/linkerd2-proxy#2603)
* deps: Update to indexmap v2 (linkerd/linkerd2-proxy#2604)
* build(deps): bump actions/download-artifact from 3.0.2 to 4.1.0 (linkerd/linkerd2-proxy#2569)
* deps: h2 v0.3.22 (linkerd/linkerd2-proxy#2605)
* tracing: Ensure that INFO-level spans are preserved (linkerd/linkerd2-proxy#2611)
* build(deps): bump serde from 1.0.185 to 1.0.193 (linkerd/linkerd2-proxy#2606)
* build(deps): bump tokio-boring from 3.0.4 to 3.1.0 (linkerd/linkerd2-proxy#2607)
* build(deps): bump deranged from 0.3.10 to 0.3.11 (linkerd/linkerd2-proxy#2608)
* build(deps): bump axum from 0.6.11 to 0.6.20 (linkerd/linkerd2-proxy#2609)
* build(deps): bump proc-macro2 from 1.0.69 to 1.0.74 (linkerd/linkerd2-proxy#2610)
* build(deps): bump ahash from 0.8.6 to 0.8.7 (linkerd/linkerd2-proxy#2612)
* build(deps): bump cc from 1.0.79 to 1.0.83 (linkerd/linkerd2-proxy#2613)
* build(deps): bump scopeguard from 1.1.0 to 1.2.0 (linkerd/linkerd2-proxy#2614)
* build(deps): bump io-lifetimes from 1.0.10 to 1.0.11 (linkerd/linkerd2-proxy#2616)
* build(deps): bump pem from 3.0.2 to 3.0.3 (linkerd/linkerd2-proxy#2615)
* build(deps): bump anyhow from 1.0.76 to 1.0.79 (linkerd/linkerd2-proxy#2619)
* build(deps): bump socket2 from 0.4.9 to 0.5.5 (linkerd/linkerd2-proxy#2622)
* build(deps): bump libfuzzer-sys from 0.4.6 to 0.4.7 (linkerd/linkerd2-proxy#2620)
* build(deps): bump tempfile from 3.5.0 to 3.6.0 (linkerd/linkerd2-proxy#2621)
* build(deps): bump ryu from 1.0.13 to 1.0.16 (linkerd/linkerd2-proxy#2623)
* identity: Update metrics to follow OpenMetrics best practices (linkerd/linkerd2-proxy#2617)
* build(deps): bump tokio from 1.34.0 to 1.35.1 (linkerd/linkerd2-proxy#2627)
* build(deps): bump tracing from 0.1.37 to 0.1.40 (linkerd/linkerd2-proxy#2628)
* build(deps): bump slab from 0.4.8 to 0.4.9 (linkerd/linkerd2-proxy#2629)
* build(deps): bump unicode-bidi from 0.3.11 to 0.3.14 (linkerd/linkerd2-proxy#2630)
* build(deps): bump tokio-stream from 0.1.12 to 0.1.14 (linkerd/linkerd2-proxy#2632)
* build(deps): bump boring-sys from 3.0.4 to 3.1.0 (linkerd/linkerd2-proxy#2633)
* build(deps): bump rcgen from 0.11.3 to 0.12.0 (linkerd/linkerd2-proxy#2635)
* build(deps): bump trust-dns-resolver from 0.22.0 to 0.23.2 (linkerd/linkerd2-proxy#2631)
* build(deps): bump memchr from 2.6.4 to 2.7.1 (linkerd/linkerd2-proxy#2637)
* build(deps): bump pin-project from 1.0.12 to 1.1.3 (linkerd/linkerd2-proxy#2638)
* build(deps): bump futures from 0.3.28 to 0.3.30 (linkerd/linkerd2-proxy#2639)
* build(deps): bump rangemap from 1.3.0 to 1.4.0 (linkerd/linkerd2-proxy#2640)
* build(deps): bump actions/download-artifact from 4.1.0 to 4.1.1 (linkerd/linkerd2-proxy#2636)
* build(deps): bump thingbuf from 0.1.3 to 0.1.4 (linkerd/linkerd2-proxy#2642)
* build(deps): bump rustix from 0.36.16 to 0.36.17 (linkerd/linkerd2-proxy#2643)
* build(deps): bump httpdate from 1.0.2 to 1.0.3 (linkerd/linkerd2-proxy#2645)
* build(deps): bump num_cpus from 1.15.0 to 1.16.0 (linkerd/linkerd2-proxy#2646)
* Change inbound port check log level to debug. (linkerd/linkerd2-proxy#2625)
* docs: Fix bad reference link (linkerd/linkerd2-proxy#2647)
* identity: add spire identity client (linkerd/linkerd2-proxy#2580)
* config:add spire client config (linkerd/linkerd2-proxy#2641)
* discovery: consume server_name and UriLikeIdentity from proto (linkerd/linkerd2-proxy#2618)
* build(deps): bump h2 from 0.3.22 to 0.3.24 (linkerd/linkerd2-proxy#2660)
* build(deps): bump procfs from 0.15.1 to 0.16.0 (linkerd/linkerd2-proxy#2649)
* build(deps): bump async-trait from 0.1.75 to 0.1.77 (linkerd/linkerd2-proxy#2650)
* build(deps): bump semver from 1.0.20 to 1.0.21 (linkerd/linkerd2-proxy#2651)
* build(deps): bump smallvec from 1.10.0 to 1.13.1 (linkerd/linkerd2-proxy#2661)
* build(deps): bump either from 1.8.1 to 1.9.0 (linkerd/linkerd2-proxy#2652)
* build(deps): bump actions/upload-artifact from 4.0.0 to 4.2.0 (linkerd/linkerd2-proxy#2658)
* build(deps): bump shlex from 1.1.0 to 1.3.0 (linkerd/linkerd2-proxy#2664)
* build(deps): bump DavidAnson/markdownlint-cli2-action (linkerd/linkerd2-proxy#2656)
* build(deps): bump EmbarkStudios/cargo-deny-action from 1.5.5 to 1.5.10 (linkerd/linkerd2-proxy#2665)
* build(deps): bump serde from 1.0.193 to 1.0.195 (linkerd/linkerd2-proxy#2670)
* build(deps): bump clang-sys from 1.6.0 to 1.7.0 (linkerd/linkerd2-proxy#2668)
* build(deps): bump zerocopy from 0.7.31 to 0.7.32 (linkerd/linkerd2-proxy#2666)
* build(deps): bump unicode-ident from 1.0.6 to 1.0.12 (linkerd/linkerd2-proxy#2667)
* build(deps): bump actions/upload-artifact from 4.2.0 to 4.3.0 (linkerd/linkerd2-proxy#2671)
* build(deps): bump prettyplease from 0.2.15 to 0.2.16 (linkerd/linkerd2-proxy#2673)
* build(deps): bump getrandom from 0.2.8 to 0.2.12 (linkerd/linkerd2-proxy#2674)
* build(deps): bump which from 4.4.0 to 4.4.2 (linkerd/linkerd2-proxy#2675)
* build(deps): bump sharded-slab from 0.1.4 to 0.1.7 (linkerd/linkerd2-proxy#2676)
* build(deps): bump EmbarkStudios/cargo-deny-action from 1.5.10 to 1.5.11 (linkerd/linkerd2-proxy#2672)
* build(deps): bump tj-actions/changed-files from 41.0.1 to 42.0.0 (linkerd/linkerd2-proxy#2657)

Signed-off-by: Oliver Gould <[email protected]>

* Bump helm version

* +changes

* Update CHANGES.md

Co-authored-by: Alejandro Pedraza <[email protected]>

---------

Signed-off-by: Oliver Gould <[email protected]>
Co-authored-by: Alejandro Pedraza <[email protected]>
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.

2 participants