

# Monitoring Amazon CloudSearch Domains
<a name="monitoring-domains"></a>

The AWS Management Console enables you to easily monitor the status and configuration of your search domains and view your Amazon CloudSearch usage. You can also get configuration information about particular domains with the AWS CLI and AWS SDKs.

**Topics**
+ [Getting Information About an Amazon CloudSearch Domain](getting-domain-info.md)
+ [Monitoring an Amazon CloudSearch Domain with Amazon CloudWatch](cloudwatch-monitoring.md)
+ [Logging Amazon CloudSearch Configuration API Calls with AWS CloudTrail](logging-config-api-calls.md)
+ [Tracking your Amazon CloudSearch Usage and Charges](tracking-usage.md)

# Getting Information About an Amazon CloudSearch Domain
<a name="getting-domain-info"></a>

You can retrieve the following information about each of your search domains:
+ **Domain name**—The name of the domain.
+ **ARN**—The domain's Amazon Resource Name (ARN).
+ **Document endpoint**—The endpoint through which you can submit document updates.
+ **Search endpoint**—The endpoint through which you can submit search requests.
+ **Searchable documents**—The number of documents that have been indexed.
+ **Access policies**—The access policies configured for the domain's document and search endpoints.
+ **Analysis schemes**—The text analysis schemes that can be applied to the domain's index fields.
+ **Index fields**—The name and type of each configured index field.
+ **Expressions**—The expressions that can be used for sorting search results.
+ **Suggesters**—The suggesters that can be used to retrieve suggestions for incomplete queries.

When a domain is first created, the domain status will indicate that the domain is currently being activated and no other information is available. Once your domain's document and search endpoints are available, the domain status shows the endpoint addresses that you can use to add data and submit search requests. If you haven't submitted any data for indexing, the number of searchable documents is zero. 

You can view all of the information about your domain through the [Amazon CloudSearch console](#getting-domain-info-console). When you use the `aws cloudsearch describe-domains` command or the AWS SDKs, the domain's ARN is shown within the domain's access policies.

To get the number of searchable documents, use the console or submit a `matchall` request to your domain's search endpoint. 

```
q=matchall&q.parser=structured&size=0
```

**Topics**
+ [Amazon CloudSearch console](#getting-domain-info-console)
+ [Getting Amazon CloudSearch Domain Information Using the AWS CLI](#getting-domain-info-clt)
+ [DescribeDomains](#getting-domain-info-sdk)

## Getting Domain Information Using the Amazon CloudSearch Console
<a name="getting-domain-info-console"></a>

You can use the Amazon CloudSearch console to view information about all of your domains. The dashboard of the console shows a summary of each domain that you have created, including the domain name, status, and number of searchable documents. To update the table with the latest information, click the **Refresh** button at the top of the page. 

A domain can be in one of five states:
+ **Loading**—The domain has just been created and is still being initialized. You must wait until the domain status changes to PROCESSING, NEEDS INDEXING, or ACTIVE before you can start uploading documents.
+ **Active**—The domain is running and all configured fields have been indexed.
+ **Needs Indexing**—You have made changes to the domain configuration that require rebuilding the index. If you search the domain, these changes won't be reflected in the results. When you are done making changes, choose **Actions**, **Run indexing** to rebuild your index.
+ **Processing**—Configuration changes are being applied to your domain. If you search the domain, the most recent configuration changes might not be reflected in the results.
+ **Being Deleted**—You chose to delete the domain and its contents, and the domain and all of its resources are in the process of being removed. When deletion is complete, the domain will be removed from the list of domains.

 From the Amazon CloudSearch dashboard, you can do the following:
+ View the status of your search domains
+ Access the dashboard for a particular domain
+ Access the Amazon CloudSearch documentation and other resources

**To view detailed information about a particular domain**

1. Open the Amazon CloudSearch console at [https://console.aws.amazon.com/cloudsearch/home](https://console.aws.amazon.com/cloudsearch/home).

1. Choose **Domains** from the left navigation pane.

<a name="domain-dashboard"></a>The domain dashboard shows the status summary for the selected domain. From the domain dashboard, you can do the following:
+ View the status of the domain
+ Upload documents to the domain
+ Search the domain
+ Access the domain configuration pages
+ Delete the domain

## Getting Amazon CloudSearch Domain Information Using the AWS CLI
<a name="getting-domain-info-clt"></a>

You use the `aws cloudsearch describe-domains` command to get the status of your search domains. To get specific information such as the access policies, availability options, and scaling options configured for a domain, you use the separate `describe` commands for each option. For information about installing and setting up the AWS CLI, see the [AWS Command Line Interface User Guide](https://docs.aws.amazon.com/cli/latest/userguide/). 

**To get domain status information**
+ Run the `aws cloudsearch describe-domains` command to get information about all of your domains. To get information about specific domains, use the `--domain-names` option to specify the domains that you are interested in. For example, the following request gets the status of the `movies` domain:

  ```
  aws cloudsearch describe-domains --domain-names movies
                          
  {
      "DomainStatusList": [
          {
              "SearchInstanceType": "search.small", 
              "DomainId": "965407640801/movies", 
              "Created": true, 
              "Deleted": false, 
              "SearchInstanceCount": 1, 
              "DomainName": "movies", 
              "SearchService": {
                  "Endpoint": "search-movies-m4fcjhuxgj6i76smhyiz7pfxsu.us-east-1.cloudsearch.amazonaws.com"
              }, 
              "RequiresIndexDocuments": false, 
              "Processing": true, 
              "DocService": {
                  "Endpoint": "doc-movies-m4fcjhuxgj6i76smhyiz7pfxsu.us-east-1.cloudsearch.amazonaws.com"
              }, 
              "ARN": "arn:aws:cloudsearch:us-east-1:965407640801:domain/movies", 
              "SearchPartitionCount": 1
          }
      ]
  }
  ```

The `describe-domains` command does not return the number of searchable documents in the domain. To get the number of searchable documents, use the console or submit a `matchall` request to your domain's search endpoint: 

```
q=matchall&q.parser=structured&size=0
```

**To get the analysis schemes configured for a domain**
+ Run the `aws cloudsearch describe-analysis-schemes` command. For example, the following request gets the analysis schemes configured for the `movies` domain:

  ```
  aws cloudsearch describe-analysis-schemes --domain-name movies
                  
  {
      "AnalysisSchemes": [
          {
              "Status": {
                  "PendingDeletion": false, 
                  "State": "Active", 
                  "CreationDate": "2014-03-28T19:27:30Z", 
                  "UpdateVersion": 31, 
                  "UpdateDate": "2014-03-28T19:27:30Z"
              }, 
              "Options": {
                  "AnalysisSchemeLanguage": "en", 
                  "AnalysisSchemeName": "samplescheme", 
                  "AnalysisOptions": {
                      "AlgorithmicStemming": "none", 
                      "Synonyms": "{\"aliases\":{\"youth\":[\"young adult\"]},\"groups\":[[\"tool box\",\"toolbox\"],[\"band saw\",\"bandsaw\"],[\"drill press\",\"drillpress\"]]}", 
                      "StemmingDictionary": "{}", 
                      "Stopwords": "[]"
                  }
              }
          }
      ]
  }
  ```

**To get the availability options configured for a domain**
+ Run the `aws cloudsearch describe-availability-options` command. For example, the following request gets the availability options configured for the `movies` domain. If Multi-AZ is enabled for the domain, the `Options` value is set to `true`:

  ```
  aws cloudsearch describe-availability-options --domain-name movies
  
  {
      "AvailabilityOptions": {
          "Status": {
              "PendingDeletion": false, 
              "State": "Processing", 
              "CreationDate": "2014-04-30T20:42:57Z", 
              "UpdateVersion": 13, 
              "UpdateDate": "2014-05-01T00:17:45Z"
          }, 
          "Options": true
      }
  }
  ```

**To get the expressions configured for a domain**
+ Run the `aws cloudsearch describe-expressions` command. For example, the following request gets the expressions configured for the `movies` domain: 

  ```
  aws cloudsearch describe-expressions --domain-name movies
  
  {
      "Expression": {
          "Status": {
              "PendingDeletion": false, 
              "State": "Processing", 
              "CreationDate": "2014-05-01T01:15:18Z", 
              "UpdateVersion": 52, 
              "UpdateDate": "2014-05-01T01:15:18Z"
          }, 
          "Options": {
              "ExpressionName": "popularhits", 
              "ExpressionValue": "((0.3*popularity)/10.0)+(0.7* _score)"
          }
      }
  }
  ```

## Getting Domain Information Using the AWS SDKs
<a name="getting-domain-info-sdk"></a>

The AWS SDKs (except the Android and iOS SDKs) support all of the Amazon CloudSearch actions defined in the Amazon CloudSearch Configuration API, including `DescribeDomains`. For more information about installing and using the AWS SDKs, see [AWS Software Development Kits](http://aws.amazon.com/code).

The `DescribeDomains` action does not return the number of searchable documents in the domain. To get the number of searchable documents, use the console or submit a `matchall` request to your domain's search endpoint:

```
q=matchall&q.parser=structured&size=0
```

# Monitoring an Amazon CloudSearch Domain with Amazon CloudWatch
<a name="cloudwatch-monitoring"></a>

Amazon CloudSearch automatically sends metrics to Amazon CloudWatch so that you can gather and analyze performance statistics. You can monitor these metrics by using the Amazon CloudSearch console, or by using the CloudWatch console, AWS CLI, or AWS SDKs. Each of your domain's search instances sends metrics to CloudWatch at one-minute intervals. The metrics are archived for two weeks; after that period, the data is discarded. 

There is no charge for the Amazon CloudSearch metrics that are reported through CloudWatch. If you set alarms on the metrics, you will be billed at standard [CloudWatch rates](http://aws.amazon.com/cloudwatch/pricing/). You can use the metrics in all regions supported by Amazon CloudSearch.

**Topics**
+ [Amazon CloudSearch Metrics](#cloudsearch-metrics)
+ [Dimensions for Amazon CloudSearch Metrics](#cloudsearch-metric-dimensions)
+ [Generating SDK for Java Metrics for Amazon CloudSearch](#java-sdk-metrics)
+ [Viewing CloudWatch Metrics for an Amazon CloudSearch Domain](#viewing-metrics)

Not all statistics, such as *Average* or *Sum*, are applicable for every metric. However, all of these values are available through the Amazon CloudSearch console, or by using the CloudWatch console, AWS CLI, or AWS SDKs for all metrics. In the following table, each metric has a list of Valid Statistics that is applicable to that metric.

## Amazon CloudSearch Metrics
<a name="cloudsearch-metrics"></a>

The `AWS/CloudSearch` namespace includes the following metrics.


| Metric | Description | 
| --- | --- | 
|  `SuccessfulRequests`  |  The number of search requests successfully processed by a search instance.  Units: Count Valid statistics: Maximum, Sum  | 
|  `SearchableDocuments`  |  The number of searchable documents in the domain's search index.  Units: Count Valid statistics: Maximum  | 
|  `IndexUtilization`  |  The percentage of the search instance's index capacity that has been used. The Maximum value indicates the percentage of the domain's index capacity that has been used. Units: Percent Valid statistics: Average, Maximum  | 
|  `Partitions`  |  The number of partitions the index is distributed across. Units: Count Valid statistics: Minimum, Maximum  | 

## Dimensions for Amazon CloudSearch Metrics
<a name="cloudsearch-metric-dimensions"></a>

Amazon CloudSearch sends the ClientId and DomainName dimensions to CloudWatch.


| Dimension | Description | 
| --- | --- | 
| `ClientId` |  The AWS account ID.  | 
| `DomainName` |  The name of the search domain.  | 

## Generating SDK for Java Metrics for Amazon CloudSearch
<a name="java-sdk-metrics"></a>

The AWS SDK for Java can generate performance metrics for your Amazon CloudSearch client and send them to CloudWatch for visualization. For the Java VM arguments that enable this feature, see [Enabling Metrics for the AWS SDK for Java](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/generating-sdk-metrics.html) in the *AWS SDK for Java Developer Guide*.

You can use the following code to test metrics generation. The code creates a new CloudWatch client and performs 2,500 searches. Because the SDK only sends metrics once per minute, long-running clients work best. The code uses the [default credential provider chain](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials.html#credentials-default).

```
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomain;
import com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClientBuilder;
import com.amazonaws.services.cloudsearchdomain.model.SearchRequest;

public class Metrics {

  public static void main(String[] args) {

    String search_endpoint = "https://search-domain-id.us-west-1.cloudsearch.amazonaws.com";
    String region = "us-west-1";

    AwsClientBuilder.EndpointConfiguration endpointConfig = new AwsClientBuilder
        .EndpointConfiguration(search_endpoint, region);
        
    AmazonCloudSearchDomainClientBuilder builder = AmazonCloudSearchDomainClientBuilder
        .standard()
        .withEndpointConfiguration(endpointConfig);
        
    AmazonCloudSearchDomain client = builder.build();
        
    String query;
    SearchRequest request = new SearchRequest();
    com.amazonaws.services.cloudsearchdomain.model.SearchResult test = client.search(request);
                
    for (int i = 0; i < 2500; i++) {
      query = "test";
      request.setQuery(query);
      test = client.search(request);
      System.out.println(test.toString());
    }
  }
}
```

To verify that the SDK is sending metrics to CloudWatch, check the **Metrics** page of the CloudWatch console and look for **AWSSDK/Java** under the **Custom Namespaces** section. The metrics might take several minutes to display.

## Viewing CloudWatch Metrics for an Amazon CloudSearch Domain
<a name="viewing-metrics"></a>

The Amazon CloudSearch console graphs the metrics reported to CloudWatch. You can also access the metrics through the [CloudWatch console](https://console.aws.amazon.com/cloudwatch), AWS CLI, and AWS SDKs. For more information, see [Viewing, Graphing, and Publishing Metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/working_with_metrics.html) in the * Amazon CloudWatch Developer Guide*.

**To view metrics for a search domain using the Amazon CloudSearch console**

1. Open the Amazon CloudSearch console at [https://console.aws.amazon.com/cloudsearch](https://console.aws.amazon.com/cloudsearch).

1. Choose **Domains** from the left navigation pane.

1. Click the name of the domain, and then go to the **Monitoring** tab.

# Logging Amazon CloudSearch Configuration API Calls with AWS CloudTrail
<a name="logging-config-api-calls"></a>

Amazon CloudSearch integrates with AWS CloudTrail, a service that provides a record of actions taken by a user, role, or an AWS service in Amazon CloudSearch. CloudTrail captures all configuration API calls for Amazon CloudSearch as events.

**Note**  
CloudTrail only captures calls to the [configuration API](configuration-api.md), such as `CreateDomain` and `UpdateServiceAccessPolicies`, not the [document service API](document-service-api.md) nor the [search API](search-api.md).

The calls captured include calls from the Amazon CloudSearch console, CLI, or SDKs. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for Amazon CloudSearch. If you don't configure a trail, you can still view the most recent events in the CloudTrail console in **Event history**. Using the information collected by CloudTrail, you can determine the request that was made to Amazon CloudSearch, the IP address from which the request was made, who made the request, when it was made, and additional details.

To learn more about CloudTrail, see the [AWS CloudTrail User Guide](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/).

## Amazon CloudSearch Information in CloudTrail
<a name="service-name-info-in-cloudtrail"></a>

CloudTrail is enabled on your AWS account when you create the account. When activity occurs in Amazon CloudSearch, that activity is recorded in a CloudTrail event along with other AWS service events in **Event history**. You can view, search, and download recent events in your AWS account. For more information, see [Viewing Events with CloudTrail Event History](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html).

For an ongoing record of events in your AWS account, including events for Amazon CloudSearch, create a trail. A *trail* enables CloudTrail to deliver log files to an Amazon S3 bucket. By default, when you create a trail in the console, the trail applies to all AWS Regions. The trail logs events from all Regions in the AWS partition and delivers the log files to the Amazon S3 bucket that you specify. Additionally, you can configure other AWS services to further analyze and act upon the event data collected in CloudTrail logs. For more information, see the following:
+ [Overview for Creating a Trail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)
+ [CloudTrail Supported Services and Integrations](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-aws-service-specific-topics.html#cloudtrail-aws-service-specific-topics-integrations)
+ [Configuring Amazon SNS Notifications for CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/getting_notifications_top_level.html)
+ [Receiving CloudTrail Log Files from Multiple Regions](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html) and [Receiving CloudTrail Log Files from Multiple Accounts](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-receive-logs-from-multiple-accounts.html)

All Amazon CloudSearch configuration API actions are logged by CloudTrail and are documented in the [Configuration API Reference for Amazon CloudSearch](configuration-api.md).

Every event or log entry contains information about who generated the request. The identity information helps you determine the following: 
+ Whether the request was made with root or AWS Identity and Access Management (IAM) user credentials.
+ Whether the request was made with temporary security credentials for a role or federated user.
+ Whether the request was made by another AWS service.

For more information, see the [CloudTrail userIdentity Element](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-user-identity.html).

## Understanding Amazon CloudSearch Log File Entries
<a name="understanding-service-name-entries"></a>

A trail is a configuration that enables delivery of events as log files to an Amazon S3 bucket that you specify. CloudTrail log files contain one or more log entries. An event represents a single request from any source and includes information about the requested action, the date and time of the action, request parameters, and so on. CloudTrail log files aren't an ordered stack trace of the public API calls, so they don't appear in any specific order.

The following example shows a CloudTrail log entry that demonstrates the `CreateDomain` action.

```
{
  "eventVersion": "1.05",
  "userIdentity": {
    "type": "IAMUser",
    "principalId": "AIDACKCEVSQ6C2EXAMPLE",
    "arn": "arn:aws:iam::123456789012:user/test-user",
    "accountId": "123456789012",
    "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
    "userName": "test-user",
    "sessionContext": {
      "attributes": {
        "mfaAuthenticated": "false",
        "creationDate": "2018-08-21T23:31:33Z"
      }
    },
    "invokedBy": "signin.amazonaws.com"
  },
  "eventTime": "2018-08-21T23:32:15Z",
  "eventSource": "cloudsearch.amazonaws.com",
  "eventName": "CreateDomain",
  "awsRegion": "us-west-1",
  "sourceIPAddress": "123.123.123.123",
  "userAgent": "signin.amazonaws.com",
  "requestParameters": {
    "domainName": "test-domain"
  },
  "responseElements": {
    "domainStatus": {
      "aRN": "arn:aws:cloudsearch:us-west-1:123456789012:domain/test-domain",
      "searchInstanceCount": 0,
      "docService": {},
      "requiresIndexDocuments": false,
      "deleted": false,
      "searchService": {},
      "domainId": "123456789012/test-domain",
      "processing": false,
      "created": true,
      "searchPartitionCount": 0,
      "domainName": "test-domain"
    }
  },
  "requestID": "12345678-1234-1234-1234-987654321098",
  "eventID": "87654321-4321-4321-4321-987654321098",
  "eventType": "AwsApiCall",
  "recipientAccountId": "123456789012"
}
```

# Tracking your Amazon CloudSearch Usage and Charges
<a name="tracking-usage"></a>

The AWS account activity page enables you to track your Amazon CloudSearch usage and charges.

**To get your Amazon CloudSearch usage information**

1. Go to [aws.amazon.com](http://aws.amazon.com) and choose **My Account**, **Billing & Cost Management**.

1. Choose **Cost & Usage Reports**, then choose **AWS Usage Report**.

1. Choose **Amazon CloudSearch** from the services dropdown.

1. Specify the information that you want to include in the report, then choose the download button for the data format that you want to download. Reports can be downloaded in XML or CSV format.