# Can we fill up some variable dynamically using jSON field?

**URL:** <https://discuss.elastic.co/t/can-we-fill-up-some-variable-dynamically-using-json-field/116765>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [January 23, 2018, 10:46pm UTC](https://discuss.elastic.co/t/can-we-fill-up-some-variable-dynamically-using-json-field/116765 "2018-01-23T22:46:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpereira](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpereira/32/26675_2.png) [@jpereira](https://discuss.elastic.co/u/jpereira)\
**Post date:** [January 23, 2018, 10:46pm UTC](https://discuss.elastic.co/t/can-we-fill-up-some-variable-dynamically-using-json-field/116765/1 "2018-01-23T22:46:25Z")

</div>

Hi there,

In my system, we have several log types/levels that are based on the name "log\_type", e.g: "python\_log", "cache\_log", ... that are coming to the single log file "mylog.log"

I am wondering to do something like:

```auto
filebeat.prospectors:
- paths:
  - "/var/log/mysystem/*.json.log"
  type: log
  json.keys_under_root: true
  json.add_error_key: true
  overwrite_keys: true
  fields_under_root: true
  fields:
    type: "${var_from_my_json_log}_logs"

```

Has there some way to do that? any clue?

ps: I am working an POC to replace our current heka setup.

---

<div class="post-metadata">

**Author:** ![jpereira](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpereira/32/26675_2.png) [@jpereira](https://discuss.elastic.co/u/jpereira)\
**Post date:** [January 24, 2018, 4:30pm UTC](https://discuss.elastic.co/t/can-we-fill-up-some-variable-dynamically-using-json-field/116765/2 "2018-01-24T16:30:57Z")

</div>

@pierhugues, @daved Do you guys have some clue?

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [January 25, 2018, 5:24pm UTC](https://discuss.elastic.co/t/can-we-fill-up-some-variable-dynamically-using-json-field/116765/3 "2018-01-25T17:24:50Z")

</div>

So you want to set the `type` field dynamically based on a field from the JSON object?

With Filebeat alone there isn't way to accomplish this because there is no processor for mutating the data (e.g. copy some field value to `type` and append `_logs` to the value).

You should be able to do this with an [ingest node pipeline](https://www.elastic.co/guide/en/beats/filebeat/6.1/configuring-ingest-node.html) in Elasticsearch or with Logstash.

---

<div class="post-metadata">

**Author:** ![jpereira](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpereira/32/26675_2.png) [@jpereira](https://discuss.elastic.co/u/jpereira)\
**Post date:** [January 25, 2018, 5:55pm UTC](https://discuss.elastic.co/t/can-we-fill-up-some-variable-dynamically-using-json-field/116765/4 "2018-01-25T17:55:10Z")

</div>

Thank you @andrewkroh, so can we assume that the ES-ingest mechanism is faster than Logstash?

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [January 25, 2018, 7:53pm UTC](https://discuss.elastic.co/t/can-we-fill-up-some-variable-dynamically-using-json-field/116765/5 "2018-01-25T19:53:02Z")

</div>

> [@jpereira](#):
>
> we assume that the ES-ingest mechanism is faster than Logstash?

I wouldn't assuming anything about performance without testing.

Setting up ingest node to do this will probably be simpler since I assume you are already delivering the data to ES. So you only need to [`PUT`](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/put-pipeline-api.html) a pipeline and add [`pipeline`](https://www.elastic.co/guide/en/beats/filebeat/current/configuration-filebeat-options.html#_literal_pipeline_literal) to your prosector config.

---

<div class="post-metadata">

**Author:** ![jpereira](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpereira/32/26675_2.png) [@jpereira](https://discuss.elastic.co/u/jpereira)\
**Post date:** [January 29, 2018, 7:47pm UTC](https://discuss.elastic.co/t/can-we-fill-up-some-variable-dynamically-using-json-field/116765/6 "2018-01-29T19:47:39Z")

</div>

Hi @andrewkroh, Thank you for your time! I owe you some beer! 🙂

---

<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:** [February 26, 2018, 7:47pm UTC](https://discuss.elastic.co/t/can-we-fill-up-some-variable-dynamically-using-json-field/116765/7 "2018-02-26T19:47:44Z")

</div>

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