# Multiple outputs with different formats

**URL:** <https://discuss.elastic.co/t/multiple-outputs-with-different-formats/196285>\
**Category:** Logstash\
**Created:** [August 22, 2019, 9:30am UTC](https://discuss.elastic.co/t/multiple-outputs-with-different-formats/196285 "2019-08-22T09:30:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![programagor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/programagor/32/40183_2.png) [@programagor](https://discuss.elastic.co/u/programagor)\
**Post date:** [August 22, 2019, 9:30am UTC](https://discuss.elastic.co/t/multiple-outputs-with-different-formats/196285/1 "2019-08-22T09:30:58Z")

</div>

Greetings

I am using Logstash to parse and index event logs into Elasticsearch. My pipeline has the following form:

```auto
input{
  # input plugins and their config
}

filter{
  # lots of parsing
  # in some cases, event is tagged as long_term
}

output{
  # index_A in elasticsearch with short-term retention policy
}

```

Now, I would like all events tagged with `long_term` to be ALSO indexed into an `index_B`. This can be done like so:

```auto
output{
  # index_A in elasticsearch
  if "long_term" in [tags] {
    # index_B in elasticsearch, with long-term retention policy
  }
}

```

However, my `index_B` requires additional processing - namely replacing email with a fingerprint, and keeping only small subset of the fields.

Can I have two output clauses with a filter clause in between, with the execution proceeding sequentially?

---

<div class="post-metadata">

**Author:** ![programagor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/programagor/32/40183_2.png) [@programagor](https://discuss.elastic.co/u/programagor)\
**Post date:** [August 22, 2019, 10:13am UTC](https://discuss.elastic.co/t/multiple-outputs-with-different-formats/196285/2 "2019-08-22T10:13:30Z")

</div>

I was thinking I could have a different template for `index_b`, but how do I make sure that only fields specified in the template are stored?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 22, 2019, 12:17pm UTC](https://discuss.elastic.co/t/multiple-outputs-with-different-formats/196285/3 "2019-08-22T12:17:04Z")

</div>

If you just want to ignore some fields in index B you could define the fields you want in the template and disable [dynamic mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-field-mapping.html).

If you need to do data transformations while ingesting in elasticsearch you may be able to do it using a [script processor](https://www.elastic.co/guide/en/elasticsearch/reference/current/script-processor.html). I believe that supports replacing a field with a fingerprint or hash, but that is an elasticsearch question, not a logstash question.

If you want to have logstash remove fields and replace fields with hashes I would look at pipeline to pipeline comms with a [forked path](https://www.elastic.co/guide/en/logstash/current/pipeline-to-pipeline.html#forked-path-pattern) pattern.

---

<div class="post-metadata">

**Author:** ![programagor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/programagor/32/40183_2.png) [@programagor](https://discuss.elastic.co/u/programagor)\
**Post date:** [August 26, 2019, 8:42am UTC](https://discuss.elastic.co/t/multiple-outputs-with-different-formats/196285/4 "2019-08-26T08:42:38Z")

</div>

I decided to disable the dynamic mapping, but while the fields such as `email` are not indexed, they are still stored in the `_source` field. To address this, I had to include this in my template:

```auto
"_source": {
  "includes": [
    # List of all fields that are to be stored
  ]
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 23, 2019, 8:52am UTC](https://discuss.elastic.co/t/multiple-outputs-with-different-formats/196285/5 "2019-09-23T08:52:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
