Spring Cloud Eureka Services on-line monitoring

Source: Internet
Author: User

We have previously introduced the use of Spring Boot Admin to detect the upper and lower lines of the service, and then the notification function.

Article: http://cxytiandi.com/blog/detail/13376

Today we will introduce another way of implementation, in the Eureka Service for detection notification, Eureka provides the way to monitor the event to support the extension. Eurekainstancecanceledevent Service downline Event eurekainstanceregisteredevent Service registration Event Eurekainstancerenewedevent Service Renewal Event Eurekaregistryavailableevent Eureka Registry Start Event eurekaserverstartedevent Eureka Server Startup event

Import Com.netflix.appinfo.InstanceInfo;
Import org.springframework.cloud.netflix.eureka.server.event.*;
Import Org.springframework.context.event.EventListener;

Import org.springframework.stereotype.Component; /** * Eureka Event Monitoring * * @author Yinjihuan * @create 2018-03-09 13:45 **/@Component public class Eurekastatechangelisten ER {@EventListener public void Listen (Eurekainstancecanceledevent event) {System.err.println (event.gets
    Erverid () + "\ T" + event.getappname () + "service downline"); } @EventListener public void Listen (Eurekainstanceregisteredevent event) {Instanceinfo instanceinfo = Ev
        Ent.getinstanceinfo ();
    System.err.println (Instanceinfo.getappname () + "register"); } @EventListener public void Listen (Eurekainstancerenewedevent event) {System.err.println (event.getserve
    RId () + "\ T" + event.getappname () + "Service for Renewal"); } @EventListener public void Listen (Eurekaregistryavailableevent event) {SYSTEM.ERR.PRINTLN ("Registration center launch"); } @EventListener public void Listen (Eurekaserverstartedevent event) {System.err.println ("Eureka Server
    Dynamic "); }

}

The above is just a demonstration of the effect of the event, specifically in what events need to do what action, need to send e-mail or text messages, you need to implement their own.

Note: In the Eureka cluster environment, each node will trigger the event, this time need to control the behavior of sending notifications, each node will send a notification without control.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.