-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Add support for health indicator groups #14022
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
Comments
I am working in this issue. I will be sending a PR this weekend. |
Thank you, @eddumelendez. We had a few thoughts when we discussed this earlier this week. They are only initial thoughts so they aren't prescriptive, but hopefully they'll be of some use. We envisaged a property-based mechanism for creating a group of health indicators. In We then thought that |
Thanks for letting me know @wilkinsona I'll be working on this taking into account these thoughts. |
@eddumelendez Are you still interested in working on this? If not, we'll go ahead and pick it up. |
@mbhave I have an initial draft which I can share it later today. |
great, thanks! |
sorry for the delay. I have submitted #16252 |
I gave this some thoughts and I am wondering if we shouldn't have a concept of "out-of-the-box groups" the same way we have logging groups. The two obvious ones are those defined in this very request. If there is an obvious default for a given indicator, having a way to indicate a preference would give a better out-of-the-box experience for users compared to having them configure the list of indicators in every app. Another argument is that, in this scenario, if an indicator is not specified, it will not be invoked. When new indicators are added, there's no hint and it could easily be missed if the application is only relying on one group or another. Of course, we can start with a configurable map for a start and see how we can improve the manual solution. |
I've started to hack on a prototype where the following configuration is applied (random indicators based on
(Notice the // http://localhost:8080/actuator/health/ready
{
"status": "UP",
"details": {
"diskSpace": {
"status": "UP",
"details": {
"total": 499963170816,
"free": 271707451392,
"threshold": 10485760
}
}
}
} The // http://localhost:8080/actuator/health/live
{
"status": "UP",
"details": {
"example": {
"status": "UP",
"details": {
"counter": 42
}
},
"hello": {
"status": "UP",
"details": {
"hello": "world"
}
},
"db": {
"status": "UP",
"details": {
"database": "H2",
"result": 1,
"validationQuery": "SELECT 1"
}
}
}
} The main endpoint does not contain any reference to This spike is quite limited but brings several interesting questions:
|
+1 for failing
Accidental absence of an indicator from a group could lead to traffic being routed to an instance when it's unable to handle it. As such, I think the implementation should try to help users to avoid that mistake. I think we should fail if a group is configured to include an unknown indicator. We could consider a configuration option that changes this behaviour from fail to ignore.
I think unknown indicators should result in failure (see above). I think a group that's genuinely empty (rather than only containing indicators that do no exist) should return
I share you're feeling that this isn't quite right, but I'm not sure I have a better proposal right now. The two marker interfaces for the group indicators feel like a bit of a smell, but I'm not sure how else we can distinguish between a group indicator and a standard indicator.
I wonder if we need some sort of wildcard or pattern matching support. I'd be tempted to ship a first iteration without that and gather some feedback before we do anything more sophisticated.
While this would be a breaking change, I think it's unlikely that anyone has implemented their own indicator named |
This commit allows a user to define an arbitrary number of health indicator groups using configuration. If a given health indicator is defined in more than one group, a single invocation is ensured using a AggregateHealth. A reactive counter-part is also provided. See spring-projectsgh-14022
This commit allows a user to define an arbitrary number of health indicator groups using configuration. If a given health indicator is defined in more than one group, a single invocation is ensured using a AggregateHealth. A reactive counter-part is also provided. See spring-projectsgh-14022
Team, I've rebased my proposal in snicoll@43144b6 - if someone has some cycles to review it, I'd appreciate. I've been back and forth on several strategies to identify that an indicator is a group and hope a review would ameliorate the proposal. It is also very basic at the moment where groups are declared in a static fashion via configuration. |
This is a very interesting topic, and in our organisation we required a separation of ready, and alive endpoints as others mentioned in the above. But we went in a bit different direction..we introduced a new
and we mapped k8s endpoints such as:
Even the wording of the health statuses is kind of similar to the wording of kubernetes but a bit inverted,
All core health indicators already return DOWN, e.g. datasource, jms etc when the resource is not available *. which covers our needs I understand that this is completely different approach from what is requested, but i think it delivers what was requested + a couple of opportunities that might be useful. For example, some health indicators might get written in a smarter way, to distinguish whether the app should stop running, or it should just stop serving requests. one example, although probably difficult to implement, is to distinguish transient errors on datasourceHealthIndicator and return I don't know if this approach is more powerful or not than grouping health indicators, but the implementation of the new Actually this approach, can work well in conjunction with groups, all i am saying is that although the "custom" endpoint was easy to write, i would like to see something similar in spring-boot :) Or it can also replace the grouping approach, as instead of configuring groups, we would then just configure the statuses returned from each health indicator, for example it would be quite easy to control with a property or code, that jmsHealthIndicator should return this way, we can finally give a semantic on the I am happy to submit a pull request, if this makes sense and covers what is needed. As a side note, there are some cases maybe, where some people would like a health indicator not to participate in neither liveness or readiness results, and just use if for alerting purposes, for those cases we could just use a custom health status called To finish my long post, i feel that the best approach would be for spring boot to support a cascading set of endpoints such as
and a way to configure the failure status of an indicator some other benefits i can think from this approach are:
|
Thanks for sharing your thoughts, @ckoutsouridis. We discussed this last week and our feeling was that custom status mapping was likely to be quite specific to your usage and not something that we feel is generally applicable. As you may already know, you can perform custom mappings with
Liveness and readiness checks are just one use case that we're hoping to cover by being able to group health indicators. We'd like to provide something that's sufficiently flexible to support liveness and readiness checks with Kubernetes as well as more general grouping.
If we go with something that's similar to what we currently have in mind, this won't be an issue. Every indicators will be included in |
thank you @wilkinsona for the reply. I wasn't referring so much to custom statuses, as we rarely use them as well. I was mostly referring to the fact that at the moment But yes, this suggestion has nothing to do with grouping them. |
This commit allows a user to define an arbitrary number of health indicator groups using configuration. If a given health indicator is defined in more than one group, a single invocation is ensured using a AggregateHealth. A reactive counter-part is also provided. See spring-projectsgh-14022
Migrate all `HealthIndicator` configuration to `HealthContributor` configurations instead. See spring-projectsgh-14022
Update the `HealthEndpoint` to support health groups. The `HealthEndpointSettings` interface has been replaced with `HealthEndpointGroups` which provides access to the primary group as well as an optional set of additional groups. Groups can be configured via properties and may have custom `StatusAggregator` and `HttpCodeStatusMapper` settings. Closes spring-projectsgh-14022 Co-authored-by: Stephane Nicoll <snicoll@pivotal.io>
Migrate all `HealthIndicator` configuration to `HealthContributor` configurations instead. See gh-14022
Migrate all `HealthIndicator` configuration to `HealthContributor` configurations instead. See spring-projectsgh-14022
Update the `HealthEndpoint` to support health groups. The `HealthEndpointSettings` interface has been replaced with `HealthEndpointGroups` which provides access to the primary group as well as an optional set of additional groups. Groups can be configured via properties and may have custom `StatusAggregator` and `HttpCodeStatusMapper` settings. Closes spring-projectsgh-14022 Co-authored-by: Stephane Nicoll <snicoll@pivotal.io>
We need to update the Actuator API documentation to reflect the new functionality. Currently, it mentions components and component instances but makes no mention of groups. We also need to figure out how to document the arbitrarily deep path that's now supported. |
My organization uses Spring Boot services running in a Kubernetes environment. Kubernetes has a concept of two types of health probes: liveness and readiness probes. Liveness probes are used to detect if the service needs to be restarted, while readiness probes detect if the service is ready to be added to load balancers.
It would be great if there were a way to perform different checks for readiness and liveness. For example, if an application temporarily loses connectivity to its data source it should be taken out of load balancing, but doesn't need to be restarted. So we would like to include the
DataSourceHealthIndicator
in the readiness probe but not the liveness probe.Note that #8685 already allows querying a single health indicator, but not multiple indicators. Perhaps Spring Boot could provide a way to configure named groups of indicators that could be accessed as
/actuator/health/{group}
.The text was updated successfully, but these errors were encountered: