xiangfu0 commented on code in PR #12389: URL: https://github.com/apache/pinot/pull/12389#discussion_r1495133985
########## pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotBrokerHealthCheck.java: ########## @@ -79,4 +88,40 @@ public String getBrokerHealth() { Response.status(Response.Status.SERVICE_UNAVAILABLE).entity(errMessage).build(); throw new WebApplicationException(errMessage, response); } + + @GET + @Produces(MediaType.TEXT_PLAIN) + @Path("uptime") + @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_HEALTH) + @ApiOperation(value = "Get broker uptime") + public String getUptime() { + ServiceStatus.Status status = ServiceStatus.getServiceStatus(_instanceId); + if (status == ServiceStatus.Status.GOOD) { + _brokerMetrics.addMeteredGlobalValue(BrokerMeter.HEALTHCHECK_OK_CALLS, 1); + Instant now = Instant.now(); + Duration uptime = Duration.between(_startTime, now); + return "Uptime: " + uptime.getSeconds() + " seconds"; + } + _brokerMetrics.addMeteredGlobalValue(BrokerMeter.HEALTHCHECK_BAD_CALLS, 1); + String errMessage = String.format("Cannot tell Pinot broker uptime. Pinot broker status is %s", status); + Response response = + Response.status(Response.Status.SERVICE_UNAVAILABLE).entity(errMessage).build(); + throw new WebApplicationException(errMessage, response); + } + + @GET + @Produces(MediaType.TEXT_PLAIN) + @Path("start-time") + @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_HEALTH) + @ApiOperation(value = "Get broker start time") + public String getStartTime() { + ServiceStatus.Status status = ServiceStatus.getServiceStatus(_instanceId); Review Comment: no need to check service status = good. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org