9 changed files with 68 additions and 228 deletions
Unified View
Diff Options
-
110actuator-demo.iml
-
21pom.xml
-
50spring-boot-docker.iml
-
2src/main/java/com/neo/DockerApplication.java
-
43src/main/java/com/neo/config/ActuatorSecurityConfig.java
-
23src/main/java/com/neo/controller/DockerController.java
-
19src/main/java/com/neo/health/CustomHealthIndicator.java
-
26src/main/resources/application.properties
-
2src/main/resources/prometheus.yml
@ -1,110 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> |
|
||||
<component name="FacetManager"> |
|
||||
<facet type="Spring" name="Spring"> |
|
||||
<configuration /> |
|
||||
</facet> |
|
||||
<facet type="web" name="Web"> |
|
||||
<configuration> |
|
||||
<webroots /> |
|
||||
<sourceRoots> |
|
||||
<root url="file://$MODULE_DIR$/src/main/java" /> |
|
||||
<root url="file://$MODULE_DIR$/src/main/resources" /> |
|
||||
</sourceRoots> |
|
||||
</configuration> |
|
||||
</facet> |
|
||||
</component> |
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> |
|
||||
<output url="file://$MODULE_DIR$/target/classes" /> |
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> |
|
||||
<content url="file://$MODULE_DIR$"> |
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> |
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> |
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> |
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" /> |
|
||||
</content> |
|
||||
<orderEntry type="inheritedJdk" /> |
|
||||
<orderEntry type="sourceFolder" forTests="false" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-actuator:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.12.1" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.12.1" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.29" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" /> |
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.25" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator-autoconfigure:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.0" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.0" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.0" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.0" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: io.micrometer:micrometer-core:1.3.1" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.hdrhistogram:HdrHistogram:2.1.11" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.latencyutils:LatencyUtils:2.0.3" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-security:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.0" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.0" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.27" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.27" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.27" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.1" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: io.micrometer:micrometer-registry-prometheus:1.3.1" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: io.prometheus:simpleclient_common:0.7.0" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: io.prometheus:simpleclient:0.7.0" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.29" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: jakarta.activation:jakarta.activation-api:1.2.1" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.5.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.5.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.5.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.5.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.5.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.vintage:junit-vintage-engine:5.5.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.5.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:3.1.0" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.13.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.1" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.1.0" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.10.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.2" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.6.3" level="project" /> |
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.security:spring-security-test:5.2.1.RELEASE" level="project" /> |
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:5.2.1.RELEASE" level="project" /> |
|
||||
</component> |
|
||||
</module> |
|
||||
@ -1,43 +0,0 @@ |
|||||
package com.neo.config; |
|
||||
|
|
||||
|
|
||||
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest; |
|
||||
import org.springframework.boot.actuate.context.ShutdownEndpoint; |
|
||||
import org.springframework.boot.autoconfigure.security.servlet.PathRequest; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
|
||||
|
|
||||
@Configuration |
|
||||
public class ActuatorSecurityConfig extends WebSecurityConfigurerAdapter { |
|
||||
|
|
||||
/* |
|
||||
This spring security configuration does the following |
|
||||
|
|
||||
1. Restrict access to the Shutdown endpoint to the ACTUATOR_ADMIN role. |
|
||||
2. Allow access to all other actuator endpoints. |
|
||||
3. Allow access to static resources. |
|
||||
4. Allow access to the home page (/). |
|
||||
5. All other requests need to be authenticated. |
|
||||
5. Enable http basic authentication to make the configuration complete. |
|
||||
You are free to use any other form of authentication. |
|
||||
*/ |
|
||||
|
|
||||
@Override |
|
||||
protected void configure(HttpSecurity http) throws Exception { |
|
||||
http |
|
||||
.authorizeRequests() |
|
||||
.requestMatchers(EndpointRequest.to(ShutdownEndpoint.class)) |
|
||||
.hasRole("ACTUATOR_ADMIN") |
|
||||
.requestMatchers(EndpointRequest.toAnyEndpoint()) |
|
||||
.permitAll() |
|
||||
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()) |
|
||||
.permitAll() |
|
||||
.antMatchers("/", "/slowApi") |
|
||||
.permitAll() |
|
||||
.antMatchers("/**") |
|
||||
.authenticated() |
|
||||
.and() |
|
||||
.httpBasic(); |
|
||||
} |
|
||||
} |
|
||||
@ -1,19 +0,0 @@ |
|||||
package com.neo.health; |
|
||||
|
|
||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator; |
|
||||
import org.springframework.boot.actuate.health.Health; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
@Component |
|
||||
public class CustomHealthIndicator extends AbstractHealthIndicator { |
|
||||
|
|
||||
@Override |
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception { |
|
||||
// Use the builder to build the health status details that should be reported. |
|
||||
// If you throw an exception, the status will be DOWN with the exception message. |
|
||||
|
|
||||
builder.up() |
|
||||
.withDetail("app", "Alive and Kicking") |
|
||||
.withDetail("error", "Nothing! I'm good."); |
|
||||
} |
|
||||
} |
|
||||
@ -1,23 +1,25 @@ |
|||||
# Logging |
# Logging |
||||
logging.file=app.log |
|
||||
|
#logging.file=app.log |
||||
|
|
||||
# Spring Security default user name and password |
# Spring Security default user name and password |
||||
spring.security.user.name=actuator |
|
||||
spring.security.user.password=actuator |
|
||||
spring.security.user.roles=ACTUATOR_ADMIN |
|
||||
|
#spring.security.user.name=actuator |
||||
|
#spring.security.user.password=actuator |
||||
|
#spring.security.user.roles=ACTUATOR_ADMIN |
||||
|
|
||||
# INFO ENDPOINT CONFIGURATION |
# INFO ENDPOINT CONFIGURATION |
||||
info.app.name=@project.name@ |
|
||||
info.app.description=@project.description@ |
|
||||
info.app.version=@project.version@ |
|
||||
info.app.encoding=@project.build.sourceEncoding@ |
|
||||
info.app.java.version=@java.version@ |
|
||||
|
#info.app.name=@project.name@ |
||||
|
#info.app.description=@project.description@ |
||||
|
#info.app.version=@project.version@ |
||||
|
#info.app.encoding=@project.build.sourceEncoding@ |
||||
|
#info.app.java.version=@java.version@ |
||||
|
|
||||
# SHUTDOWN ENDPOINT (ShutdownEndpoint) |
# SHUTDOWN ENDPOINT (ShutdownEndpoint) |
||||
management.endpoint.shutdown.enabled=true |
|
||||
|
#management.endpoint.shutdown.enabled=true |
||||
|
|
||||
# HEALTH ENDPOINT |
# HEALTH ENDPOINT |
||||
management.endpoint.health.show-details=always |
|
||||
|
#management.endpoint.health.show-details=always |
||||
|
|
||||
# ENDPOINTS WEB CONFIGURATION |
# ENDPOINTS WEB CONFIGURATION |
||||
management.endpoints.web.exposure.include=* |
|
||||
|
#management.endpoints.web.exposure.include=* |
||||
|
|
||||
|
logging.level.io.swagger.models.parameters.AbstractSerializableParameter=error |
||||
Write
Preview
Loading…
Cancel
Save