0

我不知道我的 config.yaml 有什么问题

我按照官方网站上的示例配置了我的 config.yaml,当我完成配置时。我运行命令:

java -javaagent:./jmx_prometheus_javaagent-0.12.0.jar=8980:config.yaml -jar /usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56/bin/activemq.jar

但我收到关于我的 config.yaml 的错误

这是我的配置文件

[root@sz-7-centos162 test]# cat config.yaml 
{
        startDelaySeconds: 0,
        username: admin,
        password: admin,
        jmxUrl: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi,
        ssl: false,
        lowercaseOutputName: false,
        lowercaseOutputLabelNames: false
}

这是错误日志:

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: while scanning a plain scalar
 in 'reader', line 5, column 17:
            jmxUrl: service:jmx:rmi:///jndi/rmi://lo ... 
                    ^
found unexpected ':'
 in 'reader', line 5, column 24:
            jmxUrl: service:jmx:rmi:///jndi/rmi://localhost ... 
                           ^
Please check http://pyyaml.org/wiki/YAMLColonInFlowContext for details.

    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.scanner.ScannerImpl.scanPlain(ScannerImpl.java:2013)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.scanner.ScannerImpl.fetchPlain(ScannerImpl.java:1046)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:401)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.parser.ParserImpl$ParseFlowMappingValue.produce(ParserImpl.java:762)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:132)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:229)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:120)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:450)
    at io.prometheus.jmx.shaded.org.yaml.snakeyaml.Yaml.load(Yaml.java:393)
    at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.<init>(JmxCollector.java:74)
    at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:29)
    ... 6 more
FATAL ERROR in native method: processing of -javaagent failed
Aborted
4

2 回答 2

0

将 URL 用引号括起来,例如jmxUrl: "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi"

于 2019-08-26T14:49:23.043 回答
0

您需要将值用引号括起来,如下所示:

jmxUrl: "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi",

有关更多信息,请参见此处:如何在 YAML 中转义指示符(即 : 或 - )

于 2019-08-26T14:50:46.843 回答