-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
admin: Replace 'metrics' with 'prometheus-client' (#211)
* admin: Replace 'metrics' with 'prometheus-client' This change replaces the `metrics` feature with a `prometheus-client` feature. prometheus-client is the official Prometheus-org OpenMetrics implementation. The watch-pods example has been updated to export prometheus metrics: :; curl localhost:8080/metrics # HELP watch_pods_events Number of events observed. # TYPE watch_pods_events counter watch_pods_events_total{op="apply"} 0 watch_pods_events_total{op="delete"} 0 watch_pods_events_total{op="restart"} 1 # HELP watch_pods_current_pods Number of Pods being observed. # TYPE watch_pods_current_pods gauge watch_pods_current_pods 10 # HELP watch_pods_pods Total number of unique pods observed. # TYPE watch_pods_pods counter watch_pods_pods_total 10 # HELP process_start_time_seconds Time that the process started (in seconds since the UNIX epoch). # UNIT process_start_time_seconds seconds process_start_time_seconds 1702159727.213669 # HELP process_uptime_seconds Total time since the process started (in seconds) # TYPE process_uptime_seconds counter # UNIT process_uptime_seconds seconds process_uptime_seconds_total 2.712104395 # HELP process_cpu_seconds Total user and system CPU time spent in seconds # TYPE process_cpu_seconds counter # UNIT process_cpu_seconds seconds process_cpu_seconds_total 0.73 # HELP process_virtual_memory_bytes Virtual memory size in bytes # TYPE process_virtual_memory_bytes gauge # UNIT process_virtual_memory_bytes bytes process_virtual_memory_bytes 1208897536 # HELP process_resident_memory_bytes Resident memory size in bytes # TYPE process_resident_memory_bytes gauge # UNIT process_resident_memory_bytes bytes process_resident_memory_bytes 21114880 # HELP process_open_fds Number of open file descriptors # TYPE process_open_fds gauge process_open_fds 16 # HELP process_max_fds Maximum number of open file descriptors # TYPE process_max_fds gauge process_max_fds 1048576 # HELP process_threads Number of OS threads in the process. # TYPE process_threads gauge process_threads 18 # EOF Furthermore, `admin::Builder` APIs are updated to consume the builder and return it by-value (instead of handling references, which does not work well when chaining configuration). This is based on the experience of integrating prometheus into the example. Additionally, the admin server has been updated to use spawn_blocking for non-probe handlers. To support this, a new kubert-prometheus-process crate has been added, including only the procfs bindings needed to support the process metrics. This crate is completely decoupled from kubert. It is based on the process metrics implementation in the linkerd2-proxy repo. * fixup ci * Improve docs * fixup! Improve docs
- Loading branch information
Showing
16 changed files
with
657 additions
and
159 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Release kubernetes-prometheus-process | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- .github/workflows/release-prometheus-process.yml | ||
push: | ||
tags: | ||
- 'kubert-prometheus-process/*' | ||
|
||
env: | ||
CARGO_INCREMENTAL: 0 | ||
CARGO_NET_RETRY: 10 | ||
RUSTUP_MAX_RETRIES: 10 | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
cleanup: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: write | ||
steps: | ||
- uses: styfle/cancel-workflow-action@01ce38bf961b4e243a6342cbade0dbc8ba3f0432 | ||
with: | ||
all_but_latest: true | ||
access_token: ${{ github.token }} | ||
|
||
meta: | ||
timeout-minutes: 5 | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/linkerd/dev:v42-rust | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
- id: meta | ||
shell: bash | ||
run: | | ||
ref="${{ github.ref }}" | ||
if [[ "$ref" == refs/tags/kubert-prometheus-process/* ]]; then | ||
version="${ref##refs/tags/kubert-prometheus-process/}" | ||
crate=$(just-cargo crate-version kubert-prometheus-process) | ||
if [[ "$crate" != "$version" ]]; then | ||
echo "::error ::Crate version $crate does not match tag $version" >&2 | ||
exit 1 | ||
fi | ||
( echo version="$version" | ||
echo mode=release | ||
) >> "$GITHUB_OUTPUT" | ||
else | ||
sha="${{ github.sha }}" | ||
( echo version="$(just-cargo crate-version kubert-prometheus-process)-git-${sha:0:7}" | ||
echo mode=test | ||
) >> "$GITHUB_OUTPUT" | ||
fi | ||
outputs: | ||
mode: ${{ steps.meta.outputs.mode }} | ||
version: ${{ steps.meta.outputs.version }} | ||
|
||
release: | ||
needs: [meta] | ||
permissions: | ||
contents: write | ||
timeout-minutes: 5 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- if: needs.meta.outputs.mode == 'release' | ||
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 | ||
with: | ||
name: ${{ needs.meta.outputs.version }} | ||
generate_release_notes: true | ||
|
||
crate: | ||
# Only publish the crate after the rest of the release succeeds. | ||
needs: [meta, release] | ||
timeout-minutes: 10 | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/linkerd/dev:v42-rust | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
- run: cargo publish --package=kubert-prometheus-process --dry-run | ||
- if: needs.meta.outputs.mode == 'release' | ||
run: cargo publish --package=kubert-prometheus-process --token=${{ secrets.CRATESIO_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
[workspace] | ||
resolver = "2" | ||
default-members = ["kubert"] | ||
default-members = ["kubert", "kubert-prometheus-process"] | ||
members = [ | ||
"kubert", | ||
"kubert-prometheus-process", | ||
"examples", | ||
] |
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
Oops, something went wrong.