Skip to content

Commit addcb4b

Browse files
richabankerdashpole
andcommitted
Add Beta and Internal metric stability levels, update deprecation timelines
Co-authored-by: David Ashpole <[email protected]>
1 parent 445db32 commit addcb4b

File tree

1 file changed

+67
-8
lines changed

1 file changed

+67
-8
lines changed

contributors/devel/sig-instrumentation/metric-stability.md

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
## Stability Classes
66

7-
There are currently two stability classes for metrics: (1) Alpha, (2) Stable. These classes are intended to make explicit the API contract between the control-plane and the consumer of control-plane metrics.
7+
There are currently four stability classes for metrics: (1) Alpha, (2) Beta, (3) Stable, and (4) Internal. These classes are intended to make the API contract between the control-plane and the consumer of control-plane metrics explicit.
88

99
### Alpha
1010

1111
__Alpha__ metrics have __*no*__ stability guarantees; as such they can be modified or deleted at any time. All Kubernetes metrics begin as alpha metrics.
1212

13-
An example of an alpha metric follows:
13+
Alpha metrics are new metrics with minimal or no production experience. There is no expectation for users to monitor them yet, as they may belong to Alpha features or haven't yet proven their long-term value. Due to the lack of production feedback, there is a high probability these metrics will change or be removed entirely.
14+
15+
An example of an alpha metric is as follows:
1416

1517
```go
1618
var alphaMetricDefinition = kubemetrics.CounterOpts{
@@ -21,10 +23,37 @@ var alphaMetricDefinition = kubemetrics.CounterOpts{
2123
}
2224
```
2325

26+
### Beta
27+
28+
__Beta__ metrics have a looser stability contract than their stable counterparts. No labels can be removed from beta metrics during their lifetime, however, labels can be added while the metric is in the beta stage.
29+
Beta metrics can also be marked as __deprecated__ for a future Kubernetes version.
30+
31+
Beta metrics are metrics that have been validated in production and deemed useful. While not yet critical, it is recommended that users begin monitoring them. The expectation is that metrics for GA features and critical metrics for Beta features eventually graduate to this level. While less likely than Alpha, these metrics might still change if they are tightly coupled to internal implementation details.
32+
33+
An example of a beta metric follows:
34+
35+
```go
36+
var betaMetricDefinition = kubemetrics.CounterOpts{
37+
Name: "some_beta_metric",
38+
Help: "some description",
39+
StabilityLevel: kubemetrics.BETA,
40+
DeprecatedVersion: "1.15", // this is a custom metadata field
41+
}
42+
```
43+
44+
By the beta stability contract, we mean:
45+
46+
1. the metric will not be deleted without graduating to stable first or being deprecated for a minimum of 1 release (or 4 months, whichever is longer)
47+
2. the type of metric will not be modified
48+
3. no labels can be removed from this metric
49+
4. labels **can** be added to this metric while in beta
50+
2451
### Stable
2552

2653
__Stable__ metrics can be guaranteed to *not change*, except that the metric may become marked deprecated for a future Kubernetes version.
2754

55+
Stable metrics are crucial metrics covering core Kubernetes features that are expected to change very rarely, if ever. Users should prioritize monitoring these metrics to understand the fundamental health and performance of their clusters.
56+
2857
An example of a stable metric follows:
2958

3059
```go
@@ -38,14 +67,35 @@ var deprecatedMetricDefinition = kubemetrics.CounterOpts{
3867

3968
By *not change*, we mean three things:
4069

41-
1. the metric itself will not be deleted ([or renamed](#metric-renaming))
70+
1. the metric itself will not be deleted ([or renamed](#metric-renaming)) without being deprecated for a minimum of 3 releases (or 9 months, whichever is longer)
4271
2. the type of metric will not be modified
4372
3. no labels can be added **or** removed from this metric
4473

4574
From an ingestion point of view, it is backwards-compatible to add or remove possible __values__ for labels which already do exist (but __not__ labels themselves). Therefore, adding or removing __values__ from an existing label is permissible. Stable metrics can also be marked as __deprecated__ for a future Kubernetes version, since this is a metadata field and does not actually change the metric itself.
4675

4776
**Removing or adding labels from stable metrics is not permissible.** In order to add/remove a label to an existing stable metric, one would have to introduce a new metric and deprecate the stable one; otherwise this would violate compatibility agreements.
4877

78+
### Internal
79+
80+
__Internal__ metrics are intended for metrics that are used for internal purposes only and are not meant to be consumed by end users. These metrics have __*no*__ stability guarantees and can be modified or deleted at any time, similar to alpha metrics. However, they are explicitly marked as internal to signal that they are not part of the public API.
81+
82+
An example of an internal metric follows:
83+
84+
```go
85+
var internalMetricDefinition = kubemetrics.CounterOpts{
86+
Name: "some_internal_metric",
87+
Help: "some description",
88+
StabilityLevel: kubemetrics.INTERNAL,
89+
}
90+
```
91+
92+
Internal metrics:
93+
94+
1. have no stability guarantees
95+
2. can be modified or deleted at any time
96+
3. should not be relied upon by external monitoring or alerting systems
97+
4. are typically used for debugging, testing, or internal component communication
98+
4999
## API Review
50100

51101
Graduating a metric to a stable state is a contractual API agreement, as such, it would be desirable to require an api-review (to sig-instrumentation) for graduating or deprecating a metric (in line with current Kubernetes [api-review processes](https://github.com/kubernetes/community/blob/master/sig-architecture/api-review-process.md)).
@@ -54,13 +104,13 @@ We use a verification script to flag stable metric changes for review by SIG Ins
54104

55105
## Metric Renaming
56106

57-
Metric renaming is be tantamount to deleting a metric and introducing a new one. Accordingly, metric renaming will also be disallowed for stable metrics.
107+
Metric renaming is tantamount to deleting a metric and introducing a new one. Accordingly, metric renaming will also be disallowed for stable metrics.
58108

59109
## Deprecation Lifecycle
60110

61111
Metrics can be annotated with a Kubernetes version, from which point that metric will be considered deprecated. This allows us to indicate that a metric is slated for future removal and provides the consumer a reasonable window in which they can make changes to their monitoring infrastructure which depends on this metric.
62112

63-
While deprecation policies only actually change stability guarantees for __stable__ metrics (and not __alpha__ ones), deprecation information may however be optionally provided on alpha metrics to help component owners inform users of future intent, to help with transition plans (this change was made at the request of @dashpole, who helpfully pointed out that it would be nice to be able signal future intent even for alpha metrics).
113+
While a deprecation period is only required for __stable__ metrics, an alpha or beta metric may still be deprecated prior to removal to help component owners inform users of future intent, and to ease the transition to the replacement metrics.
64114

65115
When a stable metric undergoes the deprecation process, we are signaling that the metric will eventually be deleted. The lifecyle looks roughly like this (each stage represents a Kubernetes release):
66116

@@ -77,7 +127,7 @@ var someCounter = kubemetrics.CounterOpts{
77127
}
78128
````
79129

80-
__Deprecated__ metrics will have their description text prefixed with a deprecation notice string '(Deprecated from x.y)' and a warning log will be emitted during metric registration (in the spirit of the official [Kubernetes deprecation policy](https://kubernetes.io/docs/reference/using-api/deprecation-policy/#deprecating-a-flag-or-cli)).
130+
__Deprecated__ metrics will have their description text prefixed with a deprecation notice string '(Deprecated since x.y)' and a warning log will be emitted during metric registration (in the spirit of the official [Kubernetes deprecation policy](https://kubernetes.io/docs/reference/using-api/deprecation-policy/#deprecating-a-flag-or-cli)).
81131

82132
Before deprecation:
83133

@@ -88,14 +138,23 @@ some_counter 0
88138
```
89139

90140
During deprecation:
141+
91142
```text
92-
# HELP some_counter (Deprecated from 1.15) this counts things
143+
# HELP some_counter (Deprecated since 1.15) this counts things
93144
# TYPE some_counter counter
94145
some_counter 0
95146
```
96147
Like their stable metric counterparts, deprecated metrics will be automatically registered to the metrics endpoint.
97148

98-
On a subsequent release (when the metric's deprecatedVersion is equal to current_kubernetes_version - 1)), a deprecated metric will become a __hidden metric__. _Unlike_ their deprecated counterparts, hidden metrics will __*no longer be automatically registered*__ to the metrics endpoint (hence hidden). However, they can be explicitly enabled through a command line flag on the binary (i.e. '--show-hidden-metrics-for-version=<previous minor release>'). This is to provide cluster admins an escape hatch to properly migrate off of a deprecated metric, if they were not able to react to the earlier deprecation warnings. Hidden metrics should be deleted after one release.
149+
After a period of time, a deprecated metric will become a __hidden metric__. The timeline for this transition depends on the metric's stability level:
150+
151+
| Stability Level | Time until hidden |
152+
| --------------- | ----------------------------------------------------------- |
153+
| **STABLE** | Minimum of 3 releases or 9 months, whichever is longer |
154+
| **BETA** | Minimum of 1 release or 4 months, whichever is longer |
155+
| **ALPHA** | Can be hidden or removed in the same release as deprecation |
156+
157+
_Unlike_ their deprecated counterparts, hidden metrics will __*no longer be automatically registered*__ to the metrics endpoint (hence hidden). However, they can be explicitly enabled through a command line flag on the binary (i.e. '--show-hidden-metrics-for-version=<previous minor release>'). This is to provide cluster admins an escape hatch to properly migrate off of a deprecated metric, if they were not able to react to the earlier deprecation warnings. Hidden metrics will be deleted after one release.
99158
100159
101160
[KEP-1209]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/1209-metrics-stability

0 commit comments

Comments
 (0)