

# Create network analyzer configuration and add resources
<a name="network-analyzer-create-resources"></a>

Before you can stream trace messages, create a network analyzer configuration and add the resources you want to monitor to this configuration. A LoRaWAN network analyzer configuration is a set of settings and rules that define how network analyzer should capture and analyze traffic in a LoRaWAN network. It specifies the types of information and messages that should be included in the network trace, and any filtering or processing rules that should be applied.

a LoRaWAN network analyzer configuration providesvisibility into the communication between LoRaWAN devices and the network server. This enables troubleshooting, performance monitoring, and security analysis of the LoRaWAN network.

When you create a configuration, you can:
+ Specify a configuration name and optional description.
+ Customize the configuration settings such as frame info and level of detail for your log messages.
+ Add the resources that you want to monitor. The resources can be wireless devices or wireless gateways, or both.

The configuration settings that you specify will determine the trace messaging information that you'll receive for resources you add to the configuration. You may also want to create multiple configurations depending on your monitoring use case.

The following shows how to create a configuration and add resources.

**Topics**
+ [Create a network analyzer configuration](network-analyzer-create.md)
+ [Add resources and update the network analyzer configuration](network-analyzer-resources.md)

# Create a network analyzer configuration
<a name="network-analyzer-create"></a>

Before you can monitor your wireless gateways or wireless devices, you must create a network analyzer configuration. When creating the configuration, you only need to specify a configuration name. You can customize your configuration settings and add the resources that you want to monitor to your configuration even after it's created. The configuration settings determine the trace messaging information that you'll receive for those resources.

Depending on the resources you want to monitor and the level of information you want to receive for them, you may want to create multiple configurations. For example, you can create a configuration that displays only error information for a set of gateways in your AWS account. You can also create a configuration that displays all information about a wireless device that you want to monitor.

The following sections show the various configuration settings and how to create your configuration.

## Configuration settings
<a name="network-analyzer-config-settings"></a>

When creating or updating your network analyzer configuration, you can also customize the following parameters to filter the log stream information.
+ 

**Frame info**  
This setting is the frame info for your wireless device resources for trace messages. The frame info can be used to debug the communication between your network server and the end devices. It is enabled by default.
+ 

**Log levels**  
You can view Info or Error logs, or you can turn off logging.
  + 

**Info**  
Logs with a log level of **Info** are more verbose and contain both error log streams and informational log streams. The informational logs can be used to view changes to the state of a device or gateway.
**Note**  
Collecting more verbose log streams can incur additional costs. For more information about pricing, see [AWS IoT Core pricing](https://aws.amazon.com/iot-core/pricing/). 
  + 

**Error**  
Logs with a log level of **Error** are less verbose and display only error information. You can use these logs when an application has an error, such as a device connection error. By using the information from the log stream, you can identify and troubleshoot errors for resources in your fleet.

## Create a configuration using the console
<a name="network-analyzer-create-configuration-console"></a>

You can create a network analyzer configuration and customize the optional parameters using the AWS IoT console or the AWS IoT Wireless API. You can also create multiple configurations and later delete any configurations that you're no longer using.

**Create a network analyzer configuration**  


1. Open the [Network Analyzer hub of the AWS IoT console](https://console.aws.amazon.com/iot/home#/wireless/networkAnalyzer) and choose **Create configuration**.

1. Specify the configuration settings.
   + 

**Name, description, and tags**  
Specify a unique **Configuration name** that only contains letters, numbers, hyphens, or underscores. Use the optional **Description** field to provide information about the configuration, and the **Tags** field to add key-value pairs of metadata about the configuration. For more information about naming and describing your resources, see [Describing your AWS IoT Wireless resources](getting-started.md#iotwireless-describe-resources).
   + 

**Configuration settings**  
Choose whether to disable frame info, and use **Select log levels** to choose the log levels that you want to use for your trace message logs. Choose **Next**.

1. Add resources to your configuration. You can either add your resources now or choose **Create** and then add your resources later. To add resources later, choose **Create**.

   In the **Network Analyzer hub page**, you'll see the configuration that you created along with its settings. To view the details of the new configuration, choose the configuration name. 

**Delete your network analyzer configuration**  


You can create multiple network analyzer configurations depending on the resources you want to monitor and the level of trace messaging information that you want to receive for them. 

**To remove configurations from the console**

1. Go to the [Network Analyzer hub of the AWS IoT console](https://console.aws.amazon.com/iot/home#/wireless/networkAnalyzer) and choose the configuration that you want to remove.

1. Choose **Actions**, and then choose **Delete**.

## Create a configuration using the API
<a name="network-analyzer-create-configuration-api"></a>

To create a network analyzer configuration using the API, use the [ CreateNetworkAnalyzerConfiguration](https://docs.aws.amazon.com/iot-wireless/latest/apireference/API_CreateNetworkAnalyzerConfiguration.html) API operation or the [ create-network-analyzer-configuration](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/create-network-analyzer-configuration.html) CLI command.

When you create your configuration, you only need to specify a configuration name. You can also use this API operation to specify the configuration settings and add resources when creating the configuration. Alternatively, you can specify them later by using the [UpdateNetworkAnalyzerConfiguration](https://docs.aws.amazon.com/iot-wireless/latest/apireference/API_UpdateNetworkAnalyzerConfiguration.html) API operation or the [update-network-analyzer-configuration](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/update-network-analyzer-configuration.html) CLI.
+ 

**Create a configuration**  
When you create your configuration, you must specify a name. For example, the following command creates a configuration by providing only a name and an optional description. By default, the configuration has frame info activated and uses a log level of `INFO`.

  ```
  aws iotwireless create-network-analyzer-configuration \ 
      --configuration-name My_Network_Analyzer_Config \ 
      --description "My first network analyzer configuration"
  ```

  Running this command displays the ARN and ID of your network analyzer configuration.

  ```
  {
      "Arn": "arn:aws:iotwireless:us-east-1:123456789012:NetworkAnalyzerConfiguration/12345678-a1b2-3c45-67d8-e90fa1b2c34d",
      "Id": "12345678-a1b2-3c45-67d8-e90fa1b2c34d"
  }
  ```
+ 

**Create configuration with resources**  
To customize the configuration settings, use the `trace-content` parameter. To add resources, use the `WirelessDevices` and `WirelessGateways` parameters to specify the gateways, devices, or both that you want to add to your configuration. For example, the following command customizes the configuration settings and adds to your configuration the wireless resources, specified by their `WirelessGatewayID` and `WirelessDeviceID`.

  ```
  aws iotwireless create-network-analyzer-configuration \ 
      --configuration-name My_NetworkAnalyzer_Config \ 
      --trace-content WirelessDeviceFrameInfo=DISABLED,LogLevel="ERROR" \ 
      --wireless-gateways "12345678-a1b2-3c45-67d8-e90fa1b2c34d" "90123456-de1f-2b3b-4c5c-bb1112223cd1"   
      --wireless-devices "1ffd32c8-8130-4194-96df-622f072a315f"
  ```

  The following example shows the output of running the command:

  ```
  {
      "Arn": "arn:aws:iotwireless:us-east-1:123456789012:NetworkAnalyzerConfiguration/12345678-a1b2-3c45-67d8-e90fa1b2c34d",
      "Id": "12345678-a1b2-3c45-67d8-e90fa1b2c34d"
  }
  ```

**List network analyzer configurations**  
You can create multiple network analyzer configurations depending on the resources that you want to monitor and the level of detail of trace messaging information that you want to receive for the resources. After you create these configurations, you can use the [ListNetworkAnalyzerConfigurations](https://docs.aws.amazon.com/iot-wireless/latest/apireference/API_ListNetworkAnalyzerConfigurations.html) API operation or the [list-network-analyzer-configuration](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/list-network-analyzer-configuration.html) CLI command to get a list of these configurations.

```
aws iotwireless list-network-analyzer-configurations
```

Running this command displays all the network analyzer configurations in your AWS account. You can also use the `max-results` parameter to specify how many configurations you want to display. The following shows the output of running this command.

```
{
   "NetworkAnalyzerConfigurationList": [ 
      { 
         "Arn": "arn:aws:iotwireless:us-east-1:123456789012:NetworkAnalyzerConfiguration/12345678-a1b2-3c45-67d8-e90fa1b2c34d",
         "Name": "My_Network_Analyzer_Config1"
      },
      { 
         "Arn": "arn:aws:iotwireless:us-east-1:123456789012:NetworkAnalyzerConfiguration/90123456-a1a2-9a87-65b4-c12bf3c2d09a",
         "Name": "My_Network_Analyzer_Config2"
      }
   ]
}
```

**Delete your network analyzer configuration**  
You can delete a configuration that you're no longer using with the [ DeleteNetworkAnalyzerConfiguration](https://docs.aws.amazon.com/iot-wireless/latest/apireference/API_DeleteNetworkAnalyzerConfiguration.html) API operation or the [delete-network-analyzer-configuration](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/delete-network-analyzer-configuration.html) CLI command.

```
aws iotwireless delete-network-analyzer-configuration \ 
    --configuration-name My_NetworkAnalyzer_Config
```

Running this command doesn't produce any output. To see the available configurations, you can use the `ListNetworkAnalyzerConfigurations` API operation.

## Next steps
<a name="network-analyzer-create-next"></a>

Now that you've created a network analyzer configuration, you can add resources to your configuration or update your configuration settings. For more information, see [Add resources and update the network analyzer configuration](network-analyzer-resources.md). 

# Add resources and update the network analyzer configuration
<a name="network-analyzer-resources"></a>

Before you can activate trace messaging, you must add resources to your configuration. You can use only a single, default network analyzer configuration. AWS IoT Core for LoRaWAN assigns the name, **NetworkAnalyzerConfig\$1Default**, to this configuration, and this field can't be edited. This configuration is automatically added to your AWS account when you use network analyzer from the console.

You can add the resources that you want to monitor to this default configuration. Resources can be either or both LoRaWAN devices and LoRaWAN gateways. To add each individual resource to the configuration, use the wireless gateway and wireless device identifiers.

## Configuration settings
<a name="resources-config-settings"></a>

To configure settings, first add resources to your default configuration and activate trace messaging. After you've received the trace message logs, you can also customize the following parameters to update your default configuration and filter the log stream.
+ 

**Frame info**  
This setting is the frame info of your wireless device resources for trace messages. the frame info is enabled by default, and can be used to debug the communication between your network server and the end devices.
+ 

**Log levels**  
You can view Info or Error logs, or you can turn off logging.
  + 

**Info**  
Logs with a log level of **Info** are more verbose and contain log streams that are both informative and contain errors. The informative logs can be used to view changes to the state of a device or gateway.
**Note**  
Collecting more verbose log streams can incur additional costs. For more information about pricing, see [AWS IoT Core pricing](https://aws.amazon.com/iot-core/pricing/). 
  + 

**Error**  
Logs with a log level of **Error** are less verbose and display only error information. You can use these logs when an application has an error, such as a device connection error. By using the information from the log stream, you can identify and troubleshoot errors for resources in your fleet. 

## Prerequisites
<a name="resources-prereq"></a>

Before you can add resources, you must have onboarded the gateways and devices that you want to monitor to AWS IoT Core for LoRaWAN. For more information, see [Connecting gateways and devices to AWS IoT Core for LoRaWAN](lorawan-getting-started.md).

## Add resources and update the network analyzer configuration by using the console
<a name="add-resources-console"></a>

You can add resources and customize the optional parameters by using the AWS IoT console or the AWS IoT Wireless API. In addition to resources, you can also edit your configuration settings and save the updated configuration.

**To add resources to your configuration (console)**  


1. Open the [Network Analyzer hub of the AWS IoT console](https://console.aws.amazon.com/iot/home#/wireless/networkAnalyzer) and choose the network analyzer configuration, **NetworkAnalyzerConfig\$1Default**.

1. Choose **Add resources**.

1. Add the resources you want to monitor by using the wireless gateway and wireless device identifiers. You can add up to 250 wireless gateways or wireless devices. To add your resource:

   1. Use the **View gateways** or **View devices** tab to see the list of gateways and devices that you've added to your AWS account.

   1. Copy the `WirelessDeviceID` or the `WirelessGatewayID` of the device or gateway that you want to monitor and enter the identifier value for the corresponding resource.

   1. To continue adding resources, choose **Add gateway** or **Add device** and add your wireless gateway or device. If you added a resource that you no longer want to monitor, choose **Remove resource**.

1. After you've added all the resources, choose **Add**.

   You'll see the number of gateways and devices that you added in the **Network Analyzer hub page**. You can still continue adding gateways and devices until you activate the trace messaging session. After the session has been activated, to add resources, you'll have to deactivate the session.

**To edit the network analyzer configuration (console)**  
You can also edit the network analyzer configuration and choose whether to disable frame info and the log level for your trace message logs. 

1. Open the [Network Analyzer hub of the AWS IoT console](https://console.aws.amazon.com/iot/home#/wireless/networkAnalyzer) and choose the network analyzer configuration, **NetworkAnalyzerConfig\$1Default**.

1. Choose **Edit**.

1. Choose whether to disable frame info and use **Select log levels** to choose the log levels that you want to use for your trace message logs. Choose **Save**.

   You'll see the configuration settings that you specified in the details page of your network analyzer configuration.

## Add resources and update the network analyzer configuration by using the API
<a name="network-analyzer-add-resources-api"></a>

You can use the [AWS IoT Wireless API operations](https://docs.aws.amazon.com/iot-wireless/latest/apireference/) or the [AWS IoT Wireless CLI commands](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/index.html) to add resources and update the configuration settings for your network analyzer configuration.
+ To add resources and update your network analyzer configuration, use the [UpdateNetworkAnalyzerConfiguration](https://docs.aws.amazon.com/iot-wireless/latest/apireference/API_UpdateNetworkAnalyzerConfiguration.html) API or the [update-network-analyzer-configuration](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/update-network-analyzer-configuration.html) CLI.
  + 

**Add resources**  
For the wireless devices you want to add, use `WirelessDevicesToAdd` to enter the `WirelessDeviceID` for the devices as an array of strings. For the wireless gateways you want to add, use `WirelessGatewaysToAdd` to enter the `WirelessGatewayID` for the gateways as an array of strings.
  + 

**Edit configuration**  
To edit your network analyzer configuration, use the `TraceContent` parameter to specify whether `WirelessDeviceFrameInfo` should be `ENABLED` or `DISABLED`, and whether the `LogLevel` parameter should be `INFO`, `ERROR`, or `DISABLED`. 

  ```
  {
     "TraceContent": { 
        "LogLevel": "string",
        "WirelessDeviceFrameInfo": "string"
     },
     "WirelessDevicesToAdd": [ "string" ],
     "WirelessDevicesToRemove": [ "string" ],
     "WirelessGatewaysToAdd": [ "string" ],
     "WirelessGatewaysToRemove": [ "string" ]
  }
  ```
+ To get information about the configuration and the resources that you've added, use the [GetNetworkAnalyzerConfiguration](https://docs.aws.amazon.com/iot-wireless/latest/apireference/API_UpdateNetworkAnalyzerConfiguration.html) API operation or the [get-network-analyzer-configuration](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/get-network-analyzer-configuration.html) command. Provide the name of the network analyzer configuration, `NetworkAnalyzerConfig_Default`, as input.

## Next steps
<a name="network-analyzer-resources-next"></a>

Now that you've added resources and specified any optional configuration settings for your configuration, you can use the WebSocket protocol to establish a connection with AWS IoT Core for LoRaWAN for using network analyzer. You can then activate trace messaging and start receiving trace messages for your resources. For more information, see [Stream network analyzer trace messages with WebSockets](network-analyzer-api.md).