读取包含日期名称的日志文件时出现问题

时间:2015-11-22 08:33:46

标签: elasticsearch logstash logstash-grok

我有2个linux盒子设置,其中1个盒子包含一个组件,它生成日志和logstash以便传输日志。在其他方面,我有redis elasticsearch和logstash。 logstash将充当logstash索引器来处理数据。

现在我的问题是,在第一个盒子组件中每天生成新的日志文件,但只有日志文件名称的差异因日期而异。

计数器-20151120-0.log

计数器-20151121-0.log

counter-20151122-0.log

依此类推,我在logstash发货人配置文件中包含了以下类型的代码:

<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appBarLayout"
    android:layout_width="match_parent"
    android:layout_height="400dp"
    android:background="@android:color/transparent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsingToolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <View
            android:id="@+id/emptyView"
            android:layout_width="match_parent"
            android:layout_height="400dp"
            android:background="@android:color/transparent"
            app:layout_collapseMode="parallax"/>

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

        <EditText
            android:id="@+id/editText"
            android:paddingLeft="16dp"
            android:inputType="textAutoCorrect"
            android:layout_centerVertical="true"
            android:background="@android:color/transparent"
            android:layout_width="match_parent"
            android:layout_height="56dp"/>

    </RelativeLayout>

</RelativeLayout>

在我的logstash索引器中,我有以下类型的代码来捕获这些日志文件:

file {
    path => "/opt/data/logs/counters-%{YEAR}%{MONTHNUM}%{MONTHDAY}*.log"
    type => "rg_counters"
  }

请注意,这是正常工作的设置,其他类型的日志文件已成功转移和处理,因此不存在设置问题。

问题是如何处理包含日期文件名的日志文件。

这里有任何帮助吗?

提前致谢!!

1 个答案:

答案 0 :(得分:1)

根据评论......

而不是尝试在路径中使用正则表达式模式:

path => "/opt/data/logs/counters-%{YEAR}%{MONTHNUM}%{MONTHDAY}*.log"

只使用glob模式:

path => "/opt/data/logs/counters-*.log"

logstash将记住之前看到的文件(inode)。