Spring Cloud - Eureka Server API



Eureka Server provides various APIs for the client instances or the services to talk to. A lot of these APIs are abstracted and can be used directly with @DiscoveryClient we defined and used earlier. Just to note, their HTTP counterparts also exist and can be useful for Non-Spring framework usage of Eureka.

We can use Server API to get the information about the client running EurekaClient can also be invoked via the browser using http://localhost:8761/eureka/apps/eurekaclient as can be seen here −

Example - Eureka Server API Usage via browser

Hit http://localhost:8761/eureka/apps/eurekaclient and verify the browser output as shown below −

<application>
   <name>EUREKACLIENT</name>
   <instance>
      <instanceId>Home:eurekaclient</instanceId>
      <hostName>Home</hostName>
      <app>EUREKACLIENT</app>
      <ipAddr>192.168.31.173</ipAddr>
      <status>UP</status>
      <overriddenstatus>UNKNOWN</overriddenstatus>
      <port enabled="true">8080</port>
      <securePort enabled="false">443</securePort>
      <countryId>1</countryId>
      <dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
         <name>MyOwn</name>
      </dataCenterInfo>
      <leaseInfo>
         <renewalIntervalInSecs>30</renewalIntervalInSecs>
         <durationInSecs>90</durationInSecs>
         <registrationTimestamp>1759835254121</registrationTimestamp>
         <lastRenewalTimestamp>1759836004625</lastRenewalTimestamp>
         <evictionTimestamp>0</evictionTimestamp>
         <serviceUpTimestamp>1759835253497</serviceUpTimestamp>
      </leaseInfo>
      <metadata>
         <management.port>8080</management.port>
         <jmx.port>63088</jmx.port>
      </metadata>
      <homePageUrl>http://Home:8080/</homePageUrl>
      <statusPageUrl>http://Home:8080/actuator/info</statusPageUrl>
      <healthCheckUrl>http://Home:8080/actuator/health</healthCheckUrl>
      <vipAddress>eurekaclient</vipAddress>
      <secureVipAddress>eurekaclient</secureVipAddress>
      <isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
      <lastUpdatedTimestamp>1759835254121</lastUpdatedTimestamp>
      <lastDirtyTimestamp>1759835253411</lastDirtyTimestamp>
      <actionType>ADDED</actionType>
   </instance>
</application>

Useful Server APIs

Few other useful APIs are −

Action API
Register a new service POST /eureka/apps/{appIdentifier}
Deregister the service DELTE /eureka/apps/{appIdentifier}
Information about the service GET /eureka/apps/{appIdentifier}
Information about the service instance GET /eureka/apps/{appIdentifier}/{instanceId}

More details about the programmatic API can be found here https://javadoc.io/doc/com.netflix.eureka/eureka-client/latest/index.html

Advertisements