# Expected one of #, \\", ', -, \[, / at line 77, column 52 (byte 2039)

**URL:** <https://discuss.elastic.co/t/expected-one-of-at-line-77-column-52-byte-2039/164505>\
**Category:** Logstash\
**Created:** [January 16, 2019, 4:39pm UTC](https://discuss.elastic.co/t/expected-one-of-at-line-77-column-52-byte-2039/164505 "2019-01-16T16:39:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![exocore123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exocore123/32/45130_2.png) [@exocore123](https://discuss.elastic.co/u/exocore123)\
**Post date:** [January 16, 2019, 4:39pm UTC](https://discuss.elastic.co/t/expected-one-of-at-line-77-column-52-byte-2039/164505/1 "2019-01-16T16:39:19Z")

</div>

> Failed to execute action {:action=\>LogStash::PipelineAction::Create/pipeline\_id:main, :exception=\>"LogStash::ConfigurationError", :message=\>"Expected one of #, ", ', -, [, / at line 77, column 52 (byte 2039) after filter {\n\t#Extract key value pairs from fields\n\tkv {\n\t\tsource =\> "\_fields"\n\t\tfield\_split =\> ";"\n\t}\n # Unify the format of MessageType\n if ([operation] == "unmarshalRequest") {\n mutate {\n add\_field =\> {"messageType" =\> "%{request}Request"}\n }\n }\n if ([messageType] == "CreateOrder" or [messageType] == "ChangeOrder") {\n if ([stage] == "end") {\n mutate {\n update =\> {"messageType" =\> "%{messageType}Response"}\n }\n }\n }\n\truby {\n\t code =\> "event.set('kafka\_retry\_time', (Time.now.getutc.to\_i - event.get('@timestamp').to\_i) / 60)"\n\t}\n\n # check the retry time and retry count\n\tif ([kafka\_retry\_count] and [kafka\_retry\_count] \> ", :backtrace=\>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:42:in `compile_imperative'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:50:in `compile\_graph'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:12:in `block in compile_sources'", "org/jruby/RubyArray.java:2486:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:11:in `compile_sources'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:51:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:169:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:40:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:315:in `block in converge_state'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:141:in `with\_pipelines'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:312:in `block in converge_state'", "org/jruby/RubyArray.java:1734:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:299:in `converge_state'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:166:in `block in converge\_state\_and\_update'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:141:in `with_pipelines'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:164:in `converge\_state\_and\_update'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:90:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:348:in `block in execute'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24:in `block in initialize'"]}

```
filter {
	#Extract key value pairs from fields
	kv {
		source => "_fields"
		field_split => ";"
	}
    # Unify the format of MessageType
    if ([operation] == "unmarshalRequest") {
        mutate {
            add_field => {"messageType" => "%{request}Request"}
        }
    }
    if ([messageType] == "CreateOrder" or [messageType] == "ChangeOrder") {
        if ([stage] == "end") {
            mutate {
                update => {"messageType" => "%{messageType}Response"}
            }
        }
    }
	ruby {
	    code => "event.set('kafka_retry_time') = (Time.now.getutc.to_i - event.get('@timestamp').to_i) / 60"
	}

    # check the retry time and retry count
	if ([kafka_retry_count] and [kafka_retry_count] > ${KAFKA_MAX_RETRY_COUNT} and [kafka_retry_time]> ${KAFKA_MAX_RETRY_TIME}) {
	    ruby {
	        code => "puts 'Max Retries Reached:' + event.get('kafka_retry_count').to_s + '---' + event.get('kafka_retry_time').to_s + '---' + event.get('orderOperationCorrelationID').to_s"
	    }
	    drop{}
	}...

```

I could build this on my local machine, but on a remote machine, keeps getting this error message.

\*typo of error message and code

---

<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 16, 2019, 5:00pm UTC](https://discuss.elastic.co/t/expected-one-of-at-line-77-column-52-byte-2039/164505/2 "2019-01-16T17:00:28Z")

</div>

> [@exocore123](#):
>
> Expected one of #, ", ', -, [, / at line 77, column 52 (byte 2039) after [...] # check the retry time and retry count\n\tif ([kafka\_retry\_count] and [kafka\_retry\_count] \> "

And you say your configuration contains

```
if ([kafka_retry_count] and [kafka_retry_time]> ${KAFKA_MAX_RETRY_TIME}) {

```

That is not consistent (one is checking the retry\_time and the other the retry\_count), but it suggests it is failing when it tries to parse the environment substitution ${KAFKA\_MAX\_RETRY\_TIME}.

The documentation says "You can set environment variable references in the configuration for Logstash plugins by using `${var}` ." You are trying to do an environment variable reference in the logic of the filter, which is not a plugin configuration. It is not, as far as I know, expected to work.

---

<div class="post-metadata">

**Author:** ![exocore123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exocore123/32/45130_2.png) [@exocore123](https://discuss.elastic.co/u/exocore123)\
**Post date:** [January 16, 2019, 5:10pm UTC](https://discuss.elastic.co/t/expected-one-of-at-line-77-column-52-byte-2039/164505/3 "2019-01-16T17:10:11Z")

</div>

@Badger

Thanks for your response, regarding the inconsistency, that was my fault for copying the wrong code which I modified post-error message. Please see latest edit.

Actually I have tried using just integers instead of environment variable, there is still some hidden underlying issue (which I suspect it shouldnt be because of the env variable when my local machine can built). Will get back to you upon better investigation.

---

<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 16, 2019, 5:13pm UTC](https://discuss.elastic.co/t/expected-one-of-at-line-77-column-52-byte-2039/164505/4 "2019-01-16T17:13:22Z")

</div>

If you want to post a configuration, then paste it into the edit pane, select it, and click on \</\> in the toolbar above the edit pane. That will indent it, which results in the formatting and special characters being preserved.

---

<div class="post-metadata">

**Author:** ![exocore123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exocore123/32/45130_2.png) [@exocore123](https://discuss.elastic.co/u/exocore123)\
**Post date:** [January 16, 2019, 6:37pm UTC](https://discuss.elastic.co/t/expected-one-of-at-line-77-column-52-byte-2039/164505/5 "2019-01-16T18:37:31Z")

</div>

I was actually able to reproduce this issue on my local machine now. And that seems to be a env ariable issue after I forced a regular value... but this document suggests that environment variable works within filters?

[https://www.elastic.co/guide/en/logstash/current/environment-variables.html](https://www.elastic.co/guide/en/logstash/current/environment-variables.html)

---

<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 16, 2019, 6:53pm UTC](https://discuss.elastic.co/t/expected-one-of-at-line-77-column-52-byte-2039/164505/6 "2019-01-16T18:53:47Z")

</div>

> [@exocore123](#):
>
> KAFKA\_MAX\_RETRY\_COUNT

It works within plugins.

```
filter {
    if "${KAFKA_MAX_RETRY_COUNT}" ...

```

is NOT inside a plugin. However, you could do

```
mutate { add_field => { "[@metadata][kafka_max_retry_count]" => "${KAFKA_MAX_RETRY_COUNT}" } }
mutate { convert => { "[@metadata][kafka_max_retry_count]" => "integer" } }
if [@metadata][kafka_max_retry_count] ...

```

and that will work. (Fields inside [@metadata] are not added to the event that is output, so it is handy for stashing temporary variables.)

---

<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 13, 2019, 6:53pm UTC](https://discuss.elastic.co/t/expected-one-of-at-line-77-column-52-byte-2039/164505/7 "2019-02-13T18:53:52Z")

</div>

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