# We had given a task, for adding Tag but facing issue in it

**URL:** <https://discuss.elastic.co/t/we-had-given-a-task-for-adding-tag-but-facing-issue-in-it/235730>\
**Category:** Logstash\
**Created:** [June 4, 2020, 10:22am UTC](https://discuss.elastic.co/t/we-had-given-a-task-for-adding-tag-but-facing-issue-in-it/235730 "2020-06-04T10:22:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashish\_Jindal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashish_jindal/32/46023_2.png) [@Ashish\_Jindal](https://discuss.elastic.co/u/Ashish_Jindal)\
**Post date:** [June 4, 2020, 10:22am UTC](https://discuss.elastic.co/t/we-had-given-a-task-for-adding-tag-but-facing-issue-in-it/235730/1 "2020-06-04T10:22:18Z")

</div>

We had given a task, but facing issue in it. Task is -

Try adding tag A if the data read is a.

```auto
a
b
a
c
d

```

Ensure that the input data is tagged with type as **test** , and write the output to the file **output.txt** in the path usr/share/logstash.

```auto
input { 
        stdin { 
                add_tag => ["A"]
                type => "test" 
                path => ["/usr/share/logstash/output.txt"]
                 } 
        } 

```

Please let us know our mistake

---

<div class="post-metadata">

**Author:** ![ptamba](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@ptamba](https://discuss.elastic.co/u/ptamba)\
**Post date:** [June 4, 2020, 12:21pm UTC](https://discuss.elastic.co/t/we-had-given-a-task-for-adding-tag-but-facing-issue-in-it/235730/2 "2020-06-04T12:21:47Z")

</div>

your input config will add tag [“A”] and type “test” to any events coming to that input.

if you need to do conditional tags, you need to use [filter plugin](https://www.elastic.co/guide/en/logstash/current/filter-plugins.html)

> [@Ashish\_Jindal](#):
>
> write the output to the file **output.txt**

to write outputs , use file [output plugin](https://www.elastic.co/guide/en/logstash/current/output-plugins.html)

---

<div class="post-metadata">

**Author:** ![Ashish\_Jindal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashish_jindal/32/46023_2.png) [@Ashish\_Jindal](https://discuss.elastic.co/u/Ashish_Jindal)\
**Post date:** [June 4, 2020, 12:23pm UTC](https://discuss.elastic.co/t/we-had-given-a-task-for-adding-tag-but-facing-issue-in-it/235730/3 "2020-06-04T12:23:33Z")

</div>

We need dis

tag A if the data read is a.

```auto
a
b
a
c
d

```

---

<div class="post-metadata">

**Author:** ![ptamba](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@ptamba](https://discuss.elastic.co/u/ptamba)\
**Post date:** [June 4, 2020, 12:28pm UTC](https://discuss.elastic.co/t/we-had-given-a-task-for-adding-tag-but-facing-issue-in-it/235730/4 "2020-06-04T12:28:17Z")

</div>

you can use mutate filter

something like

```
filter { 
if [<field_name_>] == “A” { 
   mutate => { 
      add_tag => “A” }
   }
}
```

---

<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:** [July 2, 2020, 12:28pm UTC](https://discuss.elastic.co/t/we-had-given-a-task-for-adding-tag-but-facing-issue-in-it/235730/5 "2020-07-02T12:28:17Z")

</div>

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