2

ログ収集に Apache Flume を使用しています。これは私の設定ファイルです

httpagent.sources = http-source
httpagent.sinks = local-file-sink
httpagent.channels = ch3

#Define source properties 

httpagent.sources.http-source.type = org.apache.flume.source.http.HTTPSource
httpagent.sources.http-source.channels = ch3
httpagent.sources.http-source.port = 8082


# Local File Sink

httpagent.sinks.local-file-sink.type = file_roll
httpagent.sinks.local-file-sink.channel = ch3
httpagent.sinks.local-file-sink.sink.directory = /home/avinash/log_dir
httpagent.sinks.local-file-sink.sink.rollInterval = 21600

# Channels

httpagent.channels.ch3.type = memory
httpagent.channels.ch3.capacity = 1000

私のアプリケーションは正常に動作しています。私の問題は、log_dir でファイルがデフォルトで乱数 (タイムスタンプだと思います) のタイムスタンプを使用していることです。

ログファイルに適切なファイル名サフィックスを付けるには?

4

2 に答える 2

3

ドキュメントを見ると、作成されるファイルの名前を設定するためのパラメータがないようです。隠しパラメーターを探してソースに行きましたが、誰もいません:)

実装の詳細に入ると、ファイルの名前はPathManagerクラスによって管理されているようです。

private PathManager pathController;
...
@Override
public Status process() throws EventDeliveryException {
    ...
    if (outputStream == null) {
        File currentFile = pathController.getCurrentFile();
        logger.debug("Opening output stream for file {}", currentFile);
        try {
            outputStream = new BufferedOutputStream(new FileOutputStream(currentFile));
    ...
}

既にお気づきのように、これは現在のタイムスタンプに基づいています (コンストラクターと次のファイル ゲッターを示しています)。

public PathManager() {
    seriesTimestamp = System.currentTimeMillis();
    fileIndex = new AtomicInteger();
}

public File nextFile() {
    currentFile = new File(baseDirectory, seriesTimestamp + "-" + fileIndex.incrementAndGet());
    return currentFile;
}

process()したがって、カスタム パス コントローラーを使用するには、ファイル ロール シンクを拡張してメソッドをオーバーライドするしかないと思います。

于 2015-07-01T05:51:35.397 に答える