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

clustermesh-apiserver: add missing metrics and documentation #26070

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions Documentation/observability/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ so this functionality is currently opt-in, though we believe all of the Hubble
metrics conform to the OpenMetrics requirements.


.. _clustermesh_apiserver_metrics:

Cluster Mesh API Server Metrics
===============================

Expand Down Expand Up @@ -893,6 +895,8 @@ Options

This metric supports :ref:`Context Options<hubble_context_options>`.

.. _clustermesh_apiserver_metrics_reference:

clustermesh-apiserver
---------------------

Expand Down Expand Up @@ -923,6 +927,19 @@ Name Labels
``kvstore_initial_sync_completed`` ``scope``, ``source_cluster``, ``action`` Whether the initial synchronization from/to the kvstore has completed
======================================== ============================================ ========================================================

API Rate Limiting
~~~~~~~~~~~~~~~~~

============================================== ================================ ========================================================
Name Labels Description
============================================== ================================ ========================================================
``api_limiter_processed_requests_total`` ``api_call``, ``outcome`` Total number of API requests processed
``api_limiter_processing_duration_seconds`` ``api_call``, ``value`` Mean and estimated processing duration in seconds
``api_limiter_rate_limit`` ``api_call``, ``value`` Current rate limiting configuration (limit and burst)
``api_limiter_requests_in_flight`` ``api_call`` ``value`` Current and maximum allowed number of requests in flight
``api_limiter_wait_duration_seconds`` ``api_call``, ``value`` Mean, min, and max wait duration
============================================== ================================ ========================================================

.. _kvstoremesh_metrics_reference:

kvstoremesh
Expand Down
8 changes: 8 additions & 0 deletions Documentation/operations/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ Added Metrics
* ``cilium_operator_ipam_available_ips``
* ``cilium_operator_ipam_used_ips``
* ``cilium_operator_ipam_needed_ips``
* ``kvstore_sync_queue_size``
* ``kvstore_initial_sync_completed``

You can now additionally configure the *clustermesh-apiserver* to expose a set
of metrics about the synchronization process, kvstore operations, and the sidecar
etcd instance. Please refer to :ref:`clustermesh_apiserver_metrics` and
:ref:`the clustermesh-apiserver metrics reference<clustermesh_apiserver_metrics_reference>`
for more information.

Deprecated Metrics
~~~~~~~~~~~~~~~~~~
Expand Down
10 changes: 8 additions & 2 deletions clustermesh-apiserver/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package metrics
import (
"errors"
"net/http"
"regexp"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
Expand Down Expand Up @@ -63,11 +64,16 @@ func (mm *metricsManager) Start(hive.HookContext) error {
log.Info("Registering metrics")

mm.registry.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
mm.registry.MustRegister(collectors.NewGoCollector())
mm.registry.MustRegister(collectors.NewGoCollector(
collectors.WithGoCollectorRuntimeMetrics(
collectors.GoRuntimeMetricsRule{Matcher: regexp.MustCompile(`^/sched/latencies:seconds`)},
),
))
// Constructing the legacy metrics and register them at the metrics global variable.
// This is a hack until we can unify this metrics manager with the metrics.Registry.
metrics.NewLegacyMetrics()
mm.registry.MustRegister(
metrics.VersionMetric,
metrics.KVStoreOperationsDuration,
metrics.KVStoreEventsQueueDuration,
metrics.KVStoreQuorumErrors,
Expand All @@ -77,7 +83,7 @@ func (mm *metricsManager) Start(hive.HookContext) error {
metrics.APILimiterWaitDuration,
metrics.APILimiterRequestsInFlight,
metrics.APILimiterRateLimit,
metrics.APILimiterAdjustmentFactor,
metrics.APILimiterProcessedRequests,
)

mux := http.NewServeMux()
Expand Down