Increment a integer field in Logstash

时间:2016-07-11 22:25:42

标签: elasticsearch logstash pipeline

I am using logstash to upload logs into elasticsearch. Could I increment a field in my .conf file?

For example, I have a field 'count = 0;' I hope to increment it to 1 when meet some conditions.

Thank you!

1 个答案:

答案 0 :(得分:0)

在编写elasticsearch的输出配置时,您需要指定

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <ui:composition template="/template.xhtml">
        <ui:define name="title">c1 Index</ui:define>
        <ui:define name="h1">index.xhtml</ui:define>
        <ui:define name="content">
            <h:form>
                <div>Name: #{requestScopedBean.name}</div>
                <label>Name:
                    <h:inputText id="username"
                                 title="Name: "
                                 value="#{requestScopedBean.name}"
                                 required="true"
                                 requiredMessage="Error: A name is required."
                                 maxlength="25" />
                </label>
                <br/>
                <h:commandButton id="submit" value="Submit"
                                 action="index" />
                <h:commandButton id="reset" value="Reset" type="reset" />
            </h:form>
            <div class="messagecolor">
                <h:messages showSummary="true"
                            showDetail="false"
                            errorStyle="color: #d20005"
                            infoStyle="color: blue"/>
            </div>
        </ui:define>
    </ui:composition>
</html>

并编写一个脚本,它将检查您的状况并在条件满足时更新字段。您可以在弹性搜索中查看Event Dependent Configuration script选项以供参考。