1

I can see hystrix dashboard with : http://localhost:8081/hystrix Also I see my circuits break and fallback methods working as well Yet I can't see my application's data at : http://localhost:8081/actuator/hystrix.stream enter image description here When I look at /actuator/conditions I see following error for Hystrix

"HystrixAutoConfiguration.HystrixServletAutoConfiguration": {
                    "notMatched": [
                        {
                            "condition": "OnClassCondition",
                            "message": "@ConditionalOnClass did not find required class 'com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet'"
                        }
                    ],
                    "matched": []
                }

Code pom.xml

Spring Boot parent version : 2.2.6.RELEASE
Spring Cloud version : Hoxton.SR3
<dependencies>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
   </dependency>
   <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
   </dependency>
</dependencies>

application.properties

management.endpoints.web.exposure.include = hystrix.stream, conditions

MainApp

@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
@EnableHystrixDashboard
@EnableHystrix
public class MovieCatalogServiceApplication {}

CatalogRestController

@RestController
@RequestMapping("/catalog")
public class CatalogRestController {

    @Autowired
    MovieInfoService movieInfo;

    @Autowired
    UserRatingsService userRatingInfo;


    @RequestMapping("/{userId}")
    public List<Catalog> getCatalogsByUserId(@PathVariable("userId") int userId){

        UserRatings ratings = userRatingInfo.getUserRating(userId);


        return ratings.getUserRatings().stream().map(oneOfRatings -> {
            return movieInfo.getCatalog(oneOfRatings);
            }).collect(Collectors.toList());

    }
}

UserRatingsService

@Service
public class UserRatingsService {

    @Autowired
    private WebClient webClient;

    @HystrixCommand(fallbackMethod="getFallbackUserRating")
    public UserRatings getUserRating(int userId) {
        return webClient
                .get()
                .uri("http://user-rated-movies-service/ratingsdata/users/"+ userId)
                .retrieve()
                .bodyToMono(UserRatings.class)
                .block();
    }
    public UserRatings getFallbackUserRating(int userId) {
        UserRatings userRatings = new UserRatings();
        userRatings.setUserRatings(Arrays.asList(
                new Rating("0", "fallback method of user rating", 0)
                ));

        return userRatings;
    }
}
Ali D.A.
  • 144
  • 1
  • 2
  • 10

1 Answers1

0

Your Hixtrix port is 8081, so you need to use your endpoint on that 8081 port for metrics work.

E.G.

API-GATEWAY where Hystrix is used on port: 8081
USER-SERVICE port: 9001

Problem:

API-GATEWAY - http://localhost:8081/acturator/hystrix.stream
USER-SERVICE save user - http://localhost:9001/user/ 

Solution:

API-GATEWAY - http://localhost:8081/acturator/hystrix.stream
USER-SERVICE save user - http://localhost:8081/user/ 

Metrics now work well and the Hystrix Dashboard can work correctly.

Braian Silva
  • 1,986
  • 1
  • 15
  • 21