# Logstash update only 1 field

**URL:** <https://discuss.elastic.co/t/logstash-update-only-1-field/175066>\
**Category:** Logstash\
**Created:** [April 2, 2019, 7:58pm UTC](https://discuss.elastic.co/t/logstash-update-only-1-field/175066 "2019-04-02T19:58:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![R\_H1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/r_h1/32/43337_2.png) [@R\_H1](https://discuss.elastic.co/u/R_H1)\
**Post date:** [April 2, 2019, 7:58pm UTC](https://discuss.elastic.co/t/logstash-update-only-1-field/175066/1 "2019-04-02T19:58:23Z")

</div>

Hi,

I'm parsing a logfile and each line has in a column "Action" either "CREATE" or "CLEAR". If the Action field contains CREATE, I want to create a new document as normal. If the Action contains CLEAR it just want to update field "timestamp\_clear", how can I achieve this - so not the full document gets overwritten?

> input {  
> file {  
> path =\> "/tmp/NLegacy.OUT"  
> start\_position =\> "beginning"  
> sincedb\_path =\> "/dev/null"  
> }  
> }  
> filter {  
> csv {  
> separator =\> [";"]  
> columns =\> ["Action", "DateTimeAlarm", "DateTimeN", "DType", "MType", "Name", "AID"]  
> #convert =\> {  
> # "DateTimeAlarm" =\> "date\_time"  
> #}  
> }  
> if "CREATE" in [Action] {  
> date {  
> match =\> ["DateTimeAlarm", "MM/dd/YYYY HH:mm:ss"]  
> target =\> "@timestamp"  
> timezone =\> "UTC"  
> }  
> date {  
> match =\> ["DateTimeAlarm", "MM/dd/YYYY HH:mm:ss"]  
> target =\> "timestamp\_create"  
> timezone =\> "UTC"  
> }  
> }  
> if "CLEAR" in [Action] {  
> date {  
> match =\> ["DateTimeAlarm", "MM/dd/YYYY HH:mm:ss"]  
> target =\> "timestamp\_clear"  
> timezone =\> "UTC"  
> }  
> }  
> date {  
> match =\> ["DateTimeNotifier", "dd.MM.YY HH:mm:ss"]  
> target =\> "DateTimeNotifier"  
> timezone =\> "UTC"  
> }  
> mutate {  
> remove\_field =\> ["DateTimeAlarm", "message"]  
> }  
> }
> 
> output {  
> stdout { codec =\> rubydebug }  
> elasticsearch {  
> hosts =\> ["localhost"]  
> document\_id =\> "%{GID}"  
> index =\> "logstash-my-index"  
> timeout =\> 30  
> workers =\> 1  
> action =\> "update"  
> doc\_as\_upsert =\> true  
> }  
> }

---

<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:** [April 30, 2019, 7:58pm UTC](https://discuss.elastic.co/t/logstash-update-only-1-field/175066/2 "2019-04-30T19:58:27Z")

</div>

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