Невозможно подключиться к командному метрическому потоку. в Eureka Admin - PullRequest
0 голосов
/ 22 января 2019

Я получаю сообщение об ошибке ниже - Невозможно подключиться к командному метрическому потоку.

Я реализовал api-gateway-service из https://howtodoinjava.com/spring-cloud/microservices-monitoring/, используя загрузочную версию 2.1.2.RELEASE и облачная версия Greenwich.RC2 .

enter image description here

pom.xml

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    </dependency>

    <!-- Hystrix -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
    </repository>
</repositories>

application.yml

spring:
  application:
    name: api-gateway

server:
  port: 8010

eureka:
  instance:
    lease-renewal-interval-in-seconds: 5
    lease-expiration-duration-in-seconds: 2
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
    healthcheck:
      enabled: true
    lease:
      duration: 5

logging:
  level:
    com.self.sprintboot.learning.apigateway: DEBUG

management:
  endpoints:
    web:
      exposure:
        exclude: hystrix.stream, info, health
      base-path: /

EmployeeController.java

@RestController
public class EmployeeController {
    private static final String URL = "http://employee-service/findEmployeeDetails/{employeeid}";
    @Autowired
    private RestTemplate restTemplate;

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @GetMapping("/employeeDetails/{employeeid}")
    @HystrixCommand(fallbackMethod = "fallbackMethod")
    public String getStudents(@PathVariable int employeeid) {
        System.out.println("Getting Employee details for " + employeeid);

        ResponseEntity<String> responseEntity = restTemplate.exchange(URL, HttpMethod.GET, null,
                new ParameterizedTypeReference<String>() {
                }, employeeid);
        String response = responseEntity.getBody();
        System.out.println("Response Body " + response);
        return "Employee Id -  " + employeeid + " [ Employee Details " + response + " ]";
    }

    private String fallbackMethod(int employeeid) {
        return "Fallback response:: No employee details available temporarily";
    }
}

ApiGatewayApplication.java

@SpringBootApplication
@EnableEurekaClient
@EnableHystrixDashboard
@EnableCircuitBreaker
public class ApiGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiGatewayApplication.class, args);
    }
}

enter image description here

1 Ответ

0 голосов
/ 27 июня 2019

В подразделе exposure раздела management измените exclude на include.

...