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

admin: Replace 'metrics' with 'prometheus-client' #211

Merged
merged 4 commits into from
Dec 9, 2023
Merged

Conversation

olix0r
Copy link
Owner

@olix0r olix0r commented Dec 9, 2023

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).                                                                                                    
# TYPE process_start_time_seconds gauge
# 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.

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.
@olix0r olix0r merged commit a487ccd into main Dec 9, 2023
46 of 47 checks passed
@olix0r olix0r deleted the ver/prom-proc branch December 9, 2023 23:59
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