Logstash Clone Filter Plugin

The Clone filter plugin in Logstash is used to create duplicate events within the processing pipeline. It's particularly useful when you need to create multiple versions of an event, each with slight modifications, or when you want to send the same event to multiple outputs with different configurations.

Syntax

clone {
  clones => <number>
}

For more detailed information, refer to the official Logstash Clone filter plugin documentation.

Example Use Case and Usage

A common use case for the Clone filter is when you need to send the same log event to multiple destinations, each with different formatting or enrichment.

filter {
  clone {
    clones => 1
  }
  if [type] == "clone" {
    mutate {
      add_field => { "cloned" => "true" }
    }
  }
}

In this example, each incoming event is cloned once. The original event passes through unchanged, while the cloned event gets a new field "cloned" set to "true".

Common Issues and Best Practices

  • Be cautious when using the Clone filter, as it can significantly increase the number of events processed by Logstash, potentially impacting performance.
  • Always consider whether cloning is necessary or if you can achieve your goal through other means, such as multiple outputs or conditional processing.
  • When cloning events, make sure to add a distinguishing field or tag to differentiate between the original and cloned events in subsequent processing or output.

Frequently Asked Questions

Q: How many clones can I create with the Clone filter?
A: You can create as many clones as you specify in the clones parameter. However, be mindful of the performance impact when creating a large number of clones.

Q: Does cloning an event copy all its fields?
A: Yes, when you clone an event, all fields from the original event are copied to the cloned event.

Q: Can I modify the cloned events differently from the original?
A: Yes, you can use conditional processing based on a tag or field to apply different filters or modifications to cloned events.

Q: Does the Clone filter affect the original event?
A: No, the original event passes through the Clone filter unchanged. Only the cloned copies can be modified in subsequent processing.

Q: How can I identify which events are clones in my output?
A: It's a best practice to add a distinguishing field or tag to cloned events using a Mutate filter after cloning, so you can easily identify them in your output or subsequent processing.

Pulse - Elasticsearch Operations Done Right

Pulse can solve your Elasticsearch issues

Subscribe to the Pulse Newsletter

Get early access to new Pulse features, insightful blogs & exclusive events , webinars, and workshops.

We use cookies to provide an optimized user experience and understand our traffic. To learn more, read our use of cookies; otherwise, please choose 'Accept Cookies' to continue using our website.