# About Comments within Logstash Plugin Config

**URL:** <https://discuss.elastic.co/t/about-comments-within-logstash-plugin-config/295120>\
**Category:** Logstash\
**Created:** [January 22, 2022, 3:24pm UTC](https://discuss.elastic.co/t/about-comments-within-logstash-plugin-config/295120 "2022-01-22T15:24:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![usb](https://avatars.discourse-cdn.com/v4/letter/u/85f322/32.png) [@usb](https://discuss.elastic.co/u/usb)\
**Post date:** [January 22, 2022, 3:24pm UTC](https://discuss.elastic.co/t/about-comments-within-logstash-plugin-config/295120/1 "2022-01-22T15:24:34Z")

</div>

Hi everyone. Recently, I am trying to add more comments to my Logstash pipeline config so that it is more understandable. However, I found that it seems comments cannot be added in-between lines of a plugin config.

For example, the following pipeline will result in the error `given configuration is invalid. Reason: Expected one of [\t\r\n], "#", "{", "}"`:

```auto
input {
  http {}
}

filter {
  mutate {
    copy => {
      # Copy `source` to `source2`
      source => 'source2'
      # Copy `target` to `target2`
      target => 'target2'
    }
  }
}

output {
  stdout {
    codec => rubydebug
  }
}

```

But the following pipeline is fine:

```auto
input {
  http {}
}

filter {
  mutate {
    copy => {
      # Copy `source` to `source2`
      source => 'source2'
      target => 'target2'
      # Copy `target` to `target2`
    }
  }
}

output {
  stdout {
    codec => rubydebug
  }
}

```

It would be greatly appreciated if anyone could let me know what's the problem -maybe it is just me overlooking somewhere in the documentation stating the first pipeline is not a valid.

---

<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:** [January 22, 2022, 4:43pm UTC](https://discuss.elastic.co/t/about-comments-within-logstash-plugin-config/295120/2 "2022-01-22T16:43:56Z")

</div>

> [@usb](#):
>
> it seems comments cannot be added in-between lines of a plugin config

That is correct. This [github issue](https://github.com/elastic/logstash/issues/12665) includes a pointer to the formal grammar for configuration files and it clearly does not allow comments between hash entries. You can have \_ before a set of attributes, or after a set of attributes, but not _in_ a set of attributes.

One comment claims using array syntax is a workaround

```
mutate {
    copy => [
        "source", "source2", # Copy `source` to `source2`
        "target", "target2" # Copy `target` to `target2`
    ]
}

```

and looking at the definition of an array in the grammar that does seem like it would work. Personally I do not like it as a solution.

---

<div class="post-metadata">

**Author:** ![usb](https://avatars.discourse-cdn.com/v4/letter/u/85f322/32.png) [@usb](https://discuss.elastic.co/u/usb)\
**Post date:** [January 23, 2022, 4:34am UTC](https://discuss.elastic.co/t/about-comments-within-logstash-plugin-config/295120/3 "2022-01-23T04:34:53Z")

</div>

Thank you for the prompt reply. I think maybe I would just divide the handlings into separate `mutate` plugins because of the logical disjoint (it can also avoid the case where missing in earlier fields causing latter fields not to be processed)

---

<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 20, 2022, 4:35am UTC](https://discuss.elastic.co/t/about-comments-within-logstash-plugin-config/295120/4 "2022-02-20T04:35:48Z")

</div>

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