小编Bam*_*bus的帖子

Eureka netflix - 集群服务器列表为空

我想在没有 Spring Boot 的情况下进行服务发现。所以我下载了 netflix 项目示例,因为它的 gradle 项目我想使它成为 maven。

所以我创建了 maven 项目,导入了类和配置,并添加了依赖项。

我将它eureka.war放在 Tomcat webapps 文件夹中,然后启动了 eureka 服务器。

但是当我在 eclipse 中运行应用程序时,我收到了一个错误。

错误 c.netflix.discovery.DiscoveryClient - DiscoveryClient_UNKNOWN/DESKTOP-B997GFD - 无法刷新其缓存!status = 没有已知的尤里卡服务器;集群服务器列表为空 com.netflix.discovery.shared.transport.TransportException: 没有已知的尤里卡服务器;集群服务器列表为空

并且无法从尤里卡获取示例服务的实例以与之交谈

netflix netflix-eureka

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

普罗米修斯指标 - 未找到

我有 Spring Boot 应用程序,并且正在使用 vertx。我想监控服务和 jvm,为此我选择了 Prometheus。

这是我的 MonitoringConfig 类:

@Configuration
public class MonitoringConfig {

    @Bean
    SpringBootMetricsCollector springBootMetricsCollector(Collection<PublicMetrics> publicMetrics) {

        SpringBootMetricsCollector springBootMetricsCollector = new SpringBootMetricsCollector(publicMetrics);
        springBootMetricsCollector.register();

        return springBootMetricsCollector;
    }

    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        DefaultExports.initialize();
        return new ServletRegistrationBean(new MetricsServlet(), "/prometheus");
    }

}
Run Code Online (Sandbox Code Playgroud)

这是我的依赖项:

<dependency>
            <groupId>com.moelholm</groupId>
            <artifactId>prometheus-spring-boot-starter</artifactId>
            <version>1.0.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.prometheus/simpleclient -->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient</artifactId>
            <version>0.0.25</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.prometheus/simpleclient_hotspot -->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_hotspot</artifactId>
            <version>0.0.25</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.prometheus/simpleclient_spring_boot -->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_spring_boot</artifactId>
            <version>0.0.25</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.prometheus/simpleclient_servlet -->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_servlet</artifactId>
            <version>0.0.25</version>
        </dependency> …
Run Code Online (Sandbox Code Playgroud)

java vert.x spring-boot prometheus

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

JSch 登录文件

我想将 JSch 日志保存在文件中,因为它在控制台中没有显示任何内容。

这是我的代码:

public boolean openConnection() throws ItsSshException {
    boolean connectSuccess = false;

    JSch.setLogger(new MyLogger());

    Properties config = new Properties();
    config.put("StrictHostKeyChecking", "no");
    jschSSH.setConfig(config);
    try {
        sshSession = jschSSH.getSession(username, hostname, port);
        sshSession.setPassword(password);
        sshSession.connect(connectionTimeout);
        LOGGER.info("Connection timeout : " + connectionTimeout);
        Thread.sleep(1000);
        sshHChannel = sshSession.openChannel("shell");
        sshHChannel.connect();
        in = sshHChannel.getInputStream();
        out = new PrintStream(sshHChannel.getOutputStream());
        clearInitialSocketState();
        connectSuccess = true;
    } catch (Exception e) {
        LOGGER.error("Error during connectiong to host: " + hostname +
                     ", port: " + port + "!", e);
        throw new ItsSshException("Error …
Run Code Online (Sandbox Code Playgroud)

java ssh logging jsch

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

普罗米修斯仪表没有改变值 - 弹簧靴

我有带有肥皂客户端的 Spring Boot 应用程序,它正在检查某些应用程序是否还活着。如果应用程序处于活动状态,我将仪表设置为 1,否则我将其设置为 0。问题是当我启动应用程序并发送请求并且响应正常时,我在普罗米修斯中看到仪表值为 1,但是当我停止服务器并发送另一个请求时,我希望仪表值应为 0,但又为 1。

这是我的代码。我也尝试过使用原子整数,但仍然存在问题。

 @Autowired
 MeterRegistry meterRegistry;


  public void callWebService() throws IOException {

String request = "message";
List<String> list = convertUsingJava8(url);
for (String string : list) {
  // AtomicInteger n = meterRegistry.gauge(string, new AtomicInteger(0));
  // Gauge shit = Gauge.build().name(string).help("shit").register();
  StringEntity stringEntity;
  stringEntity = new StringEntity(request, "UTF-8");
  stringEntity.setChunked(true);
  HttpPost httpPost = new HttpPost(string);
  httpPost.setEntity(stringEntity);
  try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
    HttpResponse response = null;
    response = httpClient.execute(httpPost);
    StringBuilder total = getMessage(response);
    System.out.println(total.toString());
    if (total.toString().contains("true")) { …
Run Code Online (Sandbox Code Playgroud)

java spring-boot prometheus micrometer

5
推荐指数
0
解决办法
743
查看次数

尤里卡状态 ip 而不是桌面或本地主机

我正在与 Eureka Netflix 合作,但遇到了一个小问题。当应用程序在 eureka 上自行注册时,它会像 DESKTOP 一样注册....

在此处输入图片说明

我想像http://IP:PORT

这是我的服务器属性:

server.port=8761

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.instance.preferIpAddress=true
logging.level.com.netflix.eureka=OFF
logging.level.com.netflix.discovery=OFF
Run Code Online (Sandbox Code Playgroud)

这是客户端:

spring:
 application:
  name: Test 2
 server:
port: 0
eureka:
 client:
  serviceUrl:
   defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
  instance:
    preferIpAddress: true
Run Code Online (Sandbox Code Playgroud)

所以我认为这是一些配置问题,但我不知道是什么。

spring-boot netflix-eureka

3
推荐指数
2
解决办法
7831
查看次数