Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dokumen ini menjelaskan cara menggunakan konsol Google Cloud untuk membuat kebijakan pemberitahuan yang memantau jumlah proses yang berjalan di virtual machine (VM) Anda yang memenuhi kondisi yang Anda tentukan. Jenis kebijakan pemberitahuan ini terkadang disebut kebijakan pemberitahuan kesehatan proses.
Misalnya, Anda dapat menghitung jumlah proses yang dimulai oleh pengguna root.
Anda juga dapat menghitung jumlah proses yang perintah pemanggilannya berisi string tertentu. Kebijakan pemberitahuan dapat memberi tahu Anda saat
jumlah proses lebih dari, atau kurang dari, batas.
Untuk mengetahui informasi tentang proses yang dapat dipantau,
lihat Proses yang dipantau.
Konten ini tidak berlaku untuk kebijakan pemberitahuan berbasis log.
Untuk mengetahui informasi tentang kebijakan pemberitahuan berbasis log, yang memberi tahu Anda saat pesan tertentu muncul di log Anda, lihat Memantau log Anda.
Sebelum memulai
Untuk mendapatkan izin yang diperlukan guna membuat dan mengubah kebijakan pemberitahuan menggunakan konsol Google Cloud , minta administrator untuk memberi Anda peran IAM Monitoring Editor (roles/monitoring.editor) di project Anda.
Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.
Pastikan Anda sudah memahami konsep umum kebijakan pemberitahuan.
Untuk mengetahui informasi tentang topik ini, lihat
Ringkasan pemberitahuan.
Konfigurasi saluran notifikasi yang ingin Anda gunakan untuk menerima
pemberitahuan. Untuk tujuan redundansi, sebaiknya Anda juga membuat beberapa jenis saluran notifikasi. Untuk mengetahui informasi tentang langkah-langkah ini, lihat Membuat dan mengelola saluran notifikasi.
Pastikan Anda telah menginstal Agen Operasional di VM yang ingin dipantau. Untuk mengetahui informasi selengkapnya, lihat
Agen Google Cloud Observability.
Membuat kebijakan pemberitahuan
Untuk membuat kebijakan pemberitahuan yang memantau jumlah proses yang berjalan di VM menggunakan Cloud Monitoring API, ekspresi filter harus menentukan pemilih deret waktu. Untuk contoh file JSON yang menentukan pemilih ini, lihat Kebijakan kesehatan proses.
Untuk membuat kebijakan pemberitahuan yang memantau jumlah proses yang berjalan di VM, lakukan langkah berikut:
Di konsol Google Cloud , buka halaman
notificationsAlerting:
Tidak semua proses yang berjalan di sistem Anda dapat dipantau oleh kondisi
kesehatan proses. Kondisi ini memilih proses yang akan dipantau dengan menggunakan ekspresi reguler yang diterapkan ke command line yang memanggil proses. Jika
kolom command line tidak tersedia, proses tidak dapat dipantau.
Salah satu cara untuk menentukan apakah suatu proses dapat dipantau oleh kondisi kesehatan proses
adalah dengan melihat proses aktif. Misalnya, di sistem Linux, Anda
dapat menggunakan perintah ps:
ps aux | grep nfs
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1598 0.0 0.0 0 0 ? S< Oct25 0:00 [nfsd4]
root 1639 0.0 0.0 0 0 ? S Oct25 2:33 [nfsd]
root 1640 0.0 0.0 0 0 ? S Oct25 2:36 [nfsd]
Jika entri COMMAND diapit dengan tanda kurung siku, misalnya [nfsd],
informasi command line untuk proses tidak tersedia. Dalam situasi ini,
Anda tidak dapat menggunakan Cloud Monitoring untuk memantau proses.
[[["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-09-02 UTC."],[],[],null,["# Monitor count of processess on a VM\n\nThis document describes how to use the Google Cloud console to create an alerting\npolicy that monitors the number of processes running on your\nvirtual machines (VMs) that meet conditions you specify. This type of\nalerting policy is sometimes called a *process-health* alerting policy.\nFor example, you can count the number of processes started by the root user.\nYou can also count the number of processes whose invocation command contained\na specific string. An alerting policy can notify you when\nthe number of processes is more than, or less than, a threshold.\nFor information about which processes can be monitored,\nsee [Processes that are monitored](#process-health-processes).\n\n\nThis content does not apply to log-based alerting policies.\nFor information about log-based alerting policies, which notify you when a\nparticular message appears in your logs, see\n[Monitoring your logs](/logging/docs/alerting/monitoring-logs).\n\nBefore you begin\n----------------\n\n1.\n\n To get the permissions that\n you need to create and modify alerting policies by using the Google Cloud console,\n\n ask your administrator to grant you the\n\n\n [Monitoring Editor](/iam/docs/roles-permissions/monitoring#monitoring.editor) (`roles/monitoring.editor`)\n IAM role on your project.\n\n\n For more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\n You might also be able to get\n the required permissions through [custom\n roles](/iam/docs/creating-custom-roles) or other [predefined\n roles](/iam/docs/roles-overview#predefined).\n\n For more information about Cloud Monitoring roles,\n see [Control access with Identity and Access Management](/monitoring/access-control).\n2. Ensure that you're familiar with the general concepts of alerting policies.\n For information about these topics, see\n [Alerting overview](/monitoring/alerts).\n\n3. Configure the notification channels that you want to use to receive any\n alerts. For redundancy purposes, we also recommend that you create\n multiple types of notification channels. For information about these steps,\n see [Create and manage notification channels](/monitoring/support/notification-options).\n\n4. Ensure that you've installed the Ops Agent on the VMs that you want\n to monitor. For more information, see\n [Google Cloud Observability agents](/monitoring/agent).\n\nCreate alerting policy\n----------------------\n\nTo create an alerting policy that monitors the count of processes running on\na VM by using the Cloud Monitoring API, the filter expression must specify\na time series selector. For an example of a JSON file that specifies this\nselector, see [Process-health policy](/monitoring/alerts/policies-in-json#json-process-health).\n\nTo create an alerting policy that monitors the count of processes running on\na VM, do the following:\n\n1. In the Google Cloud console, go to the\n *notifications* **Alerting** page:\n\n [Go to **Alerting**](https://console.cloud.google.com/monitoring/alerting)\n\n \u003cbr /\u003e\n\n If you use the search bar to find this page, then select the result whose subheading is\n **Monitoring**.\n2. Select **Create policy**.\n3. Select **?** on the **Select metric** section header and then select\n **Direct filter mode** in the tooltip.\n\n4. Enter a Monitoring filter.\n\n For example, to count the number of processes that are running on\n Compute Engine VM instances whose name includes `nginx`, enter the\n following: \n\n select_process_count(\"monitoring.regex.full_match(\\\".*nginx.*\\\")\")\n resource.type=\"gce_instance\"\n\n For syntax information see the following resources:\n - For filters used to count processes running on virtual machines, see [Process-health filters](/monitoring/api/v3/process-health-filters).\n - For general syntax, see [Monitoring filters](/monitoring/api/v3/filters).\n5. Complete the alerting policy. You must configure the condition trigger,\n notifications, documentation, and policy name,\n and then click **Create policy**.\n\n For more information, see\n [Create metric-threshold alerting policies](/monitoring/alerts/using-alerting-ui).\n\nProcesses that are monitored\n----------------------------\n\nNot all processes running in your system can be monitored by a process-health\ncondition. This condition selects processes to be monitored by using a regular\nexpression that is applied to the command line that invoked the process. When\nthe command line field isn't available, the process can't be monitored.\n\nOne way to determine if a process can be monitored by a process-health condition\nis to look at the active processes. For example, on a Linux system, you\ncan use the `ps` command: \n\n ps aux | grep nfs\n USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND\n root 1598 0.0 0.0 0 0 ? S\u003c Oct25 0:00 [nfsd4]\n root 1639 0.0 0.0 0 0 ? S Oct25 2:33 [nfsd]\n root 1640 0.0 0.0 0 0 ? S Oct25 2:36 [nfsd]\n\nWhen a `COMMAND` entry is wrapped with square brackets, for example `[nfsd]`,\nthe command-line information for the process isn't available. In this situation,\nyou can't use Cloud Monitoring to monitor the process."]]