spring-attic / hystrix-dashboard

Apache License 2.0
99 stars 104 forks source link

When I run this in 1.0.0.RC2, entering in a stream doesnt work #1

Closed rubesMN closed 9 years ago

rubesMN commented 9 years ago

With the exception of not using or configuring the mock stream, this code seems to works fine in 1.0.0.M1 but not in RC2. Services are annotated with @EnableHystrix, they are using hystrix, they all report to Eurkea using @EnableEurekaClient (also tried @EnableDiscoveryClient). Navigating to default 7980 port, enter in 'http://localhost:8083/hystrix.stream' (and I know the service at 8083 is running), the circuit page comes up and shows nothing despite traffic through hystrix annotations occurring on that service. Finally, @EnableEurekaClient/@EnableDiscoveryClient on this hystrix server doesn't work at all now.

spencergibb commented 9 years ago

@rubesMN some changes have been made to the hystrix dashboard since RC2, can you try with RC3 (which just went out today) and verify you still have problems?

rubesMN commented 9 years ago

nope.. no luck. Same behavior. Console for the attempt to connect within hystrix dashboard app:

2015-02-13 13:53:42.029 INFO 15829 --- [nio-7980-exec-5] ashboardConfiguration$ProxyStreamServlet : Proxy opening connection to: http://localhost:8083/hystrix.stream

Perhaps its me somehow.. I have to admit I have no idea what this line in the .yml file is doing:

cloud: config: uri: ${vcap.services.${PREFIX:}configserver.credentials.uri:http://user:password@localhost:8888}

spencergibb commented 9 years ago

That line has nothing to do with the hystrix stream, it's the uri to config server (with some defaults). All the samples from https://github.com/spring-cloud-samples/ work correctly. Do you have some code you can share that reproduce the problem? Browser console errors? Exceptions?

rubesMN commented 9 years ago

ok.. will try to provide what seems relevant. The hystrix dashboard below is basically this app:

# yml for hystrix dashboard:
spring:
  application:
    name: hystrix
  cloud:
    config:
       uri: ${vcap.services.${PREFIX:}configserver.credentials.uri:http://user:password@localhost:8888}

server:
  port: 7980

endpoints:
  restart:
    enabled: true
  shutdown:
    enabled: true

eureka:
  client:
    #registerWithEureka: false
    registerWithEureka: true
    fetchRegistry: false
    region: default
    preferSameZone: false
    us-east-1:
          availabilityZones: default
  instance:
    statusPageUrlPath: /admin/info
    healthCheckUrlPath: /admin/health
    virtualHostName: ${spring.application.name}
  server:
    waitTimeInMsWhenSyncEmpty: 0

hystrix dashboard code

@Configuration
@ComponentScan
@EnableAutoConfiguration
@Controller
@EnableHystrixDashboard
@EnableDiscoveryClient
public class HystrixDashboardApplication extends SpringBootServletInitializer {

    @RequestMapping("/")
    public String home() {
        return "forward:/hystrix";
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(HystrixDashboardApplication.class).web(true);
    }

    public static void main(String[] args) {
        new SpringApplicationBuilder(HystrixDashboardApplication.class).web(true).run(args);
    }
}

Dependencies in POM:

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>

Application I'm connecting to:

Main class

@Configuration
@EnableAutoConfiguration
@ComponentScan
@EnableHystrix
@EnableDiscoveryClient
public class Application { 
public static void main(String[] args) {
        ApplicationContext ctx = SpringApplication.run(Application.class, args); }

Called from a @RestController

@Component
public class EricComponent { 
: 
.
@HystrixCommand(fallbackMethod = "defaultRestTemplateCall", commandKey = "doge")
public Eric doRestTemplateCall(int callNum) {
... do restTemplate calls.. etc
spencergibb commented 9 years ago

@rubesMN I added a sample @EnableCircuitBreaker application here: 516c240bdc9b5c4afdbe14c709f97e30289c1676. I'm unable to reproduce your problem.

amarjothi commented 9 years ago

Using 1.0.0 RELEASE version. @EnableHystrix doesn't seem to stream the metrics. 1. Does it work without Config Server. 2. Do we have to include @EnableCircuit breaker?

spencergibb commented 9 years ago

@amarjothi @EnableHystrix and @EnableCircuitBreaker are functionally equivalent. Config server is not needed. Can you provide some configuration? errors? sample application?

amarjothi commented 9 years ago

@spencergibb, there are no errors,

$ curl -u user:password http://localhost:8080/mytest/health {"status":"DOWN","diskSpace":{"status":"UP","free":372536553472,"threshold":10485760},"configServer":{"status":"DOWN","error":"no property sources located"},"hystrix":{"status":"UP"}}

As you can see from below it is returning empty stats in the stream. $ curl -u user:password http://localhost:8080/mytest/hystrix.stream ping:

ping:

ping:

ping:

@Configuration @EnableAutoConfiguration @EnableHystrix @EnableHystrixDashboard @Import({ApplicationConfig.class, SwaggerConfig.class, WebConfig.class }) public class Application {

public static void main(String[] args) {

    SpringApplication.run(Application.class, args);
}

}

            <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-hystrix</artifactId>
    </dependency>
            <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter</artifactId>
    </dependency>
            <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
    </dependency>
            <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-netflix-core</artifactId>
    </dependency>
            <dependency>
                    <groupId>com.netflix.hystrix</groupId>
                    <artifactId>hystrix-metrics-event-stream</artifactId>
            </dependency>
amarjothi commented 9 years ago

@spencergibb application.yml

hystrix:
       command.default.execution.isolation.thread.timeoutInMilliseconds: 15000 
       comamnd.default.circuitBreaker.errorThresholdPercentage: 50 
       collapser.default.maxRequestsInBatch: 1 
       threadpool.default.coreSize: 10

No other entries other than the above for Hystrix, do we need to set Eureka properties(we do not want to use Eureka server/client) will Hystrix still work.

amarjothi commented 9 years ago

@spencergibb, resolved, I had dependency on the spring-cloud-starter-parent. I removed it, and it works now. Cheers. ~Amar.

spencergibb commented 9 years ago

Thanks for the update.

spencergibb commented 9 years ago

@amarjothi which application is on port 8080? the dashboard or the app with hystrix? It really shouldn't matter. If it is the app with hystrix, that port should be in the url to the hystrix.stream.

spencergibb commented 9 years ago

any errors in the javascript console?

spencergibb commented 9 years ago

@amarjothi can you move this to a new issue

dinolupo commented 9 years ago

I do not understand how you solved the problem, I have this configuration and I also have void pings:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>zen-contact-spring-cloud</artifactId>
        <groupId>com.zenika</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>front-application</artifactId>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mustache</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
        </dependency>

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

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-ribbon</artifactId>
        </dependency>

    </dependencies>

</project>
dinolupo commented 9 years ago

parent pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.zenika</groupId>
    <artifactId>zen-contact-spring-cloud</artifactId>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>eureka-server</module>
        <module>backend-service</module>
        <module>front-application</module>
    </modules>
    <packaging>pom</packaging>

    <properties>
        <spring-cloud.version>Angel.SR3</spring-cloud.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

    </dependencies>

    <dependencyManagement>

        <dependencies>

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

        </dependencies>

    </dependencyManagement>

</project>
amarjothi commented 9 years ago

@Dinolupo, I removed the Spring-cloud-starter-parent, dependency and it had worked. Check the dependency-tree for conflicting dependencies.

ghost commented 6 years ago

@rubesMN @spencergibb @amarjothi @mstine - Could you please guide me on https://stackoverflow.com/questions/52137023/unable-to-connect-to-command-metric-stream-in-spring-cloud-hystrix-turbine ?