-
Notifications
You must be signed in to change notification settings - Fork 212
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
HTTP 400: data validation error: Problem validating JSON document against schema #295
Comments
Hi @jaap3, thanks for opening the issue! Do you use |
Good question, I might have omitted some relevant information. I've configured the client in a Django project (version 2.1.2) and pretty much use "all the things" (no manual calls to the client however), in short I've:
Note that the error happens rarely (in 2 days ~10 times). If I look at the APM data it all looks normal (as far as I can tell, this is my first time trying APM). The reason I know this error is happening is because I'm also using Sentry to monitor this project (using the Raven client version 6.9.0). For Sentry I got basically the same setup as APM, meaning |
Any update on this? I've now seen this error ~130 times and it's a reason for me to hold back a rollout of APM on other projects. It's unclear to me if this error is fatal, caused by a misconfiguration etc. I would really appreciate some insight. |
I think there may be a bug in In the Message.capture, we set the message field like: message = param_message["message"] % params if params else param_message["message"] So if you logged a message with no parameters, then it would take the message as it is, without any interpolation. This code assumes that I'm not sure what the best fix is, but I think it might just a matter of changing LoggingHandler's call to client_capture like this: diff --git a/elasticapm/handlers/logging.py b/elasticapm/handlers/logging.py
index b2dbd4d6..15b04436 100644
--- a/elasticapm/handlers/logging.py
+++ b/elasticapm/handlers/logging.py
@@ -130,7 +130,7 @@ class LoggingHandler(logging.Handler):
return self.client.capture(
"Message",
- param_message={"message": record.msg, "params": record.args},
+ param_message={"message": str(record.msg), "params": record.args},
stack=stack,
custom=custom,
exception=exception, |
A quick grep through the project didn't find any logging calls where the message param isn't a string. But who knows, maybe a library we're using is doing this. The proposed fix looks fairly harmless ( |
@jaap3 I've just pushed a branch and proposed it as a PR. Branch: https://github.com/axw/apm-agent-python/tree/logging-msg-arbitrary-object. If you could test it out, that would be great. |
@axw After updating to your branch I haven't seen the error again. However, a new, never before seen error appeared (only once for now):
This is obviously related to me having both Sentry and APM clients enabled and Sentry's client (raven) maybe doing something funky? |
Great!
The error is due to how additional fields of log records are being recorded as "custom" context, and probably is caused by having both Sentry and APM as you suggest. The error arises because a log record contains a key ("sentry.interfaces.Message") with dots, which the schema disallows. So we'll need another fix for that. |
OK, should I open a new ticket for that? And should this be fixed on the client or server side? |
@jaap3 it's an agent issue. We probably need to apply some kind of "de-dotting" (aka replace the dots with something that doesn't have semantic meaning for Elasticsearch field names, e.g. a dash) for keys in the context dictionary. I will merge @axw's branch with the fix for this issue (#295) some time today and release it to PyPI soon thereafter |
@jaap3 version 3.0.3 of the agent is out with a fix for the logging issue. I opened #317 to track the issue you reported in #295 (comment). |
Sometimes when sending an event to the APM instance a HTTP 400 response is returned:
I've also seen a similar, but subtly different message:
This is then followed by a log message:
I'm using the latest elastic-apm client available from PyPI (3.0.1) with Python 3.6.5 and the APM server is using version 6.4.1.
(This seems similar to #135, but not quite the same).
The text was updated successfully, but these errors were encountered: