Troubleshoot

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

Before you begin

  1. Verify that customer-managed encryption keys (CMEK) are disabled on your log bucket.

    When logs are protected with CMEK, they aren't made available to Error Reporting and therefore error groups can't be identified. Error Reporting isn't available for any of the following logs:

    • Logs stored in a CMEK-enabled log bucket.
    • Logs stored in multiple log buckets where at least one log bucket is CMEK-enabled.
    • Logs stored in any log bucket in an organization, when an organizational-level policy requires CMEK to be enabled.

    For information about how to determine the CMEK configuration for a log bucket, see Verify key enablement.

  2. Verify that Error Reporting can analyze your logs.

    Error Reporting can only analyze log entries that are stored in Cloud Logging buckets that are in the global region where the source and destination Google Cloud projects are the same.

    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 since they are routing logs to buckets that are in the global region within the same project.
    • Error Reporting can't analyze logs routed by the regional_logs sink since it routes logs to a regional bucket in the europe-west1 region.
    • Error Reporting can't analyze logs routed by the test-logs sink since it routes logs to a different project (team-b-project) than the source project.
  3. Ensure that you have the Google Cloud CLI installed.

  4. 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.