Skip to content

Commit a372f19

Browse files
authored
Add process_response flag in es output (#945)
1 parent 3b9cfce commit a372f19

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

plugin/output/elasticsearch/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,11 @@ The name of the ingest pipeline to write events to.
164164

165165
<br>
166166

167+
**`process_response`** *`bool`* *`default=true`*
168+
169+
Process ES response and report errors, if any.
170+
171+
<br>
172+
167173

168174
<br>*Generated using [__insane-doc__](https://github.com/vitkovskii/insane-doc)*

plugin/output/elasticsearch/elasticsearch.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ type Config struct {
198198
// >
199199
// > The name of the ingest pipeline to write events to.
200200
IngestPipeline string `json:"ingest_pipeline"` // *
201+
202+
// > @3@4@5@6
203+
// >
204+
// > Process ES response and report errors, if any.
205+
ProcessResponse bool `json:"process_response" default:"true"` // *
201206
}
202207

203208
type KeepAliveConfig struct {
@@ -411,12 +416,17 @@ func (p *Plugin) out(workerData *pipeline.WorkerData, batch *pipeline.Batch) err
411416
}
412417

413418
func (p *Plugin) send(data []byte) (int, error) {
419+
processFn := p.reportESErrors
420+
if !p.config.ProcessResponse {
421+
processFn = nil
422+
}
423+
414424
return p.client.DoTimeout(
415425
http.MethodPost,
416426
NDJSONContentType,
417427
data,
418428
p.config.ConnectionTimeout_,
419-
p.reportESErrors,
429+
processFn,
420430
)
421431
}
422432

@@ -425,11 +435,18 @@ func (p *Plugin) sendSplit(left int, right int, begin []int, data []byte) (int,
425435
return http.StatusOK, nil
426436
}
427437

438+
processFn := p.reportESErrors
439+
if !p.config.ProcessResponse {
440+
processFn = nil
441+
}
442+
428443
statusCode, err := p.client.DoTimeout(
429444
http.MethodPost,
430445
NDJSONContentType,
431446
data[begin[left]:begin[right]],
432-
p.config.ConnectionTimeout_, p.reportESErrors)
447+
p.config.ConnectionTimeout_,
448+
processFn,
449+
)
433450

434451
if err != nil {
435452
p.sendErrorMetric.WithLabelValues(strconv.Itoa(statusCode)).Inc()

0 commit comments

Comments
 (0)