Skip to content

Commit

Permalink
Rename cluster to storage_cluster_id for apiserver_storage_size_b…
Browse files Browse the repository at this point in the history
…ytes metric

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
  • Loading branch information
dims committed Apr 11, 2024
1 parent be4b717 commit fb5140f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var (
},
[]string{"endpoint"},
)
storageSizeDescription = compbasemetrics.NewDesc("apiserver_storage_size_bytes", "Size of the storage database file physically allocated in bytes.", []string{"cluster"}, nil, compbasemetrics.STABLE, "")
storageSizeDescription = compbasemetrics.NewDesc("apiserver_storage_size_bytes", "Size of the storage database file physically allocated in bytes.", []string{"storage_cluster_id"}, nil, compbasemetrics.STABLE, "")
storageMonitor = &monitorCollector{monitorGetter: func() ([]Monitor, error) { return nil, nil }}
etcdEventsReceivedCounts = compbasemetrics.NewCounterVec(
&compbasemetrics.CounterOpts{
Expand Down Expand Up @@ -288,21 +288,21 @@ func (c *monitorCollector) CollectWithStability(ch chan<- compbasemetrics.Metric
}

for i, m := range monitors {
cluster := fmt.Sprintf("etcd-%d", i)
storageClusterID := fmt.Sprintf("etcd-%d", i)

klog.V(4).InfoS("Start collecting storage metrics", "cluster", cluster)
klog.V(4).InfoS("Start collecting storage metrics", "storage_cluster_id", storageClusterID)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
metrics, err := m.Monitor(ctx)
cancel()
m.Close()
if err != nil {
klog.InfoS("Failed to get storage metrics", "cluster", cluster, "err", err)
klog.InfoS("Failed to get storage metrics", "storage_cluster_id", storageClusterID, "err", err)
continue
}

metric, err := compbasemetrics.NewConstMetric(storageSizeDescription, compbasemetrics.GaugeValue, float64(metrics.Size), cluster)
metric, err := compbasemetrics.NewConstMetric(storageSizeDescription, compbasemetrics.GaugeValue, float64(metrics.Size), storageClusterID)
if err != nil {
klog.ErrorS(err, "Failed to create metric", "cluster", cluster)
klog.ErrorS(err, "Failed to create metric", "storage_cluster_id", storageClusterID)
}
ch <- metric
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func TestStorageSizeCollector(t *testing.T) {
err: nil,
want: `# HELP apiserver_storage_size_bytes [STABLE] Size of the storage database file physically allocated in bytes.
# TYPE apiserver_storage_size_bytes gauge
apiserver_storage_size_bytes{cluster="etcd-0"} 1e+09
apiserver_storage_size_bytes{storage_cluster_id="etcd-0"} 1e+09
`,
},
{
Expand Down
2 changes: 1 addition & 1 deletion test/instrumentation/documentation/documentation-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3209,7 +3209,7 @@
type: Custom
stabilityLevel: ALPHA
labels:
- cluster
- storage_cluster_id
- name: terminated_watchers_total
namespace: apiserver
help: Counter of watchers closed due to unresponsiveness broken by resource type.
Expand Down
4 changes: 2 additions & 2 deletions test/instrumentation/documentation/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: >-

## Metrics (v1.30)

<!-- (auto-generated 2024 Jan 14) -->
<!-- (auto-generated 2024 Apr 11) -->
<!-- (auto-generated v1.30) -->
This page details the metrics that different Kubernetes components export. You can query the metrics endpoint for these
components using an HTTP scrape, and fetch the current metrics data in Prometheus format.
Expand Down Expand Up @@ -1094,7 +1094,7 @@ Alpha metrics do not have any API guarantees. These metrics must be used at your
<ul>
<li><label class="metric_detail">Stability Level:</label><span class="metric_stability_level">ALPHA</span></li>
<li data-type="custom"><label class="metric_detail">Type:</label> <span class="metric_type">Custom</span></li>
<li class="metric_labels_varying"><label class="metric_detail">Labels:</label><span class="metric_label">cluster</span></li></ul>
<li class="metric_labels_varying"><label class="metric_detail">Labels:</label><span class="metric_label">storage_cluster_id</span></li></ul>
</div><div class="metric" data-stability="alpha">
<div class="metric_name">apiserver_storage_transformation_duration_seconds</div>
<div class="metric_help">Latencies in seconds of value transformation operations.</div>
Expand Down
2 changes: 1 addition & 1 deletion test/instrumentation/testdata/stable-metrics-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
type: Custom
stabilityLevel: STABLE
labels:
- cluster
- storage_cluster_id
- name: container_cpu_usage_seconds_total
help: Cumulative cpu time consumed by the container in core-seconds
type: Custom
Expand Down

0 comments on commit fb5140f

Please sign in to comment.