如何解决我的config.yaml中意外的':'错误?

时间:2019-08-26 14:46:30

标签: jmx-exporter

我不知道我的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

2 个答案:

答案 0 :(得分:0)

将网址用引号引起来,例如var flavorFave = <span class=dbrecord >Favorite Ice Cream Flavor</span>

答案 1 :(得分:0)

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

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

有关更多信息,请参见此处:How to escape indicator characters (i.e. : or - ) in YAML