Skip to content

Using sprintf strings for action breaks update params #731

Open
@shnhrrsn

Description

@shnhrrsn

I ran into an issue where _retry_on_conflict wasn’t being included in my requests, I initially posted about it on the forums, however additional debugging has lead me to believe this is a bug:

output {
	stdout { codec => json_lines }
	elasticsearch {
		hosts => "search:9200"
		index => "posts"
		template => "/indexer/templates/posts.json"
		action => "%{[@metadata][index_action]}"
		document_id => "%{id}"
		retry_on_conflict => 5
	}
}

I added some debug code to common.rb around line 189:

      @logger.warn "About to set update params", action: @action

      if @action == 'update'
        params[:_upsert] = LogStash::Json.load(event.sprintf(@upsert)) if @upsert != ""
        params[:_script] = event.sprintf(@script) if @script != ""
        params[:_retry_on_conflict] = @retry_on_conflict
        @logger.warn "Set update params"
      end

The output is as follows:

[2018-02-08T16:17:06,751][WARN ][logstash.outputs.elasticsearch] About to set update params {:action=>"%{[@metadata][index_action]}"}

Since action isn’t evaluated at this point, the if conditional fails and the check is ignored.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions