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

Disable sourcemap upload endpoint when data streams enabled #4735

Merged
merged 2 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"error": "forbidden request: Sourcemap upload endpoint is disabled. Configure the `apm-server.rum` section in apm-server.yml to enable sourcemap uploads. If you are not using the RUM agent, you can safely ignore this error. If you are running APM Server managed by Fleet, you need to upload Sourcemaps directly to Elasticsearch."
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"error": "forbidden request: Sourcemap upload endpoint is disabled. Configure the `apm-server.rum` section in apm-server.yml to enable sourcemap uploads. If you are not using the RUM agent, you can safely ignore this error."
"error": "forbidden request: Sourcemap upload endpoint is disabled. Configure the `apm-server.rum` section in apm-server.yml to enable sourcemap uploads. If you are not using the RUM agent, you can safely ignore this error. If you are running APM Server managed by Fleet, you need to upload Sourcemaps directly to Elasticsearch."
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"error": "forbidden request: Sourcemap upload endpoint is disabled. Configure the `apm-server.rum` section in apm-server.yml to enable sourcemap uploads. If you are not using the RUM agent, you can safely ignore this error."
"error": "forbidden request: Sourcemap upload endpoint is disabled. Configure the `apm-server.rum` section in apm-server.yml to enable sourcemap uploads. If you are not using the RUM agent, you can safely ignore this error. If you are running APM Server managed by Fleet, you need to upload Sourcemaps directly to Elasticsearch."
}
5 changes: 3 additions & 2 deletions beater/api/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ func rumMiddleware(cfg *config.Config, _ *authorization.Handler, m map[request.R
func sourcemapMiddleware(cfg *config.Config, auth *authorization.Handler) []middleware.Middleware {
msg := "Sourcemap upload endpoint is disabled. " +
"Configure the `apm-server.rum` section in apm-server.yml to enable sourcemap uploads. " +
"If you are not using the RUM agent, you can safely ignore this error."
enabled := cfg.RumConfig.IsEnabled() && cfg.RumConfig.SourceMapping.IsEnabled()
"If you are not using the RUM agent, you can safely ignore this error. " +
"If you are running APM Server managed by Fleet, you need to upload Sourcemaps directly to Elasticsearch."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know whether or not APM Server is managed by Fleet - can we change the error message based on that knowledge? Saves the user trying to figure out whether source maps are explicitly disabled, or implicitly because data streams are enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just being lazy... you got me

enabled := cfg.RumConfig.IsEnabled() && cfg.RumConfig.SourceMapping.IsEnabled() && !cfg.DataStreams.Enabled
return append(backendMiddleware(cfg, auth, sourcemap.MonitoringMap),
middleware.KillSwitchMiddleware(enabled, msg))
}
Expand Down
9 changes: 9 additions & 0 deletions beater/api/mux_sourcemap_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ func TestSourcemapHandler_KillSwitchMiddleware(t *testing.T) {
approvaltest.ApproveJSON(t, approvalPathAsset(t.Name()), rec.Body.Bytes())
})

t.Run("DataStreams", func(t *testing.T) {
cfg := cfgEnabledRUM()
cfg.DataStreams.Enabled = true
rec, err := requestToMuxerWithPattern(cfg, AssetSourcemapPath)
require.NoError(t, err)
require.Equal(t, http.StatusForbidden, rec.Code)
approvaltest.ApproveJSON(t, approvalPathAsset(t.Name()), rec.Body.Bytes())
})

t.Run("On", func(t *testing.T) {
rec, err := requestToMuxerWithPattern(cfgEnabledRUM(), AssetSourcemapPath)
require.NoError(t, err)
Expand Down