If your application errors are not showing up in Error Reporting, then use the following steps to troubleshoot.
Before you begin
-
Verify that Error Reporting can analyze your log entries.
Error Reporting is a global service built on Cloud Logging and can analyze log entries when all of the following are true:
- Assured workloads are disabled. For more information, see Overview of Assured Workloads.
- Customer-managed encryption keys (CMEK) is disabled on all log buckets that store the log entry. For information about how to determine the CMEK configuration for a log bucket, see Verify key enablement.
- The log bucket satisfies one of the following:
- The log bucket is stored in the same project where the log entries originated.
- The log entries were routed to a project, and then that project stored those log entries in a log bucket that it owns.
To see a list of sinks you have configured, run the following command:
gcloud logging sinks list
The command returns an output similar to the following:
NAME DESTINATION FILTER _Default logging.googleapis.com/projects/my-team-project/locations/global/buckets/_Default NOT LOG_ID("cloudaudit.googleapis.com/activity") AND NOT LOG_ID("externalaudit.googleapis.com/activity") AND NOT LOG_ID("cloudaudit.googleapis.com/system_event") AND NOT LOG_ID("externalaudit.googleapis.com/system_event") AND NOT LOG_ID("cloudaudit.googleapis.com/access_transparency") AND NOT LOG_ID("externalaudit.googleapis.com/access_transparency") _Required logging.googleapis.com/projects/my-team-project/locations/global/buckets/_Required LOG_ID("cloudaudit.googleapis.com/activity") OR LOG_ID("externalaudit.googleapis.com/activity") OR LOG_ID("cloudaudit.googleapis.com/system_event") OR LOG_ID("externalaudit.googleapis.com/system_event") OR LOG_ID("cloudaudit.googleapis.com/access_transparency") OR LOG_ID("externalaudit.googleapis.com/access_transparency") logs-from-samples logging.googleapis.com/projects/my-team-project/locations/global/buckets/sample-bucket (empty filter) regional_logs logging.googleapis.com/projects/my-team-project/locations/europe-west1/buckets/bucket_for_regional_logs (empty filter) test-logs logging.googleapis.com/projects/team-b-project/locations/global/buckets/test-bucket (empty filter)
In this example, the source Google Cloud project of the log entries is
my-team-project
. As a result:- Error Reporting can analyze the log entries routed by the
_Default
,_Required
, andlogs-from-samples
sinks because the log bucket is stored by the same project that routes the log entries. - Error Reporting can't analyze the log entries stored in the log
bucket named
test-logs
because the sink inmy-team-project
routes the log entries to a log bucket in a different project.
Ensure that you have the Google Cloud CLI installed.
Ensure that you have the
beta
component enabled for the gcloud CLI.
When using logs
This section provides troubleshooting support when your error data is written to Cloud Logging buckets, and you rely on Error Reporting to automatically analyze those log buckets.
Generate a sample log entry
To confirm your project settings, you can programmatically generate a log entry
that will be picked up by Error Reporting with the following gcloud
command:
gcloud logging write --payload-type=json test-errors-log \
'{"serviceContext":
{"service": "manual-testing"},
"message": "Test Error\n at /test.js:42:42",
"context": {"httpRequest":
{"url": "/test","method": "GET","responseStatusCode": 500}}}'
Then open Error Reporting and confirm that you see the newly created error.
Confirm the log entry format
Navigate to the Cloud Logging page and locate a log entry that contains exception data sent from your application.
Confirm that the log entry uses the expected format.
When using the Error Reporting API
-
Enable the required API.
Send a test error
Try sending an error to the service manually.
You can report a test error to Error Reporting using the following
gcloud
command:gcloud beta error-reporting events report --service Manual --service-version test1 \ --message "java.lang.TestError: msg at com.example.TestClass.test(TestClass.java:51) at com.example.AnotherClass(AnotherClass.java:25)"
You can use a cURL command to test your REST API calls. Replace
PROJECT_ID
andAPI_KEY
with your valid values before sending the following command:curl -X POST -H "Content-Type: application/json" \ -d '{"message":"java.lang.TestError: msg\n\tat com.example.TestClass.test(TestClass.java:51)\n\tat com.example.AnotherClass(AnotherClass.java:25)","serviceContext":{"service":"manual-testing"}}' \ https://clouderrorreporting.googleapis.com/v1beta1/projects/PROJECT_ID/events:report?key=API_KEY
Confirm the sent payload
Ensure that your application is sending exception data to the API in the correct format and that it contains the required attributes.
A stack trace is logged but not recognized by Error Reporting
You log an error by using the message
field of a jsonPayload
, and you expect
Error Reporting to capture the error. However, the error data
isn't captured.
To resolve this failure, try the following:
Ensure that the
jsonPayload
doesn't include astack_trace
orexception
field. When those fields are present, themessage
field isn't evaluated.Ensure that the structure of the stack trace is in one of the supported programming language formats. The stack trace isn't captured by Error Reporting when an unsupported format is used.
For more information, see Format errors in logs.