Troubleshoot

If your application errors are not showing up in Error Reporting, follow the steps below to troubleshoot.

Before you begin

  1. Verify that Error Reporting can analyze your logs.

    Error Reporting is a global service built on Cloud Logging and can analyze log entries when all of the following are true:

    • The log entries are stored in a log bucket in the global location.
    • Customer-managed encryption keys (CMEK) are disabled on the log bucket. 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 logs originated.
      • The logs were routed to a project, and then that project stored those logs in a log bucket that it owns.

    To see if Error Reporting can analyze your logs, verify that you are storing your logs in buckets in the global region where the source and destination Google Cloud projects are the same.

    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 logs is my-team-project. As a result:

    • Error Reporting can analyze the logs routed by the _Default, _Required, and logs-from-samples sinks because they are routing logs to buckets that are in the global region within the same project.
    • Error Reporting can't analyze the logs stored in the log bucket named test-logs because the sink in my-team-project routes the logs to a log bucket in a different project.
    • Error Reporting can't analyze logs routed by the regional_logs sink because it routes logs to a regional bucket in the europe-west1 region.
  2. Ensure that you have the Google Cloud CLI installed.

  3. 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 API

In the navigation panel of the Google Cloud console, select APIs & Services, click Enable APIs and Services, and then enable the Error Reporting API:

Go to Error Reporting API settings

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 and API_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

Make sure that your application is sending exception data to the API in the correct format and that it contains the required attributes.