标签: spring-boot-actuator

弹簧引导执行器不工作(未找到)版本 1.4.1

我从 spring 站点(https://spring.io/guides/gs/actuator-service)下载了这个示例,我遵循了相同的步骤,但是如果我调用这个 URL

显示http://localhost:9000/health spring启动错误页面

在此处输入图片说明

spring boot 版本是1.4.1,应该是 {"status":"UP"},有什么建议吗?

应用程序属性

server.port: 9000
management.port: 9001
management.address: 127.0.0.1
Run Code Online (Sandbox Code Playgroud)

POM文件

<?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>org.springframework</groupId>
    <artifactId>gs-actuator-service</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
    </parent>

    <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>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <properties>
        <java.version>1.8</java.version>
    </properties>

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

</project>
Run Code Online (Sandbox Code Playgroud)

日志:

在此处输入图片说明

spring spring-boot spring-boot-actuator

1
推荐指数
1
解决办法
5068
查看次数

弹簧执行器“ /执行器”端点不可用

我创建了一个简单的示例项目,仅包含spring-web和spring-actuator。我无法/actuator在该项目中调用端点。我唯一得到的是404错误:

There was an unexpected error (type=Not Found, status=404). No message available

在日志中,我什么都看不到。为了避免安全问题,我激活了management.security.enabled=false中的application.properties

在其他具有相同spring,spring-web和spring-actuator版本的项目中,我达到了/actuator终点,但看不到差异。

这是示例项目的github链接:https : //github.com/ManuZiD/mzd-actuator

任何建议都很好。提前致谢。

spring spring-mvc spring-boot spring-boot-actuator

1
推荐指数
1
解决办法
1289
查看次数

访问 localhost:8080/actuator 端点(使用弹簧引导执行器)

在 spring文档中,我已经阅读了由执行器依赖项提供的名为“执行器”的端点,但我没有设法在我的本地测试应用程序上访问它。

问题:有人知道如何访问该端点吗?如果可能的话,粗略的:)
子问题 1:如果这个端点存在,那么为什么它是隐藏的?
子问题 2:如果此端点不存在,我们如何通知 spring.io 更正文档页面(打开某种票证)?

细节:

  • 我想完全访问“执行器”端点,而不是 Spring Boot 执行器提供的其他端点(本地主机:8080/actuator)
  • 是的,我尝试在属性文件中手动启用该端点(endpoints.enabled=true OR endpoints.actuator.enabled=true)
  • 是的,我尝试启用/禁用 endpoints.sencitive 属性
  • 是的,执行器的其他端点工作正常
  • 我没有特别的理由需要它,只是想尝试一下(只是学习新东西:))
  • 请不要只回答“没有这样的端点老兄!”,应该有某种原因将它写在文档中
  • 请使用我现在使用的 spring boot 版本,然后再回答“它对我有用这些配置”(spring boot 版本:1.5.4.RELEASE
  • 先感谢您 :)

endpoint spring-boot spring-boot-actuator

1
推荐指数
1
解决办法
2868
查看次数

Spring-Boot 执行器/关闭端点被禁止

我第一次使用 Spring Boot 应用程序时,执行器没有受到保护,因此很容易通过 /actuator/shutdown 端点远程关闭。最近,我使用 Spring security 保护了我的执行器,并且它起作用了。现在我需要提供 http 基本凭据来访问端点,但现在对 /actuator/shutdown 端点的curl 调用失败并出现禁止错误。我一定是某个地方配置不正确。

我的卷曲命令:

curl -XPOST -u 执行器:密码http://主机:端口/执行器/shutdown -k

我可以调用其他端点,似乎只有关闭端点被禁止。

我的配置:

management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
management.info.git.mode=full
management.endpoint.shutdown.enabled=true
management.server.port=8081
spring.security.user.name=actuator
spring.security.user.roles=ACTUATOR
spring.security.user.password=password
Run Code Online (Sandbox Code Playgroud)

编辑:

    @Configuration
public static class ActuatorWebSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
    protected void configure(HttpSecurity http) throws Exception {
        http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests()
                .anyRequest().hasRole("ACTUATOR")
                .and()
                .httpBasic();
    }
}
Run Code Online (Sandbox Code Playgroud)

curl spring-boot spring-boot-actuator

1
推荐指数
1
解决办法
3779
查看次数

执行器的 Spring Boot 2 升级问题

配置: springCloudVersion = 'Finchley.SR1' springBootVersion = '2.0.2.RELEASE'

得到以下错误:

Caused by: java.lang.ClassNotFoundException: org.springframework.boot.actuate.metrics.CounterService
Run Code Online (Sandbox Code Playgroud)

这个版本的 spring-starter-actuator-2.0.2.RELEASE 中没有 CounterService 类??参考:https : //docs.spring.io/spring-boot/docs/2.0.2.RELEASE/api/

spring-boot spring-boot-actuator

1
推荐指数
1
解决办法
2401
查看次数

扩展 GitInfoContributor 以添加属性?

在我发现 Spring Boot 的 Info Actuator 几乎拥有我想要发布的所有内容之前,我创建了一些元端点以确保我可以访问构建和 Git 信息,这些信息在尝试验证以下内容时会有所帮助:

  • “是否部署了正确的版本?”
  • “这是谁建的?”
  • “它什么时候建成的?”
  • “这是基于哪个 git commit?”

这样做之后,我确实开始发现 Info 执行器,它为我回答了几乎所有这些问题,但是我想添加 Git 信息中的一些内容——主要是提交消息和肮脏的旗帜。

如果我打开完整的 git 元数据,我会查看输出:

management.info.git.mode=full
Run Code Online (Sandbox Code Playgroud)

但是......这增加了更多的信息,其中大部分我并不关心,所以它比我真正想要的要多。

我想做的是获取 GitInfoContributor 并扩展/替换它,但我不完全确定如何做到这一点。添加我自己的贡献者很容易,但是如果我添加我自己的贡献者并调用 builder.withDetails("git"),如下所示:

package ca.cpp.api.submitapi.config

import org.springframework.boot.actuate.info.Info
import org.springframework.boot.actuate.info.InfoContributor
import org.springframework.boot.info.GitProperties
import org.springframework.stereotype.Component

@Component
class CustomGitInfoContributor(private val properties: GitProperties): InfoContributor {
    override fun contribute(builder: Info.Builder?) {
        builder?.withDetail("git",mapOf("dirty" to properties.get("dirty"))
    }
}
Run Code Online (Sandbox Code Playgroud)

这取代了整个 git 属性集,同时,我认为核心 GitInfoContributor 仍然存在,仍然提供我丢弃的信息。

有没有一种合理的方法来只添加我想要的元素,或者使用我自己的贡献者,可以将其信息与“git”下已有的信息合并,或者通过某种方式扩展/替换现有的 GitInfoContributor?

spring-boot spring-boot-actuator

1
推荐指数
1
解决办法
773
查看次数

SpringBoot 2运行状况端点JSON格式已更改

我们最近在其中一个应用程序中将Spring-Boot版本升级到2.1.2。当我访问以下URL时,我注意到JSON格式发生了变化: http:// localhost:xxxx / health

更改后的结构为:{运行状况:{状态:“启动”}}

先前是:{状态:“启动”}

我的问题是;1.为什么要对其进行修改?2.是否有任何配置可以保持以前的结构?

java spring-boot spring-boot-actuator

1
推荐指数
1
解决办法
353
查看次数

如何禁用 configserver Health 页面检查默认标签 git

我有简单的配置服务器实现,当我浏览/health端点时,我得到:

{ 
  status:"UP",
  "details":{
    "configserver":{
       "status":"UP",
       "details":{
        "repositories":[
           {
              ...
Run Code Online (Sandbox Code Playgroud)

如何在我的配置服务器再次检查配置服务器运行状况的情况下停止此操作。这导致配置服务器多次调用 git,这在我的场景中是不需要的。

spring-boot spring-cloud spring-boot-actuator actuator configserver

1
推荐指数
1
解决办法
552
查看次数

Spring Boot Actuator 更改/health的格式

最近我将 spring-boot-starter-actuator 更新到 2.2.2,当我使用端点时,/health我得到:

{
    "groups": [],
    "status": {
        "code": "UP",
        "description": ""
    }
}
Run Code Online (Sandbox Code Playgroud)

代替:

{
    "status": "UP"
}

Run Code Online (Sandbox Code Playgroud)

我不知道其中的原因。任何想法?或者如何将输出 json 重新格式化为原始格式?不覆盖 HealthIndicator,仅重新格式化。

提前致谢。

spring spring-boot spring-boot-actuator

1
推荐指数
1
解决办法
1213
查看次数

spring boot 2:执行器/健康端点需要更多时间

在我的服务 /actuator/health 端点之一中,需要更多时间(大约 9 秒)。我正在使用以下依赖项,如何调试?

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

使用的 Spring Boot 版本: 2.0.3.RELEASE

谢谢,哈里

spring spring-boot-actuator

1
推荐指数
1
解决办法
896
查看次数