

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# CloudWatch Esempi di Synthetics utilizzando AWS CLI
<a name="cli_synthetics_code_examples"></a>

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando AWS Command Line Interface with CloudWatch Synthetics.

Le *azioni* sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.

Ogni esempio include un link al codice sorgente completo, in cui vengono fornite le istruzioni su come configurare ed eseguire il codice nel contesto.

**Topics**
+ [Azioni](#actions)

## Azioni
<a name="actions"></a>

### `associate-resource`
<a name="synthetics_AssociateResource_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare. `associate-resource`

**AWS CLI**  
**Come associare un canary a un gruppo**  
L’esempio `associate-resource` seguente associa un canary a un gruppo denominato `demo_group`.  

```
aws synthetics associate-resource \
    --group-identifier demo_group \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [AssociateResource AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/associate-resource.html)*Command Reference.* 

### `create-canary`
<a name="synthetics_CreateCanary_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`create-canary`.

**AWS CLI**  
**Come creare un canary**  
L’esempio `create-canary` seguente crea un canary denominato `demo_canary`.  

```
aws synthetics create-canary \
    --name demo_canary \
    --code '{"S3Bucket": "artifacts3bucket", "S3Key":"demo_canary.zip", "Handler": "index.lambda_handler"}' \
    --artifact-s3-location s3://amzn-s3-demo-bucket/demo_canary.zip \
    --execution-role-arn arn:aws:iam::123456789012:role/demo_canary_role \
    --schedule Expression="rate(10 minutes)" \
    --runtime-version syn-nodejs-puppeteer-9.1
```
Output:  

```
{
    "Canary": {
        "Id": "a1b2c3d4-5678-90ab-cdef-example11111",
        "Name": "demo_canary",
        "Code": {
            "Handler": "index.lambda_handler"
        },
        "ExecutionRoleArn": "arn:aws:iam::123456789012:role/demo_canary_role",
        "Schedule": {
            "Expression": "rate(10 minutes)",
            "DurationInSeconds": 0
        },
        "RunConfig": {
            "TimeoutInSeconds": 600,
            "MemoryInMB": 1000,
            "ActiveTracing": false
        },
        "SuccessRetentionPeriodInDays": 31,
        "FailureRetentionPeriodInDays": 31,
        "Status": {
            "State": "CREATING",
            "StateReasonCode": "CREATE_PENDING"
        },
        "Timeline": {
            "Created": "2024-10-15T19:03:08.826000+05:30",
            "LastModified": "2024-10-15T19:03:08.826000+05:30"
        },
        "ArtifactS3Location": "amzn-s3-demo-bucket/demo_canary.zip",
        "RuntimeVersion": "syn-nodejs-puppeteer-9.1",
        "Tags": {}
    }
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [CreateCanary AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/create-canary.html)*Command Reference.* 

### `create-group`
<a name="synthetics_CreateGroup_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`create-group`.

**AWS CLI**  
**Come creare un gruppo**  
L’esempio `create-group` seguente elimina un gruppo denominato `demo_group`.  

```
aws synthetics create-group \
    --name demo_group
```
Output:  

```
{
    "Group": {
        "Id": "example123",
        "Name": "demo_group",
        "Arn": "arn:aws:synthetics:us-east-1:123456789012:group:example123",
        "Tags": {},
        "CreatedTime": "2024-10-15T14:47:23.811000+05:30",
        "LastModifiedTime": "2024-10-15T14:47:23.811000+05:30"
    }
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [CreateGroup AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/create-group.html)*Command Reference.* 

### `delete-canary`
<a name="synthetics_DeleteCanary_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`delete-canary`.

**AWS CLI**  
**Come eliminare definitivamente un canary**  
L’esempio `delete-canary` seguente elimina un canary denominato `demo_canary`.  

```
aws synthetics delete-canary \
    --name demo_canary
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [DeleteCanary AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/delete-canary.html)*Command Reference.* 

### `delete-group`
<a name="synthetics_DeleteGroup_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`delete-group`.

**AWS CLI**  
**Come eliminare un gruppo**  
L’esempio `delete-group` seguente elimina un gruppo denominato `demo_group`.  

```
aws synthetics delete-group \
    --group-identifier demo_group
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [DeleteGroup AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/delete-group.html)*Command Reference.* 

### `describe-canaries-last-run`
<a name="synthetics_DescribeCanariesLastRun_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`describe-canaries-last-run`.

**AWS CLI**  
**Come visualizzare le informazioni relative all’esecuzione più recente di ogni canary**  
L’esempio `describe-canaries-last-run` seguente restituisce l’esecuzione più recente di ogni canary creato.  

```
aws synthetics describe-canaries-last-run
```
Output:  

```
{
    "CanariesLastRun": [
        {
            "CanaryName": "demo_canary",
            "LastRun": {
                "Id": "a1b2c3d4-5678-90ab-cdef-example11111",
                "Name": "demo_canary",
                "Status": {
                    "State": "PASSED",
                    "StateReason": "",
                    "StateReasonCode": ""
                },
                "Timeline": {
                    "Started": "2024-10-15T19:20:39.691000+05:30",
                    "Completed": "2024-10-15T19:20:58.211000+05:30"
                },
                "ArtifactS3Location": "cw-syn-results-123456789012-us-east-1/canary/us-east-1/demo_canary-abc-example1234/2024/10/15/13/50-39-690"
            }
        }
    ]
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [DescribeCanariesLastRun AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/describe-canaries-last-run.html)*Command Reference.* 

### `describe-canaries`
<a name="synthetics_DescribeCanaries_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`describe-canaries`.

**AWS CLI**  
**Come elencare i canary nel tuo account**  
L’esempio `describe-canaries` seguente elenca i dettagli dei canary nell’account in uso.  

```
aws synthetics describe-canaries
```
Output:  

```
{
    "Canaries": [
        {
            "Id": "a1b2c3d4-5678-90ab-cdef-example11111",
            "Name": "demo_canary",
            "Code": {
                "SourceLocationArn": "arn:aws:lambda:us-east-1:123456789012:layer:cwsyn-demo_canary-a1b2c3d4-5678-90ab-cdef-example11111b8:1",
                "Handler": "pageLoadBlueprint.handler"
            },
            "ExecutionRoleArn": "arn:aws:iam::123456789012:role/service-role/CloudWatchSyntheticsRole-demo_canary-a12-a123bc456789",
            "Schedule": {
                "Expression": "rate(5 minutes)",
                "DurationInSeconds": 0
            },
            "RunConfig": {
                "TimeoutInSeconds": 300,
                "MemoryInMB": 1000,
                "ActiveTracing": false
            },
            "SuccessRetentionPeriodInDays": 31,
            "FailureRetentionPeriodInDays": 31,
            "Status": {
            "State": "RUNNING"
            },
            "Timeline": {
                "Created": "2024-10-15T18:55:15.168000+05:30",
                "LastModified": "2024-10-15T18:55:40.540000+05:30",
                "LastStarted": "2024-10-15T18:55:40.540000+05:30"
            },
            "ArtifactS3Location": "cw-syn-results-123456789012-us-east-1/canary/us-east-1/demo_canary-a12-a123bc456789",
            "EngineArn": "arn:aws:lambda:us-east-1:123456789012:function:cwsyn-demo_canary-a1b2c3d4-5678-90ab-cdef-example111118:1",
            "RuntimeVersion": "syn-nodejs-puppeteer-9.1",
            "Tags": {
                "blueprint": "heartbeat"
            }
        }
    ]
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [DescribeCanaries AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/describe-canaries.html)*Command Reference.* 

### `describe-runtime-versions`
<a name="synthetics_DescribeRuntimeVersions_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`describe-runtime-versions`.

**AWS CLI**  
**Come restituire un elenco di versioni di runtime dei canary di Synthetics**  
L’esempio `describe-runtime-versions` seguente restituisce l’elenco delle versioni di runtime dei canary di Synthetics.  

```
aws synthetics describe-runtime-versions
```
Output:  

```
{
    "RuntimeVersions": [
        {
            "VersionName": "syn-nodejs-puppeteer-9.1",
            "Description": "Security fixes and bug fix for date range error in har. Dependencies: Node JS 20.x, Puppeteer-core 22.12.1, Chromium 126.0.6478.126",
            "ReleaseDate": "2024-10-02T05:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-9.0",
            "Description": "Upgraded Chromium and Puppeteer. Dependencies: Node JS 20.x, Puppeteer-core 22.12.1, Chromium 126.0.6478.126",
            "ReleaseDate": "2024-07-22T05:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-8.0",
            "Description": "Upgraded Chromium and Puppeteer. Dependencies: Node JS 20.x, Puppeteer-core 22.10.0, Chromium 125.0.6422.112",
            "ReleaseDate": "2024-06-21T05:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-7.0",
            "Description": "Upgraded Chromium and Puppeteer. Dependencies: Node JS 18.x, Puppeteer-core 21.9.0, Chromium 121.0.6167.139",
            "ReleaseDate": "2024-03-08T05:30:00+05:30"
            },
        {
            "VersionName": "syn-nodejs-puppeteer-6.2",
            "Description": "Updated shared libraries for Chromium and added ephemeral storage monitoring. Dependencies: Node JS 18.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2024-02-02T05:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-6.1",
            "Description": "Added puppeteer launch retry. Dependencies: Node JS 18.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2023-11-13T05:30:00+05:30",
            "DeprecationDate": "2024-03-08T13:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-6.0",
            "Description": "Reduced X-Ray traces of a canary run, improved duration metric and upgraded to NodeJS 18.x. Dependencies: Node JS 18.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2023-09-15T05:30:00+05:30",
            "DeprecationDate": "2024-03-08T13:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-5.2",
            "Description": "Updated shared libraries for Chromium. Dependencies: Node JS 16.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2024-02-01T05:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-5.1",
            "Description": "Fixes a bug about missing request headers in har. Dependencies: Node JS 16.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2023-08-09T05:30:00+05:30",
            "DeprecationDate": "2024-03-08T13:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-5.0",
            "Description": "Upgraded Puppeteer and Chromium. Dependencies: Node JS 16.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2023-07-21T05:30:00+05:30",
            "DeprecationDate": "2024-03-08T13:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-4.0",
            "Description": "Upgraded to NodeJS 16.x. Dependencies: Node JS 16.x, Puppeteer-core 5.5.0, Chromium 92.0.4512.0",
            "ReleaseDate": "2023-05-01T05:30:00+05:30",
            "DeprecationDate": "2024-03-08T13:30:00+05:30"
        }
    ]
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [DescribeRuntimeVersions AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/describe-runtime-versions.html)*Command Reference.* 

### `disassociate-resource`
<a name="synthetics_DisassociateResource_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`disassociate-resource`.

**AWS CLI**  
**Come rimuovere un canary da un gruppo**  
L’esempio `disassociate-resource` seguente rimuove un canary da un gruppo denominato `demo_group`.  

```
aws synthetics disassociate-resource \
    --group-identifier demo_group \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [DisassociateResource AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/disassociate-resource.html)*Command Reference.* 

### `get-canary-runs`
<a name="synthetics_GetCanaryRuns_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`get-canary-runs`.

**AWS CLI**  
**Come recuperare un elenco di esecuzioni per un canary specificato**  
L’esempio `get-canary-runs` seguente recupera un elenco di esecuzioni per il canary denominato `demo_canary`.  

```
aws synthetics get-canary-runs \
    --name demo_canary
```
Output:  

```
{
    "CanaryRuns": [
        {
            "Id": "a1b2c3d4-5678-90ab-cdef-example11111",
            "Name": "demo_canary",
            "Status": {
                "State": "PASSED",
                "StateReason": "",
                "StateReasonCode": ""
            },
            "Timeline": {
                "Started": "2024-10-16T10:38:57.013000+05:30",
                "Completed": "2024-10-16T10:39:25.793000+05:30"
            },
            "ArtifactS3Location": "cw-syn-results-123456789012-us-east-1/canary/us-east-1/demo_canary-abc-example1234/2024/10/15/13/50-39-690"
        }
    ]
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [GetCanaryRuns AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/get-canary-runs.html)*Command Reference.* 

### `get-canary`
<a name="synthetics_GetCanary_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`get-canary`.

**AWS CLI**  
**Come restituire informazioni complete su un canary**  
L’esempio `get-canary` seguente recupera le informazioni complete sul canary denominato `demo_canary`.  

```
aws synthetics get-canary \
    --name demo_canary
```
Output:  

```
{
    "Canary": {
        "Id": "a1b2c3d4-5678-90ab-cdef-example11111",
        "Name": "demo_canary",
        "Code": {
            "SourceLocationArn": "arn:aws:lambda:us-east-1:123456789012:layer:cwsyn-demo_canary-a1b2c3d4-5678-90ab-cdef-example111118:1",
            "Handler": "pageLoadBlueprint.handler"
        },
        "ExecutionRoleArn": "arn:aws:iam::123456789012:role/demo_canary_role",
        "Schedule": {
            "Expression": "rate(10 minutes)",
            "DurationInSeconds": 0
        },
        "RunConfig": {
            "TimeoutInSeconds": 300,
            "MemoryInMB": 1000,
            "ActiveTracing": false
        },
        "SuccessRetentionPeriodInDays": 31,
        "FailureRetentionPeriodInDays": 31,
        "Status": {
            "State": "RUNNING"
        },
        "Timeline": {
            "Created": "2024-10-15T18:55:15.168000+05:30",
            "LastModified": "2024-10-15T18:55:40.540000+05:30",
            "LastStarted": "2024-10-15T18:55:40.540000+05:30"
        },
        "ArtifactS3Location": "cw-syn-results-123456789012-us-east-1/canary/us-east-1/demo_canary-a12-a123bc456789",
        "EngineArn": "arn:aws:lambda:us-east-1:123456789012:function:cwsyn-demo_canary-a1b2c3d4-5678-90ab-cdef-example111118:1",
        "RuntimeVersion": "syn-nodejs-puppeteer-9.1",
        "Tags": {
            "blueprint": "heartbeat"
        }
    }
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [GetCanary AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/get-canary.html)*Command Reference.* 

### `get-group`
<a name="synthetics_GetGroup_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`get-group`.

**AWS CLI**  
**Come restituire informazioni su un gruppo**  
L’esempio `get-group` seguente restituisce informazioni sul gruppo denominato `demo_group`.  

```
aws synthetics get-group \
    --group-identifier demo_group
```
Output:  

```
{
    "Group": {
        "Id": "example123",
        "Name": "demo_group",
        "Arn": "arn:aws:synthetics:us-east-1:123456789012:group:example123",
        "Tags": {},
        "CreatedTime": "2024-10-15T14:47:23.811000+05:30",
        "LastModifiedTime": "2024-10-15T14:47:23.811000+05:30"
    }
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [GetGroup AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/get-group.html)*Command Reference.* 

### `list-associated-groups`
<a name="synthetics_ListAssociatedGroups_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`list-associated-groups`.

**AWS CLI**  
**Come recuperare un elenco di gruppi**  
L’esempio `list-associated-groups` seguente restituisce un elenco dei gruppi associati al canary denominato `demo_canary`.  

```
aws synthetics list-associated-groups \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary
```
Output:  

```
{
    "Groups": [
        {
            "Id": "example123",
            "Name": "demo_group",
            "Arn": "arn:aws:synthetics:us-east-1:123456789012:group:example123"
        }
    ]
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [ListAssociatedGroups AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/list-associated-groups.html)*Command Reference.* 

### `list-group-resources`
<a name="synthetics_ListGroupResources_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`list-group-resources`.

**AWS CLI**  
**Per restituire un elenco ARNs dei canarini associati al gruppo specificato**  
L'`list-group-resources`esempio seguente restituisce un elenco ARNs dei canarini associati al gruppo denominato. `demo_group`  

```
aws synthetics list-group-resources \
    --group-identifier demo_group
```
Output:  

```
{
    "Resources": [
        "arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary"
    ]
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [ListGroupResources AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/list-group-resources.html)*Command Reference.* 

### `list-groups`
<a name="synthetics_ListGroups_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`list-groups`.

**AWS CLI**  
**Come restituire un elenco di tutti i gruppi dell’account**  
L’esempio `list-groups` seguente recupera un elenco di tutti i gruppi nell’account.  

```
aws synthetics list-groups
```
Output:  

```
{
    "Groups": [
        {
            "Id": "example123",
            "Name": "demo_group",
            "Arn": "arn:aws:synthetics:us-east-1:123456789012:group:example123"
        }
    ]
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [ListGroups AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/list-groups.html)*Command Reference.* 

### `list-tags-for-resource`
<a name="synthetics_ListTagsForResource_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`list-tags-for-resource`.

**AWS CLI**  
**Esempio 1: come visualizzare i tag associati a un canary**  
L’esempio `list-tags-for-resource` seguente restituisce i tag associati a un canary denominato `demo_canary`.  

```
aws synthetics list-tags-for-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary
```
Output:  

```
{
    "Tags": {
        "blueprint": "heartbeat"
    }
}
```
**Esempio 2: come visualizzare i tag associati a un gruppo**  
L’esempio `list-tags-for-resource` seguente restituisce i tag associati a un gruppo denominato `demo_group`.  

```
aws  synthetics list-tags-for-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:group:example123
```
Output:  

```
{
    "Tags": {
        "team": "Devops"
    }
}
```
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [ListTagsForResource AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/list-tags-for-resource.html)*Command Reference.* 

### `start-canary`
<a name="synthetics_StartCanary_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`start-canary`.

**AWS CLI**  
**Come eseguire un canary**  
L’esempio `start-canary` seguente esegue un canary denominato `demo_canary`.  

```
aws synthetics start-canary \
    --name demo_canary
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [StartCanary AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/start-canary.html)*Command Reference.* 

### `stop-canary`
<a name="synthetics_StopCanary_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`stop-canary`.

**AWS CLI**  
**Come arrestare un canary**  
L’esempio `stop-canary` seguente arresta il canary denominato `demo_canary`.  

```
aws synthetics stop-canary \
    --name demo_canary
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [StopCanary AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/stop-canary.html)*Command Reference.* 

### `tag-resource`
<a name="synthetics_TagResource_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`tag-resource`.

**AWS CLI**  
**Esempio 1: come assegnare un tag al canary**  
L’esempio `tag-resource` seguente assegna un tag al canary denominato `demo_canary`.  

```
aws synthetics tag-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary \
    --tags blueprint=heartbeat
```
Questo comando non produce alcun output.  
**Esempio 2: come assegnare un tag al gruppo**  
L’esempio `tag-resource` seguente assegna un tag al gruppo denominato `demo_group`.  

```
aws synthetics tag-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:group:example123 \
    --tags team=Devops
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [TagResource AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/tag-resource.html)*Command Reference.* 

### `untag-resource`
<a name="synthetics_UntagResource_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`untag-resource`.

**AWS CLI**  
**Esempio 1: come rimuovere un tag dal canary**  
L’esempio `untag-resource` seguente rimuove un tag dal canary denominato `demo_canary`.  

```
aws synthetics untag-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary \
    --tag-keys blueprint
```
Questo comando non produce alcun output.  
**Esempio 2: come rimuovere un tag dal gruppo**  
L’esempio `untag-resource` seguente rimuove un tag dal gruppo denominato `demo_group`.  

```
aws synthetics untag-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:group:example123 \
    --tag-keys team
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [UntagResource AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/untag-resource.html)*Command Reference.* 

### `update-canary`
<a name="synthetics_UpdateCanary_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`update-canary`.

**AWS CLI**  
**Come aggiornare un canary**  
L’esempio `update-canary` seguente aggiorna la configurazione di un canary denominato `demo_canary`.  

```
aws synthetics update-canary \
    --name demo_canary \
    --schedule Expression="rate(15 minutes)"
```
Questo comando non produce alcun output.  
Per ulteriori informazioni, consulta [Synthetic monitoring (canaries)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) nella *Amazon CloudWatch User Guide*.  
+  Per i dettagli sull'API, consulta [UpdateCanary AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/update-canary.html)*Command Reference.* 