Configurer des alertes pour les programmations d'instantanés
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Linux
Windows
Vous pouvez créer des métriques personnalisées pour déclencher des alertes ou fournir des informations permettant de résoudre des problèmes liés à une programmation d'instantanés.
Par exemple, pour configurer une alerte en cas d'échec d'une programmation d'instantanés, procédez comme suit :
Créez une métrique basée sur le filtre de journal, qui compte les échecs de programmations d'instantanés.
Créez une règle d'alerte pour envoyer une alerte en cas d'échec d'une programmation d'instantanés.
Avant de commencer
Si ce n'est pas déjà fait, configurez l'authentification.
L'authentification est le processus permettant de valider votre identité pour accéder aux services et aux API Google Cloud .
Pour exécuter du code ou des exemples depuis un environnement de développement local, vous pouvez vous authentifier auprès de Compute Engine en sélectionnant l'une des options suivantes :
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and
APIs, you don't need to set up authentication.
gcloud
Installez Google Cloud CLI.
Après l'installation,
initialisez Google Cloud CLI en exécutant la commande suivante :
Pour utiliser les exemples d'API REST de cette page dans un environnement de développement local, vous devez utiliser les identifiants que vous fournissez à gcloud CLI.
Installez Google Cloud CLI.
Après l'installation,
initialisez Google Cloud CLI en exécutant la commande suivante :
Pour en savoir plus, consultez la section S'authentifier pour utiliser REST dans la documentation sur l'authentification Google Cloud .
Rôles et autorisations requis
Pour obtenir les autorisations nécessaires pour créer une programmation d'instantanés, demandez à votre administrateur de vous accorder les rôles IAM suivants sur le projet :
Sous Métriques définies par l'utilisateur, localisez votre nouvelle métrique nommée user/scheduled_snapshot_failure_count.
Cliquez sur le bouton de menu more_vertPlus figurant sur cette ligne, puis sélectionnez Créer une alerte à partir de la métrique. La page de création d'une condition applicable à une règle d'alerte s'affiche.
Dans le panneau Cible, sous Agrégateur, sélectionnez aucun.
Sous Filtre :
Cliquez sur Ajouter un filtre.
Dans la liste, sélectionnez état.
Dans le champ Valeur, saisissez DONE.
Cliquez sur Appliquer.
Cliquez sur Afficher les options avancées.
Dans le volet Agrégation avancée, cliquez sur la liste Aligneur et sélectionnez somme.
Dans le panneau Configuration, sélectionnez les valeurs suivantes :
Déclenchement de la condition : Any time series violates
Condition : is above
Seuil : 1
Pour : most recent value
Cliquez sur Enregistrer.
Sur la page Créer une règle d'alerte, saisissez un nom de règle.
Vous pouvez au besoin ajouter des canaux de notification et de la documentation concernant cette règle.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/19 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/08/19 (UTC)."],[[["\u003cp\u003eYou can create custom metrics to monitor and troubleshoot scheduled snapshot issues, such as failures.\u003c/p\u003e\n"],["\u003cp\u003eTo set up alerts for scheduled snapshot failures, you must create a log filter, a metric based on the log filter, and finally an alert policy.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication is required to access Google Cloud services and APIs, which can be set up through the gcloud CLI or the console.\u003c/p\u003e\n"],["\u003cp\u003eTo create a snapshot schedule, you need specific IAM roles, including Compute Instance Admin (v1) and Service Account User (v1).\u003c/p\u003e\n"],["\u003cp\u003eAfter creating the user metric you can set an alert policy to trigger any time the metric exceeds the threshold, which in this case is one failure.\u003c/p\u003e\n"]]],[],null,["Linux Windows\n\n*** ** * ** ***\n\nYou can [create a custom metric](/monitoring/custom-metrics)\nto raise alerts or provide information to troubleshoot problems with scheduled\nsnapshots.\n\nFor example, to set up an alert for scheduled snapshot failures, use the\nfollowing procedure:\n\n1. [Create a log filter](#ss_alert_filter) to capture scheduled snapshot events.\n2. [Create a metric](#ss_alert_metric) based off of the log filter that counts scheduled snapshot failures.\n3. [Create an alert policy](#ss_alert_policy) to send an alert when there is a scheduled snapshot failure.\n\nBefore you begin\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n gcloud\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nRequired roles and permissions\n\n\nTo get the permissions that\nyou need to create a snapshot schedule,\n\nask your administrator to grant you the\nfollowing IAM roles on the project:\n\n- [Compute Instance Admin (v1)](/iam/docs/roles-permissions/compute#compute.instanceAdmin.v1) (`roles/compute.instanceAdmin.v1`)\n- To connect to a VM that can run as a service account: [Service Account User (v1)](/iam/docs/roles-permissions/iam#iam.serviceAccountUser) (`roles/iam.serviceAccountUser`)\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nCreate a log filter\n\nCreate a log filter to capture scheduled snapshot events. \n\nConsole\n\n1. In the Google Cloud console, go to the\n **Logging \\\u003e Logs Explorer** page.\n\n [Go to the Logs Explorer page](https://console.cloud.google.com/logs/query)\n2. In the **Filter by label or text search** list, select **Convert to advanced filter**.\n\n1. Replace the filter field by entering the following text, replacing\n \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your project ID:\n\n resource.type=\"gce_disk\"\n logName=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/cloudaudit.googleapis.com%2Fsystem_event\"\n protoPayload.methodName=\"ScheduledSnapshots\"\n severity\u003e\"INFO\"\n\n2. Click **Submit Filter**.\n\nCreate a metric\n\nAfter you create the log filter, create a metric that\ncounts scheduled snapshot failures. \n\nConsole\n\n1. On the **Logs Explorer** page, click **Create metric**.\n\n2. In the **Metric Editor**, enter the following:\n\n - **Name** : `scheduled_snapshot_failure_count`.\n - **Description** : `count of scheduled snapshot failures`.\n - **Type** : `Counter`\n3. Under **Labels** , click **Add item** and enter the following:\n\n - **Name** : `status`\n - **Description** : `status of scheduled snapshot request`\n - **Label type** : `String`\n - **Field name** : `protoPayload.response.status`\n4. Click **Done**.\n\n5. Click **Create Metric**.\n\nCreate an alert policy\n\nAfter you create the metric, create an alert policy to send an alert when\nthere is a scheduled snapshot failure. \n\nConsole\n\n1. In the Google Cloud console, go to the\n **Cloud Logging \\\u003e Logs-based metrics** page.\n\n [Go to the Logs-based metrics page](https://console.cloud.google.com/logs/metrics)\n2. Under **User-defined Metrics** , find your new metric named\n `user/scheduled_snapshot_failure_count`.\n\n3. Click the more_vert **More**\n menu button in this row and select **Create alert from metric**. The\n alert policy condition creation page opens.\n\n4. In the **Target** panel, under **Aggregator** , select **none**.\n\n5. Under **Filter**:\n\n 1. Click **Add a filter**.\n 2. Select **status** from the list.\n 3. In the **Value** field, type DONE.\n 4. Click **Apply**.\n\n6. Click **Show advanced options**.\n\n7. In the **Advanced aggregation** pane, click the **Aligner** list and select\n **sum**.\n\n8. In the **Configuration** panel, select the following values:\n\n - **Condition triggers if** : `Any time series violates`\n - **Condition** : `is above`\n - **Threshold** : `1`\n - **For** : `most recent value`\n\n9. Click **Save**.\n\n10. On the **Create new alerting policy** page, enter a policy name.\n Optionally, you can add notification channels and documentation for\n this policy.\n\n11. Click **Save**.\n\nWhat's next\n\n- Learn about snapshot schedule frequencies, retention policies, and naming rules in [About snapshot schedules for disks](/compute/docs/disks/about-snapshot-schedules).\n- Learn about [disk snapshots](/compute/docs/disks/snapshots).\n- Learn how to [create scheduled snapshots for disks](/compute/docs/disks/scheduled-snapshots).\n- Learn how to [view logs](/logging/docs/view/logs-explorer-interface)."]]