다음과 같은 PostgreSQL 상태 표시기를 만들었습니다.
@Component
public class PostgresHealthIndicator extends AbstractHealthIndicator {
@Autowired
DataSource postgresDataSource;
public DataSourceHealthIndicator dbHealthIndicator() {
DataSourceHealthIndicator indicator = new DataSourceHealthIndicator(postgresDataSource);
return indicator;
}
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
Health h = dbHealthIndicator().health();
Status status = h.getStatus();
if (status != null && "DOWN".equals(status.getCode())) {
builder.down();
} else {
builder.up();
}
}
}
내 Application.java에서이 구성 요소에 대해이 패키지를 스캔하고 있습니다.
@ComponentScan({"com.bp.health"})
내 application.properties에는 다음과 같은 세트가 있습니다.
endpoints.health.sensitive=false
endpoints.health.id=health
endpoints.health.enabled=true
{url} / health를 누르면 다음이 표시됩니다.
{ "status": "DOWN"}
사용자 지정 상태 표시기를 표시하려면 어떻게해야합니까?
모든 세부 정보를 보려면 인증을 받아야합니다. 또는 설정할 수 있습니다
management.security.enabled=false
endpoints.health.sensitive=false
인증되지 않은 전체 콘텐츠를 보려면
이에 대한 자세한 정보는 여기에서 찾을 수 있습니다. 생산 준비 모니터링
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다