Mengumpulkan data error menggunakan Error Reporting
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dokumen ini mencantumkan lingkungan yang didukung oleh Error Reporting dan
menautkan ke panduan khusus bahasa untuk developer aplikasi.
Sebaiknya gunakan library klien khusus bahasa atau andalkan entri log yang dikumpulkan secara otomatis; namun, Anda dapat menulis data error dengan Cloud Logging API atau Error Reporting API.
Misalnya, jika Anda menggunakan
Cloud Run,
maka pengecualian yang ditulis ke stderr akan otomatis dikirim ke Cloud Logging.
Error Reporting adalah layanan global yang dibangun di atas
Cloud Logging dan dapat menganalisis entri log jika semua hal berikut terpenuhi:
Assured Workloads dinonaktifkan. Untuk mengetahui informasi selengkapnya, lihat Ringkasan Assured Workloads.
Kunci enkripsi yang dikelola pelanggan (CMEK)
dinonaktifkan di semua bucket log yang menyimpan entri log. Error Reporting tidak dapat menyimpan entri log di bucket log yang mengaktifkan CMEK. Untuk mengetahui informasi tentang cara
menentukan konfigurasi CMEK untuk bucket log, lihat
Memverifikasi pengaktifan kunci.
Bucket log memenuhi salah satu hal berikut:
Bucket log disimpan dalam project yang sama dengan tempat asal entri log.
Entri log diarahkan ke project, lalu project tersebut menyimpan entri log tersebut
dalam bucket log yang dimilikinya.
Dukungan Virtual Private Cloud
Pelaporan Error adalah layanan yang didukung Virtual Private Cloud (VPC).
Untuk mengurangi risiko pemindahan data yang tidak sah, gunakan Kontrol Layanan VPC untuk membuat perimeter layanan di sekitar layanan yang dikelola Google.
Untuk mengetahui informasi tentang Kontrol Layanan VPC dan cara membuat parameter layanan, lihat dokumentasi Kontrol Layanan VPC.
Mengonfigurasi lingkungan untuk melaporkan data error secara otomatis
Untuk mengetahui informasi tentang persyaratan konfigurasi khusus lingkungan, lihat panduan berikut:
Anda dapat melaporkan peristiwa error ke project Google Cloud dengan
mengeksekusi metode Error Reporting API
report
atau metode Cloud Logging API
write.
Jika memerlukan autentikasi berbasis kunci API, Anda harus menggunakan Error Reporting API. Untuk melaporkan peristiwa error menggunakan
Error Reporting API, jalankan metode
report
dan format isi permintaan metode sebagai objek
ReportedErrorEvent.
Saat Anda menggunakan Error Reporting API, entri log dengan pesan error yang diformat dengan benar akan otomatis dibuat dan ditulis ke Cloud Logging. Entri log ini ditulis ke log
yang logName-nya diformat sebagai berikut:
Karena entri log dibuat oleh panggilan ke report, Anda mungkin dikenai biaya penyerapan Cloud Logging. Untuk mengontrol entri log yang diserap, lihat Filter pengecualian.
Jika Anda melaporkan peristiwa error menggunakan Error Reporting API, bagian lain dari dokumen ini tidak berlaku.
Jika ingin menggunakan Cloud Logging API, Anda harus memformat objek
LogEntry agar menyertakan stack trace,
atau objek ReportedErrorEvent. Untuk mengetahui informasi selengkapnya
tentang persyaratan pemformatan, lihat
Error format dalam log.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-11 UTC."],[[["\u003cp\u003eError Reporting supports various environments and offers language-specific client libraries for application developers to send error reports.\u003c/p\u003e\n"],["\u003cp\u003eError data can be sent through language-specific client libraries, automatically-collected log entries, or by directly using the Cloud Logging API or the Error Reporting API.\u003c/p\u003e\n"],["\u003cp\u003eError Reporting is a global service built on Cloud Logging that analyzes log entries under specific conditions, like assured workloads and CMEK being disabled or in a properly configured bucket.\u003c/p\u003e\n"],["\u003cp\u003eError Reporting supports Virtual Private Cloud (VPC), and VPC Service Controls can be used to enhance security.\u003c/p\u003e\n"],["\u003cp\u003eThere are dedicated guides for configuring environments and instrumenting apps, as well as for using the Error Reporting API and Cloud Logging API to write error data, each with their own set of requirements.\u003c/p\u003e\n"]]],[],null,["This document lists the environments supported by Error Reporting and\nit links to language-specific guides for application developers.\nWe recommend that you use the [language-specific client libraries](#libraries)\nor rely on automatically-collected log entries; however, you can\n[write error data with the Cloud Logging API or the Error Reporting API](#apis).\nFor example, if you use\n[Cloud Run](/error-reporting/docs/setup/cloud-run),\nthen exceptions written to `stderr` are automatically sent to Cloud Logging.\n\nError Reporting is a global service built on\nCloud Logging and can analyze log entries when all of the following are true:\n\n- Assured workloads are disabled. For more information, see [Overview of Assured Workloads](/assured-workloads/docs/overview).\n- [Customer-managed encryption keys (CMEK)](/logging/docs/routing/managed-encryption-storage) are disabled on all log buckets that store the log entry. Error Reporting can't store log entries in log buckets that have CMEK enabled. For information about how to determine the CMEK configuration for a log bucket, see [Verify key enablement](/logging/docs/routing/managed-encryption-storage#verify-key).\n- The log bucket satisfies one of the following:\n - The log bucket is stored in the same project where the log entries originated.\n - The log entries were routed to a project, and then that project stored those log entries in a log bucket that it owns.\n\n\u003cbr /\u003e\n\nVirtual Private Cloud support\n\nError Reporting is a Virtual Private Cloud (VPC) supported\nservice.\n\nTo reduce the risk of data exfiltration, use VPC Service Controls to create a\nservice perimeter around your Google-managed services.\nFor information about VPC Service Controls and how to create a service\nparameter, see the\n[VPC Service Controls documentation](/vpc-service-controls/docs).\n\nConfigure environments to automatically report error data\n\nFor information about environment-specific configuration requirements, see\nthe following guides:\n\n- [App Engine flexible environment](/error-reporting/docs/setup/app-engine-flexible-environment)\n- [App Engine standard environment](/error-reporting/docs/setup/app-engine-standard-environment)\n- [Apps Script](/error-reporting/docs/setup/apps-script)\n- [Cloud Run functions](/error-reporting/docs/setup/cloud-functions)\n- [Cloud Run](/error-reporting/docs/setup/cloud-run)\n- [Compute Engine](/error-reporting/docs/setup/compute-engine)\n- [Google Kubernetes Engine](/error-reporting/docs/setup/kubernetes-engine)\n- [Amazon EC2](/error-reporting/docs/setup/ec2)\n\nInstrument apps by using client libraries\n\nFor information about how to configure your application to send error reports,\nsee the language-specific configuration guides:\n\n- [Go apps](/error-reporting/docs/setup/go)\n- [Java apps](/error-reporting/docs/setup/java)\n- [.NET apps](/error-reporting/docs/setup/dotnet)\n- [Node.js apps](/error-reporting/docs/setup/nodejs)\n- [Python apps](/error-reporting/docs/setup/python)\n- [PHP apps](/error-reporting/docs/setup/php)\n- [Ruby apps](/error-reporting/docs/setup/ruby)\n\nWrite error data by using an API\n\nYou can report error events to your Google Cloud project by\nexecuting the Error Reporting API method\n[`report`](/error-reporting/reference/rest/v1beta1/projects.events/report)\nor the Cloud Logging API method\n[`write`](/logging/docs/reference/v2/rest/v2/entries/write).\n\n- If you require API key-based authentication, then you must use the\n Error Reporting API. To report an error event by using the\n Error Reporting API, execute the method\n [`report`](/error-reporting/reference/rest/v1beta1/projects.events/report)\n and format the request body of the method as a\n [`ReportedErrorEvent`](/error-reporting/reference/rest/v1beta1/projects.events/report#ReportedErrorEvent) object.\n\n When you use the Error Reporting API, log entries with properly\n formatted error messages are automatically generated and written to\n [Cloud Logging](/logging/docs). These log entries are written to a log\n whose `logName` is formatted as follows: \n\n ```\n projects/PROJECT_ID/clouderrorreporting.googleapis.com%2Freported_errors\n ```\n\n Because log entries are generated by calls to `report`, you might incur\n Cloud Logging ingestion costs. To control which log entries are ingested,\n see [Exclusion filters](/logging/docs/routing/overview#exclusions).\n\n If you report error events by using the Error Reporting API,\n the remainder of this document doesn't apply.\n- If you want to use the Cloud Logging API, then you must format the\n [`LogEntry`](/logging/docs/api/reference/rest/v2/LogEntry) object so that includes a stack trace,\n or a [`ReportedErrorEvent`](/error-reporting/reference/rest/v1beta1/projects.events/report#ReportedErrorEvent) object. For more information\n about the formatting requirements, see\n [Format errors in logs](/error-reporting/docs/formatting-error-messages)."]]