File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
lib/logstash/outputs/elasticsearch Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,8 @@ def multi_receive(events)
32
32
33
33
# Convert the event into a 3-tuple of action, params, and event
34
34
def event_action_tuple ( event )
35
- params = event_action_params ( event )
36
35
action = event . sprintf ( @action )
36
+ params = event_action_params ( action , event )
37
37
[ action , params , event ]
38
38
end
39
39
@@ -123,8 +123,8 @@ def submit(actions)
123
123
actions_to_retry
124
124
end
125
125
126
- # get the action parameters for the given event
127
- def event_action_params ( event )
126
+ # get the action parameters for the given action and event
127
+ def event_action_params ( action , event )
128
128
type = get_event_type ( event )
129
129
130
130
params = {
@@ -135,7 +135,7 @@ def event_action_params(event)
135
135
}
136
136
137
137
params [ :parent ] = event . sprintf ( @parent ) if @parent
138
- if @ action == 'update'
138
+ if action == 'update'
139
139
params [ :_upsert ] = LogStash ::Json . load ( event . sprintf ( @upsert ) ) if @upsert != ""
140
140
params [ :_script ] = event . sprintf ( @script ) if @script != ""
141
141
end
Original file line number Diff line number Diff line change 157
157
describe "the action option" do
158
158
subject ( :eso ) { LogStash ::Outputs ::ElasticSearch . new ( options ) }
159
159
context "with a sprintf action" do
160
- let ( :options ) { { "action" => "%{myactionfield}" } }
160
+ let ( :options ) { { "action" => "%{myactionfield}" , "upsert" => '{"message": "some text"}' } }
161
161
162
162
let ( :event ) { LogStash ::Event . new ( "myactionfield" => "update" , "message" => "blah" ) }
163
163
164
- it "should interpolate the requested action value when creating an event_action_tuple" do
164
+ it "should interpolate the requested action value when creating an event_action_tuple and obtain associated action params " do
165
165
expect ( eso . event_action_tuple ( event ) . first ) . to eql ( "update" )
166
+ expect ( eso . event_action_tuple ( event ) [ 1 ] ) . to include ( :_upsert )
166
167
end
167
168
end
168
169
You can’t perform that action at this time.
0 commit comments