小编Che*_*rry的帖子

如何获得 2 个不同的普罗米修斯指标之间的差异?

考虑指标示例:

increase(application_executor_recordsWritten[20m])
increase(kafka_server_brokertopicmetrics_messagesin_total{topic="my_topic"}[20m])
Run Code Online (Sandbox Code Playgroud)

如果我在普罗米修斯图上单独执行这些指标 - 一切正常。但是当尝试类似的东西时:

increase(application_executor_recordsWritten[20m]) -  increase(kafka_server_brokertopicmetrics_messagesin_total{topic="my_topic"}[20m])
Run Code Online (Sandbox Code Playgroud)

我得到了No datapoints error

  1. 可能是因为application_executor_recordsWritten收到了过去 1 小时,而kafka_server_brokertopicmetrics_messagesin_total收到了 6 个多小时。
  2. 可能是因为这些指标具有不同的“收集设置”,请考虑 prometheus 控制台输出:

    application_executor_recordsWritten

    {app_name="app-name",exported_instance="application_111111111111111111",exported_job="application_111111111111111111",instance="XX.XXX.X.XX",job="job_name",number="1",role="executor" }

    kafka_server_brokertopicmetrics_messagesin_total

    {instance="XX.XXX.X.XX",job="job_name",topic="my_topic"}

普罗米修斯使用ignore(???)关键字之类的东西,但我无法弄清楚它是如何工作的以及如何将其应用于这些指标。

任何想法如何执行指标差异?什么是正确的语法?

metrics apache-kafka apache-spark prometheus prometheus-operator

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

如何从匿名类访问私有方法?

假设我上课:

MyObject b = new MyObject(){
    private void method(){}
}
Run Code Online (Sandbox Code Playgroud)

是否可以通过反射获得method()?对于toString我可以写:

MyObject.class.getMethod("toString");
Run Code Online (Sandbox Code Playgroud)

但是对于新创建的私有方法呢?

java reflection methods object

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

如何在 Scala 中的 case 类中添加自定义行为来复制函数?

是否可以在 case 类中添加自定义行为来复制函数?

像这样的东西:

case class User (version: Integer) { //other fields are omitted
    //something like this
    override def copy (...) {
        return copy(version = version + 1, ...)
    }
}
Run Code Online (Sandbox Code Playgroud)

所以我不想重写复制功能,只需添加增加版本字段并复制其他字段。我怎样才能做到这一点?

scala copy function case-class

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

如何使spring服务于静态html文件?

我创建了没有web.xml的Spring应用程序.我想从WEB-INF提供静态index.html.以下是来源:

public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
    @Override
    protected Class<?>[] getRootConfigClasses() {return new Class<?>[]{AppConfiguration.class};}

    @Override
    protected Class<?>[] getServletConfigClasses() {return new Class[]{WebConfiguration.class};}

    @Override
    protected String[] getServletMappings() {return new String[]{"/ololo/*"};}
}

import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfiguration {}


@Configuration
public class WebConfiguration extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/index.html").addResourceLocations("classpath:/WEB-INF/view/index.html");
    }
}
Run Code Online (Sandbox Code Playgroud)

一切似乎都是正确的 - index.html被放入webapp\WEB-INF\view\index.html,但我仍然进入日志(contextRoot是我部署的战争的上下文根):

[2015-09-11T11:06:21.247+0500] [glassfish 4.1] [WARNING] [] [org.springframework.web.servlet.PageNotFound] [tid: _ThreadID=29 _ThreadName=http-listener-1(3)] [timeMillis: 1441951581247] [levelValue: 900] [[
  No mapping found for HTTP request with …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc

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

从 XBRL 文档中获取特定值

我一直在使用Gepsio尝试通过他们的 EDGAR 系统来处理标准 SEC XBRL 文件,尽管我多次尝试解决这个问题,但似乎我还是不知所措。

当您从任何文档中提取事实,并且您有兴趣检索“收入”时,根据特定的 US-GAAP 标准,可能有多达 200 个事实及其关联的收入标签。虽然每个 ID 都是唯一的,但弄清楚哪个 ID 相当于您想要的特定收入类型似乎并不是很简单。我感兴趣的收入与合并运营报表中出现的收入相同,即净收入,而不是文档中一些模糊的其他类型的收入。然而,像Arelle这样的 XBRL 查看器每次都能得到正确的结果,尽管浏览了 Arelle 的源代码,我也无法弄清楚他们使用的逻辑。

任何能够引导我理解这一点的正确方向的人将不胜感激。

.net c# xbrl gepsio arelle

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

如何等待通过cli创建ec2实例?

例如,我运行以下命令:

aws ec2 run-instances --instance-type i3.xlarge --image-id ami-00000000 --user-data file://myfile.sh
Run Code Online (Sandbox Code Playgroud)

这导致实例创建开始。有没有一种方法可以执行此命令,并等待创建EC2并执行所有状态检查?

amazon-ec2 amazon-web-services aws-cli

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

Spring Flux缓存项是如何管理的

考虑代码示例:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

import java.time.Duration;

import static com.google.common.collect.ImmutableMap.of;

@Component
public class Scratch {

    @Autowired
    private WebClient webClient;

    public Mono<MyClass> getMyClass(Long id) {
        return webClient.get()
                .uri("{id}", of("id", id))
                .retrieve()
                .bodyToMono(MyClass.class)
                .cache(Duration.ofHours(1));
    }
}
Run Code Online (Sandbox Code Playgroud)

规格说明

将保留无限的历史记录,但应用每个项目的到期超时

什么是项目以及缓存什么?

  1. 整个 http 调用都会被缓存。例如,如果我调用方法.get().uri()id = 1任何后续调用都会被缓存吗?或者
  2. Mono<MyClass>被缓存。例如,任何后续调用都Mono.map将使用缓存的值?

在这两种情况下,什么被视为项目?

java spring project-reactor spring-webflux

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

Reactive Spring在REST端点测试中不支持ServerHttpRequest作为参数吗?

现在的问题是非常相似,这一个。除了我使用的事实:

  1. org.springframework.http.server.ServerHttpRequest 不是 HttpServletRequest。
  2. 测试代码中有异常。实际通话有效。

码:

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SecurityTests.SecurityTestsApplication.class)
@TestPropertySource(properties = {""})
@AutoConfigureWebTestClient
public class SecurityTests {
        @Test 
        public void myTest() { 
            //send request to myUrl and got 500 
        }
}

@RestController
@RequestMapping("/myPath")
public class MyController {
    @PostMapping
    public Mono<Void> myMethod(ServerHttpRequest request) {
        return Mono.empty()
    }

}
Run Code Online (Sandbox Code Playgroud)

例外是:

java.lang.IllegalStateException: Failed to resolve argument 1 of type 'org.springframework.http.server.ServerHttpRequest' on public reactor.core.publisher.Mono<java.lang.Void> MyController$MockitoMock$606550817.myMethod(org.springframework.http.server.ServerHttpRequest)
        at org.springframework.web.reactive.result.method.InvocableHandlerMethod.getArgumentError(InvocableHandlerMethod.java:228) ~[spring-webflux-5.0.7.RELEASE.jar:5.0.7.RELEASE]
        at org.springframework.web.reactive.result.method.InvocableHandlerMethod.resolveArg(InvocableHandlerMethod.java:223) ~[spring-webflux-5.0.7.RELEASE.jar:5.0.7.RELEASE]
        at org.springframework.web.reactive.result.method.InvocableHandlerMethod.lambda$null$1(InvocableHandlerMethod.java:179) ~[spring-webflux-5.0.7.RELEASE.jar:5.0.7.RELEASE]
        at java.util.Optional.orElseGet(Optional.java:267) ~[na:1.8.0_131]
        at org.springframework.web.reactive.result.method.InvocableHandlerMethod.lambda$resolveArguments$2(InvocableHandlerMethod.java:177) ~[spring-webflux-5.0.7.RELEASE.jar:5.0.7.RELEASE]
        at …
Run Code Online (Sandbox Code Playgroud)

java spring project-reactor spring-webflux

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

如何使用 Joi 验证一个字符串不等于另一个(黑名单)?

一个经典的例子是:

schema = Joi.object().keys({
    my_string: Joi.string().valid("myString").required()
});
Run Code Online (Sandbox Code Playgroud)

这将验证该对象具有my_string必须具有myStringas 值的字段。

如何检查重点 my_string等于notAllowedString

javascript node.js joi

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

重新填充率对 AWS Step Functions 意味着什么?

限制 - AWS Step Functions显示AWS Step Functions 的限制。有人可以解释一下他们所说的bucket size和是什么意思Refill Rate per Second吗?

amazon-web-services aws-step-functions

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