# Increment field no work

**URL:** <https://discuss.elastic.co/t/increment-field-no-work/170457>\
**Category:** Logstash\
**Created:** [March 1, 2019, 8:26am UTC](https://discuss.elastic.co/t/increment-field-no-work/170457 "2019-03-01T08:26:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hermann102](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hermann102/32/41615_2.png) [@hermann102](https://discuss.elastic.co/u/hermann102)\
**Post date:** [March 1, 2019, 8:26am UTC](https://discuss.elastic.co/t/increment-field-no-work/170457/1 "2019-03-01T08:26:06Z")

</div>

Hello All,

I would like to know how to increment a field when running an event in logstash.

I tried this, but it does not work.

```
if [Process] == "status"{

   script => "ctx._source.Rej_status++"

}

```

I want to increment field **Rej\_status** every time when Process == status.

I have this message.

```
   [ERROR] 2019-03-01 08:16:12.466 [Converge PipelineAction::Create<main>] agent - Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, 
	   :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, at line 57, column 17 (byte 1980) after filter 

```

Line 57 is script =\> ...

---

<div class="post-metadata">

**Author:** ![hermann102](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hermann102/32/41615_2.png) [@hermann102](https://discuss.elastic.co/u/hermann102)\
**Post date:** [March 1, 2019, 11:27am UTC](https://discuss.elastic.co/t/increment-field-no-work/170457/2 "2019-03-01T11:27:02Z")

</div>

I have use this

> if [Process] == "status"{  
> ruby {  
> code =\> 'event.set("Rej\_status", event.get("Rej\_status").to\_i + 1)'  
> }  
> }

---

<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:** [March 29, 2019, 11:27am UTC](https://discuss.elastic.co/t/increment-field-no-work/170457/3 "2019-03-29T11:27:04Z")

</div>

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