[[getting-started]]
== Getting started ==

[[set-up-admin-server]]
=== Set up admin server ===

First you need to setup your server. To do this just setup a simple boot project (using http://start.spring.io for example).

. Add Spring Boot Admin Server and the UI to your dependencies:
+
[source,xml,subs="verbatim,attributes"]
.pom.xml
----
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-server</artifactId>
    <version>{project-version}</version>
</dependency>
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-server-ui</artifactId>
    <version>{project-version}</version>
</dependency>
----

. Pull in the Boot Admin Server configuration via adding `@EnableAdminServer` to your configuration:
+
[source,java]
----
@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class SpringBootAdminApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootAdminApplication.class, args);
    }
}
----

NOTE: If you want to setup the Spring Boot Admin Server via war-deployment in a servlet-container, please have a look at the https://github.com/codecentric/spring-boot-admin/blob/master/spring-boot-admin-samples/spring-boot-admin-sample-war/[spring-boot-admin-sample-war].

See also the https://github.com/codecentric/spring-boot-admin/tree/master/spring-boot-admin-samples/spring-boot-admin-sample/[spring-boot-admin-sample] project.


[[register-client-applications]]
=== Register client applications ===

To register your application at the admin server (next referred as "clients").
Either you can include the `spring-boot-admin` client or use http://projects.spring.io/spring-cloud/spring-cloud.html[Spring Cloud Discovery] (e.g. Eureka)

[[register-clients-via-spring-boot-admin]]
==== spring-boot-admin-starter-client ====

Each application that want to register itself to the admin has to include the Spring Boot Admin Client.

. Add spring-boot-admin-starter-client to your dependencies:
+
[source,xml,subs="verbatim,attributes"]
.pom.xml
----
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-client</artifactId>
    <version>{project-version}</version>
</dependency>
----

. Trigger the contained AutoConfiguration and tell the client where to find the admin to register at:
+
[source,yml]
.application.yml
----
include::{samples-dir}/spring-boot-admin-sample/src/main/resources/application.yml[tags=configuration-sba-client]
----

[[discover-clients-via-spring-cloud-discovery]]
==== Spring Cloud Discovery ====

If you already using Spring Cloud Discovery for your applications you don't have to add the Spring Boot Admin Client to your applications. Just make the Spring Boot Admin Server a DiscoveryClient, the rest is done by our AutoConfiguration.

The following steps are for using Eureka, but other Spring Cloud Discovery implementations are supported as well. There are examples using https://github.com/codecentric/spring-boot-admin/tree/master/spring-boot-admin-samples/spring-boot-admin-sample-consul/[Consul] and https://github.com/codecentric/spring-boot-admin/tree/master/spring-boot-admin-samples/spring-boot-admin-sample-zookeeper/[Zookeeper].

Also have a look at the http://projects.spring.io/spring-cloud/spring-cloud.html[Spring Cloud documentation].

. Add spring-cloud-starter-eureka to you dependencies:
+
[source,xml]
.pom.xml
----
include::{samples-dir}/spring-boot-admin-sample-eureka/pom.xml[tags=dependency-eureka,indent=0]
----

. Enable discovery by adding `@EnableDiscoveryClient` to your configuration:
+
[source,java]
----
include::{samples-dir}/spring-boot-admin-sample-eureka/src/main/java/de/codecentric/boot/admin/SpringBootAdminApplication.java[tags=application-eureka]
----

. Tell the Eureka client where to find the service registry:
+
[source,yml]
.application.yml
----
include::{samples-dir}/spring-boot-admin-sample-eureka/src/main/resources/application.yml[tags=configuration-eureka]
----

See also https://github.com/codecentric/spring-boot-admin/tree/master/spring-boot-admin-samples/spring-boot-admin-sample-eureka/[spring-boot-admin-sample-eureka].

NOTE: You can include the Spring Boot Admin to your Eureka server. Add the dependencies, add `@EnableAdminServer` to your configuration and set `spring.boot.admin.context-path` to something different than `"/"` so that the Spring Boot Admin Server UI won't clash with Eureka's one.