Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[splunkhecreceiver] aligns success response body w/ splunk enterprise #24604

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .chloggen/splunkhecreceiver-align-success-response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# use this changelog template to create an entry for the release notes. if
# your changes don't affect end-users (e.g. test fixes or tooling updates),
# title your pull request with "[chore]" or use the "skip changelog" label

# choose one: breaking, deprecation, new_component, enhancement, or bug_fix
change_type: bug_fix

# name of the component or a single word describing the area of concern
component: splunkhecreceiver

# brief description of the proposed changes
note: aligns success resp body w/ splunk enterprise

# tracking issues related to the changes (or a pr number if none exist)
issues: [19219]

# (optional) additional information to render under the primary note provided above;
# these lines will be padded with two spaces and inserted directly into the document
subtext: changes resp from plaintext "ok" to json {"text":"success", "code":0}
5 changes: 2 additions & 3 deletions receiver/splunkhecreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
const (
defaultServerTimeout = 20 * time.Second

responseOK = "OK"
responseOK = `{"text": "Success", "code": 0}`
responseHecHealthy = `{"text": "HEC is healthy", "code": 17}`
responseInvalidMethod = `Only "POST" method is supported`
responseInvalidEncoding = `"Content-Encoding" must be "gzip" or empty`
Expand Down Expand Up @@ -376,8 +376,7 @@ func (r *splunkReceiver) consumeMetrics(ctx context.Context, events []*splunk.Ev
r.failRequest(ctx, resp, http.StatusInternalServerError, errInternalServerError, len(events), decodeErr)
} else {
resp.WriteHeader(http.StatusOK)
_, err := resp.Write(okRespBody)
if err != nil {
if _, err := resp.Write(okRespBody); err != nil {
r.failRequest(ctx, resp, http.StatusInternalServerError, errInternalServerError, len(events), err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion receiver/splunkhecreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ func Test_splunkhecReceiver_rawReqHasmetadataInResource(t *testing.T) {
resp := w.Result()
assert.NoError(t, err)

assertResponse(t, resp.StatusCode, "OK")
assertResponse(t, resp.StatusCode, responseOK)
tt.assertResource(t, sink.AllLogs())
})
}
Expand Down