运行Micronaut应用程序的本机映像时,检索Prometheus指标失败,因为它无法获取jvm指标。
当然,本机映像
预编译应用程序并仅包括实际使用的内容,但运行本机映像时使用的是哪种JVM?我认为它也是标准热点虚拟机的一个大大简化的版本。
那么,在运行本机映像时,是否有可能获取jvm指标,或者是否应该使用其他方法来检索正在运行的应用程序的cpu和内存统计信息?
在这种情况下,我使用了Micronaut,但我侦察它通常用于从任何具有普罗米修斯指标的本机映像应用程序获取指标。
复制:
- install Micronaut cli (e.g. via Homebrew on Mac)
- install GraalVM 19.2.0 (e.g. via Sdkman on Mac)
- install GraalVM native-image tool: gu install native-image
- create application: mn create-app --features=management,micrometer-prometheus,graal-native-image --build maven metrics-graalvm-image
- update src/main/resources/application.yml to allow anonymous access to prometheus endpoint:
endpoints:
all:
enabled: true
sensitive: false
- run application: man exec:exec
- check prometheus metrics can be retrieved: open http://localhost:8080/prometheus
- build application: mvn clean verify
- create native image: native-image --no-server -jar target/metrics-graalvm-image-0.1.jar
- run native image: ./metrics-graalvm-image
- get prometheus metrics: open http://localhost:8080/prometheus
否对于本机映像,将引发以下异常:
11:06:51.186 [pool-2-thread-4] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: ThreadMXBean methods
com.oracle.svm.core.jdk.UnsupportedFeatureError: ThreadMXBean methods
at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:102)
at com.oracle.svm.core.jdk.SubstrateThreadMXBean.getAllThreadIds(ManagementSupport.java:448)
at io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics.getThreadStateCount(JvmThreadMetrics.java:85)
at io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics.lambda$bindTo$0(JvmThreadMetrics.java:75)
at io.micrometer.core.instrument.internal.DefaultGauge.value(DefaultGauge.java:40)
at io.micrometer.prometheus.PrometheusMeterRegistry.lambda$newGauge$3(PrometheusMeterRegistry.java:245)
at io.micrometer.prometheus.MicrometerCollector.collect(MicrometerCollector.java:69)
at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:183)
at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:216)
at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:137)
at io.prometheus.client.exporter.common.TextFormat.write004(TextFormat.java:22)
at io.micrometer.prometheus.PrometheusMeterRegistry.scrape(PrometheusMeterRegistry.java:95)
at io.micrometer.prometheus.PrometheusMeterRegistry.scrape(PrometheusMeterRegistry.java:80)
at io.micronaut.configuration.metrics.micrometer.prometheus.management.PrometheusEndpoint.scrape(PrometheusEndpoint.java:52)
at io.micronaut.configuration.metrics.micrometer.prometheus.management.$PrometheusEndpointDefinition$$exec1.invokeInternal(Unknown Source)
at io.micronaut.context.AbstractExecutableMethod.invoke(AbstractExecutableMethod.java:144)
at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.invoke(DefaultBeanContext.java:2792)
at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:235)
at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:122)
at io.micronaut.http.server.netty.RoutingInBoundHandler.lambda$buildResultEmitter$19(RoutingInBoundHandler.java:1408)
at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:71)
at io.reactivex.Flowable.subscribe(Flowable.java:14918)
at io.reactivex.Flowable.subscribe(Flowable.java:14865)
at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
at io.reactivex.Flowable.subscribe(Flowable.java:14918)
at io.reactivex.internal.operators.flowable.FlowableMap.subscribeActual(FlowableMap.java:37)
at io.reactivex.Flowable.subscribe(Flowable.java:14918)
at io.reactivex.Flowable.subscribe(Flowable.java:14865)
at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
at io.reactivex.Flowable.subscribe(Flowable.java:14918)
at io.reactivex.internal.operators.flowable.FlowableSwitchIfEmpty.subscribeActual(FlowableSwitchIfEmpty.java:32)
at io.reactivex.Flowable.subscribe(Flowable.java:14918)
at io.reactivex.Flowable.subscribe(Flowable.java:14865)
at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
at io.reactivex.Flowable.subscribe(Flowable.java:14918)
at io.reactivex.Flowable.subscribe(Flowable.java:14868)
at io.micronaut.http.context.ServerRequestTracingPublisher.lambda$subscribe$0(ServerRequestTracingPublisher.java:52)
at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
at io.micronaut.http.context.ServerRequestTracingPublisher.subscribe(ServerRequestTracingPublisher.java:52)
at io.micronaut.configuration.metrics.binder.web.WebMetricsPublisher.subscribe(WebMetricsPublisher.java:122)
at io.reactivex.internal.operators.flowable.FlowableFromPublisher.subscribeActual(FlowableFromPublisher.java:29)
at io.reactivex.Flowable.subscribe(Flowable.java:14918)
at io.reactivex.Flowable.subscribe(Flowable.java:14865)
at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
at io.reactivex.Flowable.subscribe(Flowable.java:14918)
at io.reactivex.Flowable.subscribe(Flowable.java:14865)
at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:288)
at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:253)
at io.micrometer.core.instrument.composite.CompositeTimer.record(CompositeTimer.java:79)
at io.micrometer.core.instrument.Timer.lambda$wrap$0(Timer.java:144)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:460)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
独立可执行文件中的GraalVMnative-image
使用子策略VM-部分VM。
您可以在此处的官方GitHub存储库中找到有关它的更多详细信息。
此外,根据 SubstrateVM 限制文档,不支持 Java 提供的标准管理和调试接口。这是因为它们需要访问 Java 字节码,而对于本机映像,在运行时不再可用。
我正在尝试用GraalVM创建一个本地映像,我的代码是: 然后我把代码本身称为: 当我运行IDE或java-jar时,它可以正常工作,但当我尝试编译为本机映像时,会抛出一个错误。下面是用于编译本机映像的命令行。 错误: TypeError:invokeMember(打印)在JavaObject[com.compiler.commons.log]上。Console@113a2d320(com.com
所有使用指南都显示了如何在单个 JAR 文件上运行。但我相信大多数项目通常在类路径上使用多个JAR(例如Gradle默认方式)。如何告诉本机映像将它们全部捆绑到一个可执行文件中?
我正在尝试在MacOS上为AWS Lambda函数构建本机映像。该应用程序在IDE中编译和运行良好,但在尝试本机映像构建时,我遇到了以下问题: > 错误:4种方法中不支持的功能详细信息:错误:在映像堆中检测到Random/SplittableRandom类的实例。在映像生成过程中创建的实例具有缓存的种子值,其行为不符合预期。要查看这个对象是如何被实例化的,请使用--trace object ins
我正在使用assets文件夹中的hdpi、mdpi、xhdpi,xxhdpi和xxxhdpi来响应本地android。 但是有些图像工作正常,有时即使在提供固定的高度和宽度后,相同的图像也会调整大小(大小增加和减小)。 对于ios来说一切都很好,但是在Android的情况下,图像会失真,有时无法显示。 我已尽一切努力解决此问题,但尚无法解决。
失败:生成失败,出现异常。 错误:执行任务“:QuarkusBuild”失败。Io.Quarkus.Builder.BuildException:生成失败:由于错误导致生成失败[error]:生成步骤Io.Quarkus.Deployment.Pkg.Steps.NativeImageBuildStep#Build引发异常:java.lang.RuntimeException:未能在io.Quar
Spring Boot通过引入Spring Graal Native 0.6.0特性引入了GraalVM本机映像支持。现在,如果我们有一个成功编译的本机Spring启动应用程序,我们如何在命令行上动态更改应用程序的端口(就像我们在JVM模式中习惯的那样)? 这对于使用Docker或云提供商的部署场景至关重要……