|
| 1 | +--- |
| 2 | +title: "Tutorial: |
| 3 | +Use Circuit Breaker Dashboard with Azure Spring Cloud | Microsoft Docs" |
| 4 | +description: Learn how to use circuit Breaker Dashboard with Azure Spring Cloud. |
| 5 | +author: MikeDodaro |
| 6 | +ms.author: brendm |
| 7 | +ms.service: spring-cloud |
| 8 | +ms.topic: tutorial |
| 9 | +ms.date: 04/06/2020 |
| 10 | +--- |
| 11 | + |
| 12 | +# Use Circuit Breaker Dashboard with Azure Spring Cloud | Microsoft Docs |
| 13 | +Spring Cloud Netflix Turbine is widely used to aggregates multiple Hystrix metrics streams so that streams can be monitored in a single view using Hystrix dashboard. This tutorial demonstrates how to use them on Azure Spring Cloud. |
| 14 | +> [!NOTE] |
| 15 | +> Netflix Hystrix is widely used in existing Spring Cloud apps, but it is no longer in active development. If you are developing new project, you can consider resilience4j instead. Circuit Breaker Dashboard for resilience4j dependents on micrometer, which is currently not supported for Azure Spring Cloud, so it will not be covered by this tutorial. |
| 16 | +
|
| 17 | +## Prepare your sample applications |
| 18 | +The sample is forked from this [repository](https://github.com/StackAbuse/spring-cloud/tree/master/spring-turbine). |
| 19 | + |
| 20 | +Clone the sample repository to your develop environment: |
| 21 | +``` |
| 22 | +git clone https://github.com/yucwan/spring-cloud.git |
| 23 | +``` |
| 24 | + |
| 25 | +Build the 3 applications that will be used in this tutorial. |
| 26 | +user-service: A simple REST service that has a single endpoint of /personalized/{id} |
| 27 | +recommendation-service: A simple REST service that has a single endpoint of /recommendations, which will be called by user-service. |
| 28 | +hystrix-turbine: A Hystrix dashboard service to display Hystrix streams and a Turbine service aggregating Hystrix metrics stream from other services. |
| 29 | +``` |
| 30 | +cd spring-cloud/spring-turbine |
| 31 | +mvn clean package -D skipTests -f user-service/pom.xml |
| 32 | +mvn clean package -D skipTests -f recommendation-service/pom.xml |
| 33 | +mvn clean package -D skipTests -f hystrix-turbine/pom.xml |
| 34 | +``` |
| 35 | +## Provision your Azure Spring Cloud instance |
| 36 | +Follow the procedure as described in [Provision a service instance on the Azure CLI](https://docs.microsoft.com/en-us/azure/spring-cloud/spring-cloud-quickstart-launch-app-cli#provision-a-service-instance-on-the-azure-cli). |
| 37 | + |
| 38 | +## Deploy your applications to Azure Spring Cloud |
| 39 | +These apps do not use Config Server, so there is no need to set up **Config Server** for Azure Spring Cloud. Deploy as follows: |
| 40 | +```azurecli |
| 41 | +az spring-cloud app create -n user-service --is-public |
| 42 | +az spring-cloud app create -n recommendation-service |
| 43 | +az spring-cloud app create -n hystrix-turbine --is-public |
| 44 | +
|
| 45 | +az spring-cloud app deploy -n user-service --jar-path user-service/target/user-service.jar |
| 46 | +az spring-cloud app deploy -n recommendation-service --jar-path recommendation-service/target/recommendation-service.jar |
| 47 | +az spring-cloud app deploy -n hystrix-turbine --jar-path hystrix-turbine/target/hystrix-turbine.jar |
| 48 | +``` |
| 49 | +## Verify your apps |
| 50 | +After all the apps are running and discoverable, access user-service with the path https://yuchensp-user-service.azuremicroservices.io/personalized/1 from your browser. You should get the following output if the user-service can access recommendation-service. If it doesn't work, refresh the web page a few times. |
| 51 | +```json |
| 52 | +[{"name":"Product1","description":"Description1","detailsLink":"link1"},{"name":"Product2","description":"Description2","detailsLink":"link3"},{"name":"Product3","description":"Description3","detailsLink":"link3"}] |
| 53 | +``` |
| 54 | +## Access your Hystrix dashboard and metrics stream |
| 55 | +Verify using public endpoints or using private test endpoints. |
| 56 | + |
| 57 | +### Using public endpoints |
| 58 | +Access hystrix-turbine with the path `https://<SERVICE-NAME>-hystrix-turbine azuremicroservices.io/hystrix` from your browser. The following figure shows the Hystrix dashboard running in this app. |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +Copy the Turbine stream url `https://<SERVICE-NAME>-hystrix-turbine.azuremicroservices.io/turbine.stream?cluster=default` into the text box, and click **Monitor Stream**. This will display the dashboard. If you are not viewing anything, hit the user-service endpoints to generate the streams. |
| 63 | + |
| 64 | + |
| 65 | +You can experiment with the Circuit Breaker Dashboard. |
| 66 | +> [!NOTE] |
| 67 | +> In production, the Hystrix dashboard and metrics stream should not be exposed to the Internet. |
| 68 | +
|
| 69 | +### Using private test endpoints |
| 70 | +Hystrix metrics streams are also accessible from test-endpoint. As backend service, we didn't assign a public end-point for recommendation-service, but we can show its metrics with test-endpoint at `https://primary:<KEY>@<SERVICE-NAME>.test.azuremicroservices.io/recommendation-service/default/actuator/hystrix.stream` |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +As a web app, Hystrix dashboard should be working on test endpoint. If it is not working properly, there may be two reasons: First, using test endpoint will change the base URL from `/ to /<APP-NAME>/<DEPLOYMENT-NAME>`, or, second, the web app is using absolute path for static resource. To get it working on test endpoint, you might need to manually edit the <base>in the front-end files. |
| 75 | + |
| 76 | +## See also |
| 77 | +* (https://docs.microsoft.com/azure/spring-cloud/spring-cloud-quickstart-launch-app-cli#provision-a-service-instance-on-the-azure-cli) |
0 commit comments