正如每个人在他们的GitHub页面中所看到的,属性标记有一个内部类型标记,它应该告诉Elasticsearch,如果该属性的值应该写成字符串,数字.在生成的JSON中(至少我了解到了这一点):
类型(可选,默认字符串):输入结果JSON消息上的字段。可能的值是:字符串、int、浮点数和布尔值。
但我不能让它起作用。
这是我的logback.xml文件的片段:
<appender name="ELASTIC" class="com.internetitem.logback.elasticsearch.ElasticsearchAppender">
...
<property>
<name>elapsed time (ms)</name>
<value>%X{elapsedTime}</value>
<type>int</type>
</property>
...
</appender>我正在使用JoranConfigurator配置logback:
String logConfigurationPath = "logback.xml";
if (logConfigurationPath != null) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator config = new JoranConfigurator();
config.setContext(context);
context.reset();
config.doConfigure(logConfigurationPath);
} catch (JoranException je) {
}
StatusPrinter.printInCaseOfErrorsOrWarnings(context);
}Logback配置OK,但当它试图处理该类型标记时,我得到一个错误:
testingdocker | 09:46:13,134 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@68:23 - no applicable action for [type], current ElementPath is [[configuration][appender][properties][property][type]]弹性将生成的JSON中的标记设置为字符串,我可以在Kibana中检查。
如何正确使用该标签,以便从Logback获得Kibana中的数字类型?
发布于 2018-07-17 11:12:27
好像是附件里的一个bug。
如果您看到Property.java,您将看到:
public void setType(String type) {
try {
this.type = Enum.valueOf(Type.class, type.toUpperCase());
} catch (IllegalArgumentException e) {
this.type = Type.STRING;
}
}因此,如果您设置了不在Enum中的内容,它将使用字符串。这很好。所以我们可以看到类型:
public enum Type {
STRING, INT, FLOAT, BOOLEAN
}我觉得你是有问题的!ElasticSearch不接受"int“类型,但接受”整数“类型。
有关数据类型的更多信息:
https://stackoverflow.com/questions/49650824
复制相似问题