You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changes for health groups, showcomponents and showdetails (#343)
* changes for health groups, showcomponents and showdetails
* Apply suggestions from code review
Co-authored-by: Bart Koelman <104792814+bart-vmware@users.noreply.github.com>
* Changes for built-in groups, other feedback
* Apply suggestions from code review
Co-authored-by: Bart Koelman <104792814+bart-vmware@users.noreply.github.com>
* treat docfx-layer-changed as string
* don't build docfx image on workflow updates
* skip docfx steps instead of whole job so later jobs aren't also skipped
* add missing header, k8s probes must be enabled, custom contributor output
---------
Co-authored-by: Bart Koelman <104792814+bart-vmware@users.noreply.github.com>
Copy file name to clipboardExpand all lines: api/v4/management/health.md
+94-58Lines changed: 94 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,8 @@ By default, the final application health state is computed by the registered `IH
13
13
It is responsible for sorting out all of the returned statuses from each `IHealthContributor` and [`IHealthCheck`](https://learn.microsoft.com/dotnet/api/microsoft.extensions.diagnostics.healthchecks.ihealthcheck) and deriving an overall application health state.
14
14
The built-in aggregator returns the "worst" status returned from the contributors and checks.
15
15
16
+
## Configure Settings
17
+
16
18
The following table describes the configuration settings that you can apply to the endpoint.
17
19
Each key must be prefixed with `Management:Endpoints:Health:`.
18
20
@@ -23,18 +25,20 @@ Each key must be prefixed with `Management:Endpoints:Health:`.
23
25
|`Path`| The relative path at which the endpoint is exposed. | same as `ID`|
24
26
|`RequiredPermissions`| Permissions required to access the endpoint, when running on Cloud Foundry. |`Restricted`|
25
27
|`AllowedVerbs`| An array of HTTP verbs the endpoint is exposed at. |`GET`|
26
-
|`ShowDetails`|The level of detail included in the response. |`Never`|
27
-
|`Claim`|The claim required in `HttpContext.User` when `ShowDetails` is set to `WhenAuthorized`. ||
28
-
|`Role`| The role required in `HttpContext.User` when `ShowDetails` is set to `WhenAuthorized`. ||
29
-
|`Groups`|Specify logical groupings of health contributors. ||
28
+
|`ShowComponents`|Whether health check components should be included in the response. |`Never`|
29
+
|`ShowDetails`|Whether details of health check components should be included in the response. |`Never`|
30
+
|`Claim`| The claim required in `HttpContext.User` when`ShowComponents` and/or`ShowDetails` is set to `WhenAuthorized`. ||
31
+
|`Role`|The role required in `HttpContext.User` when `ShowComponents` and/or `ShowDetails` is set to `WhenAuthorized`. ||
30
32
31
-
The information exposed by the health endpoint depends on the `ShowDetails`property, which can be configured with one of the following values:
33
+
The depth of information exposed by the health endpoint depends on the `ShowComponents` and `ShowDetails`properties, which can both be configured with one of the following values:
32
34
33
35
| Name | Description |
34
36
| --- | --- |
35
-
|`Never`| Details are never shown. |
36
-
|`WhenAuthorized`| Details are shown only to authorized users. |
37
-
|`Always`| Details are always shown. |
37
+
|`Never`| Never shown. |
38
+
|`WhenAuthorized`| Shown only to authorized users. |
39
+
|`Always`| Always shown. |
40
+
41
+
`ShowDetails` only has an effect when `ShowComponents` is set to `Always`, or `WhenAuthorized` and the request is authorized.
38
42
39
43
Authorized users can be configured by setting `Claim` or `Role`.
40
44
A user is considered to be authorized when they are in the given role or have the specified claim.
@@ -45,10 +49,11 @@ The following example uses `Management:Endpoints:Health:Claim`:
45
49
"Management": {
46
50
"Endpoints": {
47
51
"Health": {
52
+
"ShowComponents": "WhenAuthorized",
48
53
"ShowDetails": "WhenAuthorized",
49
54
"Claim": {
50
55
"Type": "health_actuator",
51
-
"Value": "see_details"
56
+
"Value": "see_all"
52
57
}
53
58
}
54
59
}
@@ -84,7 +89,7 @@ The configuration key `Management:Endpoints:UseStatusCodeFromResponse` can be se
84
89
Clients can overrule this per request by sending an `X-Use-Status-Code-From-Response` HTTP header with the value `true` or `false`.
85
90
86
91
> [!TIP]
87
-
> By default, health contributors for disk space, ping, liveness, and readiness are activated. They can be turned off through configuration:
92
+
> By default, health contributors for disk spaceand ping are activated. They can be turned off through configuration:
88
93
>
89
94
> ```json
90
95
> {
@@ -96,12 +101,6 @@ Clients can overrule this per request by sending an `X-Use-Status-Code-From-Resp
96
101
> },
97
102
> "Ping": {
98
103
> "Enabled": "false"
99
-
> },
100
-
> "Liveness": {
101
-
> "Enabled": "false"
102
-
> },
103
-
> "Readiness": {
104
-
> "Enabled": "false"
105
104
> }
106
105
> }
107
106
> }
@@ -113,28 +112,32 @@ Clients can overrule this per request by sending an `X-Use-Status-Code-From-Resp
113
112
114
113
This endpoint returns the top-level status, along with the details of the contributors and checks.
115
114
116
-
The response will always be returned as JSON, like this:
115
+
The response will always be returned as JSON, and this is the default value:
116
+
117
+
```json
118
+
{
119
+
"status": "UP"
120
+
}
121
+
```
122
+
123
+
When `ShowComponents` and `ShowDetails` are set to `Always`, or when set to `WhenAuthorized` and the request is authorized, the response is more detailed:
117
124
118
125
```json
119
126
{
120
127
"status": "UP",
121
-
"details": {
128
+
"components": {
122
129
"ping": {
123
130
"status": "UP"
124
131
},
125
132
"diskSpace": {
126
133
"status": "UP",
127
-
"total": 1999599824896,
128
-
"free": 1349396418560,
129
-
"threshold": 10485760
130
-
},
131
-
"readiness": {
132
-
"status": "UP",
133
-
"ReadinessState": "ACCEPTING_TRAFFIC"
134
-
},
135
-
"liveness": {
136
-
"status": "UP",
137
-
"LivenessState": "CORRECT"
134
+
"details": {
135
+
"total": 1999599824896,
136
+
"free": 1330717282304,
137
+
"threshold": 10485760,
138
+
"path": "C:\\source\\Repository\\src\\Project",
139
+
"exists": true
140
+
}
138
141
}
139
142
}
140
143
}
@@ -164,52 +167,64 @@ Should you need to check application health based on a subset of health contribu
164
167
}
165
168
```
166
169
167
-
While group names are case-sensitive, the entries in `Include` are case-insensitive and will only activate health contributors with a matching `Id`.
168
-
169
-
> [!NOTE]
170
-
> Adding your own health groups implicitly turns off the built-in groups for liveness and readiness. If you want to keep them, you need to include them explictly.
171
-
>
172
-
> To turn off the default liveness/readiness health groups without adding any of your own, configure a single-element empty group like this:
173
-
> ```json
174
-
> {
175
-
> "Management": {
176
-
> "Endpoints": {
177
-
> "Health": {
178
-
> "Groups": {
179
-
> "": {
180
-
> "Include": ""
181
-
> }
182
-
> }
183
-
> }
184
-
> }
185
-
> }
186
-
> }
187
-
> ```
188
-
> This clumsy format is used because there's no syntax in .NET Configuration to express an empty collection.
189
-
> See https://github.com/dotnet/extensions/issues/1341#issuecomment-598310364 for details.
170
+
While group names are case-sensitive, the entries in `Include` are case-insensitive and will only activate health contributors with a matching `Id`, and/or ASP.NET health check registrations with a matching name.
190
171
191
172
For any group that has been defined, you may access health information from the group by appending the group name to the HTTP request URL. For example: `/actuator/health/example-group`.
192
173
174
+
`ShowComponents` and `ShowDetails` can also be set at the group level, overriding the settings found at the endpoint level.
175
+
176
+
```json
177
+
{
178
+
"Management": {
179
+
"Endpoints": {
180
+
"Health": {
181
+
"Claim": {
182
+
"Type": "health_actuator",
183
+
"Value": "see_all"
184
+
},
185
+
"Groups": {
186
+
"example-group": {
187
+
"Include": "Redis,RabbitMQ",
188
+
"ShowComponents": "Always",
189
+
"ShowDetails": "WhenAuthorized"
190
+
}
191
+
}
192
+
}
193
+
}
194
+
}
195
+
}
196
+
```
193
197
194
198
### Kubernetes Health Groups
195
199
196
-
Applications deployed on Kubernetes can provide information about their internal state with [Container Probes](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes). Depending on your [Kubernetes configuration](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/), the kubelet will call those probes and react to the result.
200
+
Applications deployed on Kubernetes can provide information about their internal state with [Container Probes](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes).
201
+
Depending on your [Kubernetes configuration](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/), the kubelet will call those probes and react to the result.
197
202
198
-
Steeltoe provides an [`ApplicationAvailability`](https://github.com/SteeltoeOSS/Steeltoe/blob/main/src/Management/src/Endpoint/Actuators/Health/Availability/ApplicationAvailability.cs) class for managing various types of application state. Out of the box, support is provided for Liveness and Readiness, where each is exposed in a corresponding `IHealthContributor` and health group.
203
+
Steeltoe provides an [`ApplicationAvailability`](https://github.com/SteeltoeOSS/Steeltoe/blob/main/src/Management/src/Endpoint/Actuators/Health/Availability/ApplicationAvailability.cs) class for managing various types of application state.
204
+
Out of the box, support is provided for Liveness and Readiness, where each is exposed in a corresponding `IHealthContributor` and health group.
205
+
While these health contributors are included, they are disabled by default and must be enabled in configuration (as demonstrated in the example below).
199
206
200
-
To change the health contributors that are included in either of the two default groups, use the same style of configuration described above. Please note that this will _replace_ the default groupings, so if you would like to _add_ an `IHealthContributor` you will need to include the original entry. These entries demonstrate including disk space in both groups:
207
+
To change the health contributors that are included in either of the two built-in groups, use the same style of configuration described above.
208
+
Please note that this will _replace_ these groupings, so if you would like to _add_ an `IHealthContributor` you will need to include the original entry.
209
+
These entries demonstrate enabling the probes, their groups and including disk space in both groups:
201
210
202
211
```json
203
212
{
204
213
"Management": {
205
214
"Endpoints": {
206
215
"Health": {
216
+
"Liveness": {
217
+
"Enabled": "true"
218
+
},
219
+
"Readiness": {
220
+
"Enabled": "true"
221
+
},
207
222
"Groups": {
208
223
"liveness": {
209
-
"Include": "diskSPACE,liveness"
224
+
"Include": "diskSpace,livenessState"
210
225
},
211
226
"readiness": {
212
-
"Include": "diskspace,readiness"
227
+
"Include": "diskSpace,readinessState"
213
228
}
214
229
}
215
230
}
@@ -305,13 +320,34 @@ public class ExampleHealthContributor : IHealthContributor
305
320
306
321
Sending a GET request to `/actuator/health` returns the following response:
307
322
323
+
```json
324
+
{
325
+
"status":"WARNING"
326
+
}
327
+
```
328
+
329
+
When `ShowComponents` and `ShowDetails` are set to `Always`, or when set to `WhenAuthorized` and the request is authorized, the response is more detailed:
330
+
308
331
```json
309
332
{
310
333
"status": "WARNING",
311
-
"details": {
334
+
"components": {
312
335
"ExampleHealthContributor": {
313
336
"status": "WARNING",
314
337
"description": "This health check does not check anything"
0 commit comments