

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

# Integração AWS Health com outros sistemas usando a API AWS Health
<a name="health-api"></a>

AWS Health é um serviço RESTful web que usa HTTPS como transporte e JSON como formato de serialização de mensagens. O código de seu aplicativo pode fazer solicitações diretamente à API do AWS Health . Quando usar a API REST diretamente, você deverá gravar o código necessário para assinar e autenticar suas solicitações. Para obter mais informações sobre as AWS Health operações e os parâmetros, consulte a [Referência AWS Health da API](https://docs.aws.amazon.com/health/latest/APIReference/).

**nota**  
Você deve ter um plano AWS Business Support\$1, AWS Enterprise Support ou AWS Unified Operations [AWS Support](https://aws.amazon.com/premiumsupport/)para usar a AWS Health API. Se você estiver em um plano Região da AWS que não oferece um desses AWS Support planos, ou se ainda não fez a transição para um desses planos, você pode usar a AWS Health API com um plano Business, Enterprise On-Ramp ou Enterprise Support. Se você chamar a AWS Health API de alguém Conta da AWS que não está inscrito em um desses planos, receberá uma `SubscriptionRequiredException` mensagem de erro.

Você pode usar o AWS SDKs para agrupar as chamadas da API AWS Health REST, o que pode simplificar o desenvolvimento do seu aplicativo. Você especifica suas AWS credenciais, e essas bibliotecas cuidam da autenticação e solicitam a assinatura para você.

AWS Health também fornece um AWS Health painel no Console de gerenciamento da AWS que você pode usar para visualizar e pesquisar eventos e entidades afetadas. Consulte [Começando com seu AWS Health painel](getting-started-health-dashboard.md).

**Topics**
+ [Assinatura AWS Health de solicitações de API](#signing)
+ [Escolha de endpoints para solicitações de AWS Health API](#endpoints)
+ [Demonstrações: Recuperando os últimos sete dias de dados do AWS Health evento de forma programática](using-global-endpoints-demo.md)
+ [Tutorial: Usando a AWS Health API com exemplos de Java](code-sample-java.md)

## Assinatura AWS Health de solicitações de API
<a name="signing"></a>

Quando você usa o AWS SDKs ou o AWS Command Line Interface (AWS CLI) para fazer solicitações AWS, essas ferramentas assinam automaticamente as solicitações para você com a chave de acesso que você especifica ao configurar as ferramentas. Por exemplo, se você usar o AWS SDK para Java para a demonstração anterior de endpoint de alta disponibilidade, não precisará assinar as solicitações sozinho.

**Exemplos de código Java**  
Para ver mais exemplos de como usar a AWS Health API com o AWS SDK para Java, consulte este [código de exemplo](code-sample-java.md).



Ao fazer solicitações, é altamente recomendável que você não use as credenciais AWS da sua conta raiz para AWS Health acesso regular a. Você pode usar as credenciais de um usuário do IAM. Para obter mais informações, consulte [Bloquear as chaves de acesso do usuário raiz da sua AWS conta](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#lock-away-credentials) no *Guia do usuário do IAM*.

Se você não usa o AWS SDKs ou o AWS CLI, então você mesmo deve assinar suas solicitações. Recomendamos que você use o AWS Signature Version 4. Para obter mais informações, consulte [Assinatura de solicitações de AWS API](https://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html) no *Referência geral da AWS*.

## Escolha de endpoints para solicitações de AWS Health API
<a name="endpoints"></a>

A AWS Health API segue uma arquitetura de aplicativo multirregional Arquitetura de e tem dois endpoints regionais em uma configuração ativa-passiva. Para oferecer compatibilidade com o failover de DNS ativo-passivo, AWS Health fornece um endpoint único e global. Você pode realizar uma pesquisa de DNS no endpoint global para determinar o endpoint ativo e a região de assinatura correspondente. AWS Isso ajuda você a saber qual endpoint usar em seu código, para que você possa obter as informações mais recentes. AWS Health

Ao fazer uma solicitação ao endpoint global, você deve especificar suas credenciais de AWS acesso ao endpoint regional de destino e configurar a assinatura para sua região. Caso contrário, sua autenticação poderá falhar. Para obter mais informações, consulte [Assinatura AWS Health de solicitações de API](#signing).

Para solicitações IPv6 somente, recomendamos realizar uma pesquisa de DNS no endpoint global para determinar o endpoint ativo Região da AWS e, em seguida, chamar o endpoint de pilha dupla IPv6 compatível para aquela região.

A tabela a seguir representa a configuração padrão.


****  

| Description | Região de assinatura | Endpoint | Protocolo | 
| --- | --- | --- | --- | 
| Ativo |  us-east-1  |  health.us-east-1.amazonaws.com (IPv4somente) health.us-east-1.api.aws (e suportado) IPv4 IPv6   | HTTPS | 
| Passivo |  us-east-2  |  health.us-east-2.amazonaws.com (IPv4somente) health.us-east-2.api.aws (e suportado) IPv4 IPv6   | HTTPS | 
| Global |  us-east-1  Essa é a região de assinatura do endpoint ativo atual.   |  global.health.amazonaws.com  | HTTPS | 

Para determinar se um endpoint é o *endpoint ativo*, faça uma pesquisa de DNS no CNAME do *endpoint global* e, em seguida, extraia a AWS região do nome resolvido.

**Example : pesquisa de DNS no endpoint global**  
. Em seguida, o comando retorna o endpoint Região us-east-1. Essa saída informa para qual endpoint você deve usar. AWS Health  

```
dig global.health.amazonaws.com | grep CNAME
global.health.amazonaws.com. 10 IN CNAME health.us-east-1.amazonaws.com
```

**dica**  
Tanto os endpoints ativos quanto os passivos retornam AWS Health dados. No entanto, os dados AWS Health mais recentes só estão disponíveis no endpoint ativo. Os dados do endpoint passivo acabarão sendo consistentes com o endpoint ativo. Recomendamos que você reinicie todos os fluxos de trabalho quando o endpoint ativo for alterado.

# Demonstrações: Recuperando os últimos sete dias de dados do AWS Health evento de forma programática
<a name="using-global-endpoints-demo"></a>

Nos exemplos de código a seguir, AWS Health usa uma pesquisa de DNS no endpoint global para determinar o endpoint regional ativo e a região de assinatura. AWS Health usa essas informações para recuperar um relatório dos últimos sete dias de dados do evento. O código reinicia o fluxo de trabalho se o endpoint ativo mudar. 

**Topics**
+ [Demonstração: recuperando os últimos sete dias de dados do AWS Health evento usando Java](#using-the-java-sample-code)
+ [Demonstração: recuperando os últimos sete dias de dados do AWS Health evento usando Python](#using-the-python-code)

## Demonstração: recuperando os últimos sete dias de dados do AWS Health evento usando Java
<a name="using-the-java-sample-code"></a>

**Pré-requisito**  
Você deve instalar o [Gradle.](https://docs.gradle.org/current/userguide/installation.html)

**Para usar o exemplo Java**

1. Baixe a [demonstração do endpoint de AWS Health alta disponibilidade](https://github.com/aws/aws-health-tools/tree/master/high-availability-endpoint) em. GitHub

1. Navegue até o diretório de projeto do `high-availability-endpoint/java`.

1. Em uma janela de linha de comando, digite o seguinte comando:

   ```
   gradle build
   ```

1. Insira os comandos a seguir para especificar suas AWS credenciais.

   ```
   export AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE"
   export AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
   export AWS_SESSION_TOKEN="your-aws-token"
   ```

1. Insira o comando a seguir para executar a ferramenta .

   ```
   gradle run
   ```  
**Example : saída AWS Health do evento**  

   O exemplo de código retorna o AWS Health evento recente dos últimos sete dias em sua AWS conta. No exemplo a seguir, a saída inclui um AWS Health evento para o AWS Config serviço.

   ```
   > Task :run
   [main] INFO aws.health.high.availability.endpoint.demo.HighAvailabilityV2Workflow - EventDetails(Event=Event(Arn=arn:aws:health:global::event/CONFIG/AWS_CONFIG_OPERATIONAL_NOTIFICATION/AWS_CONFIG_OPERATIONAL_NOTIFICATION_88a43e8a-e419-4ca7-9baa-56bcde4dba3, 
   Service=CONFIG, EventTypeCode=AWS_CONFIG_OPERATIONAL_NOTIFICATION, EventTypeCategory=accountNotification, Region=global, StartTime=2020-09-11T02:55:49.899Z, LastUpdatedTime=2020-09-11T03:46:31.764Z, 
   StatusCode=open, EventScopeCode=ACCOUNT_SPECIFIC), EventDescription=EventDescription(LatestDescription=As part of our ongoing efforts to optimize costs associated with recording changes related to certain ephemeral workloads,
   AWS Config is scheduled to release an update to relationships modeled within ConfigurationItems (CI) for 7 EC2 resource types on August 1, 2021. 
   Examples of ephemeral workloads include changes to Amazon Elastic Compute Cloud (Amazon EC2) Spot Instances, Amazon Elastic MapReduce jobs, and Amazon EC2 Autoscaling. 
   This update will optimize CI models for EC2 Instance, SecurityGroup, Network Interface, Subnet, VPC, VPN Gateway, and Customer Gateway resource types to record direct relationships and deprecate indirect relationships.
    
   A direct relationship is defined as a one-way relationship (A->B) between a resource (A) and another resource (B), and is typically derived from the Describe API response of resource (A). 
   An indirect relationship, on the other hand, is a relationship that AWS Config infers (B->A), in order to create a bidirectional relationship. 
   For example, EC2 instance -> Security Group is a direct relationship, since security groups are returned as part of the describe API response for an EC2 instance. 
   But Security Group -> EC2 instance is an indirect relationship, since EC2 instances are not returned when describing an EC2 Security group.
    
   Until now, AWS Config has recorded both direct and indirect relationships. With the launch of Advanced queries in March 2019, indirect relationships can easily be answered by running Structured Query Language (SQL) queries such as:
    
   SELECT
    resourceId,
    resourceType
   WHERE
    resourceType ='AWS::EC2::Instance'
   AND
    relationships.resourceId = 'sg-234213'
    
   By deprecating indirect relationships, we can optimize the information contained within a
   Configuration Item while reducing AWS Config costs related to relationship changes. 
   This is especially useful in case of ephemeral workloads where there is a high volume of configuration changes for EC2 resource types.
    
   Which resource relationships are being removed?
    
   Resource Type: Related Resource Type
   1 AWS::EC2::CustomerGateway: AWS::VPN::Connection
   2 AWS::EC2::Instance: AWS::EC2::EIP, AWS::EC2::RouteTable
   3 AWS::EC2::NetworkInterface: AWS::EC2::EIP, AWS::EC2::RouteTable
   4 AWS::EC2::SecurityGroup: AWS::EC2::Instance, AWS::EC2::NetworkInterface
   5 AWS::EC2::Subnet: AWS::EC2::Instance, AWS::EC2::NetworkACL, AWS::EC2::NetworkInterface, AWS::EC2::RouteTable
   6 AWS::EC2::VPC: AWS::EC2::Instance, AWS::EC2::InternetGateway, AWS::EC2::NetworkACL, AWS::EC2::NetworkInterface, AWS::EC2::RouteTable, AWS::EC2::Subnet, AWS::EC2::VPNGateway, AWS::EC2::SecurityGroup
   7 AWS::EC2::VPNGateway: AWS::EC2::RouteTable, AWS::EC2::VPNConnection
    
   Alternate mechanism to retrieve this relationship information:
   The SelectResourceConfig API accepts a SQL SELECT command, performs the corresponding search, and returns resource configurations matching the properties. You can use this API to retrieve the same relationship information. 
   For example, to retrieve the list of all EC2 Instances related to a particular VPC vpc-1234abc, you can use the following query:
    
   SELECT
    resourceId,
    resourceType
   WHERE
    resourceType ='AWS::EC2::Instance'
   AND
    relationships.resourceId = 'vpc-1234abc'
    
   If you have any questions regarding this deprecation plan, please contact AWS Support [1]. Additional sample queries to retrieve the relationship information for the resources listed above is provided in [2].
    
   [1] https://aws.amazon.com/support
   [2] https://docs.aws.amazon.com/config/latest/developerguide/examplerelationshipqueries.html),
   EventMetadata={})
   ```

### Recursos de Java
<a name="resources-for-the-java-code"></a>
+ Para obter mais informações, consulte a [Interface HealthClient](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/health/HealthClient.html) na *Referência da AWS SDK para Java API* e o [código-fonte](https://repo1.maven.org/maven2/software/amazon/awssdk/health/2.14.2/).
+ Para obter mais informações sobre a biblioteca usada nesta demonstração para pesquisas de DNS, consulte [dnsjava](https://github.com/dnsjava/dnsjava) em. GitHub

## Demonstração: recuperando os últimos sete dias de dados do AWS Health evento usando Python
<a name="using-the-python-code"></a>

**Pré-requisito**  
Você deve instalar o [Python 3](https://www.python.org/downloads/).

**Para usar o exemplo do Python**

1. Baixe a [demonstração do endpoint de AWS Health alta disponibilidade](https://github.com/aws/aws-health-tools/tree/master/high-availability-endpoint) em. GitHub

1. Navegue até o diretório de projeto do `high-availability-endpoint/python`.

1. Em uma janela de linha de comando, digite o seguinte comando:

   ```
   pip3 install virtualenv 
   virtualenv -p python3 v-aws-health-env
   ```
**nota**  
Para Python 3.3 e mais recente, você pode usar o módulo `venv` integrado para criar um ambiente virtual, em vez de instalar o `virtualenv`. Para obter mais informações, consulte [venv: criação de ambientes virtuais](https://docs.python.org/3/library/venv.html) no site da Python.  

   ```
   python3 -m venv v-aws-health-env
   ```

1. Insira o seguinte comando para ativar o ambiente virtual:

   ```
   source v-aws-health-env/bin/activate
   ```

1. Execute o seguinte comando para instalar as dependências.

   ```
   pip install -r requirements.txt
   ```

1. Insira os comandos a seguir para especificar suas AWS credenciais.

   ```
   export AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE"
   export AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
   export AWS_SESSION_TOKEN="your-aws-token"
   ```

1. Insira o comando a seguir para executar a ferramenta .

   ```
   python3 main.py
   ```  
**Example : saída AWS Health do evento**  

   O exemplo de código retorna o AWS Health evento recente dos últimos sete dias em sua AWS conta. A saída a seguir retorna um AWS Health evento para uma notificação AWS de segurança.

   ```
   INFO:botocore.credentials:Found credentials in environment variables.
   INFO:root:Details: {'arn': 'arn:aws:health:global::event/SECURITY/AWS_SECURITY_NOTIFICATION/AWS_SECURITY_NOTIFICATION_0e35e47e-2247-47c4-a9a5-876544042721', 
   'service': 'SECURITY', 'eventTypeCode': 'AWS_SECURITY_NOTIFICATION', 'eventTypeCategory': 'accountNotification', 'region': 'global', 'startTime': datetime.datetime(2020, 8, 19, 23, 30, 42, 476000, 
   tzinfo=tzlocal()), 'lastUpdatedTime': datetime.datetime(2020, 8, 20, 20, 44, 9, 547000, tzinfo=tzlocal()), 'statusCode': 'open', 'eventScopeCode': 'PUBLIC'}, description: 
   {'latestDescription': 'This is the second notice regarding TLS requirements on FIPS endpoints.\n\nWe
   are in the process of updating all AWS Federal Information Processing Standard (FIPS) endpoints across all AWS regions 
   to Transport Layer Security (TLS) version 1.2 by March 31, 2021 . In order to avoid an interruption in service, we encourage you to act now, by ensuring that you connect to AWS FIPS endpoints at a TLS version of 1.2. 
   If your client applications fail to support TLS 1.2 it will result in connection failures when TLS versions below 1.2 are no longer supported.\n\nBetween now and March 31, 2021 AWS will remove TLS 1.0 and TLS 1.1 support from each FIPS endpoint where no connections below TLS 1.2 are detected over a 30-day period. 
   After March 31, 2021 we may deploy this change to all AWS FIPS endpoints, even if there continue
   to be customer connections detected at TLS versions below 1.2. \n\nWe will provide additional updates and reminders on the AWS Security Blog, with a ‘TLS’ tag [1]. If you need further guidance or assistance, please contact AWS Support [2] or your Technical Account Manager (TAM). 
   Additional information is below.\n\nHow can I identify clients that are connecting with TLS
   1.0/1.1?\nFor customers using S3 [3], Cloudfront [4] or Application Load Balancer [5] you can use
   your access logs to view the TLS connection information for these services, and identify client
   connections that are not at TLS 1.2. If you are using the AWS Developer Tools on your clients, 
   you can find information on how to properly configure your client’s TLS versions by visiting Tools to Build on AWS [7] or our associated AWS Security Blog has a link for each unique code language [7].\n\nWhat is Transport Layer Security (TLS)?\nTransport Layer Security (TLS Protocols) are cryptographic protocols designed to provide secure communication across a computer network 
   [6].\n\nWhat are AWS FIPS endpoints? \nAll AWS services offer Transport Layer Security (TLS) 1.2 encrypted endpoints that can be used for all API calls. Some AWS services also offer FIPS 140-2 endpoints [9] for customers that require use of FIPS validated cryptographic libraries. \n\n[1] https://aws.amazon.com/blogs/security/tag/tls/\n[2] https://aws.amazon.com/support\n[3] 
   https://docs.aws.amazon.com/AmazonS3/latest/dev/LogFormat.html\n[4] https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html\n[5] https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html\n[6] https://aws.amazon.com/tools\n[7] https://aws.amazon.com/blogs/security/tls-1-2-to-become-the-minimum-for-all-aws-fips-endpoints\n[8] 
   https://en.wikipedia.org/wiki/Transport_Layer_Security\n[9] https://aws.amazon.com/compliance/fips'}
   ```

1. Ao terminar, insira o comando a seguir para desativar a máquina virtual.

   ```
   deactivate
   ```

### Recursos Python
<a name="resources-for-python-code-example"></a>
+ Para mais informações sobre a `Health. Client`, consulte a [AWS SDK para Referência API Python (Boto3) ](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/health.html#Health.Client).
+ [Para obter mais informações sobre a biblioteca usada nesta demonstração para pesquisas de DNS, consulte o kit de ferramentas [dnspython](https://dnspython.readthedocs.io/en/stable/) e o código-fonte em.](https://github.com/rthalley/dnspython/) GitHub

# Tutorial: Usando a AWS Health API com exemplos de Java
<a name="code-sample-java"></a>

Os exemplos de código Java a seguir demonstram como inicializar um AWS Health cliente e recuperar informações sobre eventos e entidades.

## Etapa 1: Inicialize as credenciais
<a name="step-1"></a>

São necessárias credenciais válidas para se comunicar com a AWS Health API. Você pode usar o par de chaves de qualquer usuário do IAM associado à AWS conta.

Crie e inicialize uma [AWSCredentials](https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/AWSCredentials.html)instância:

```
AWSCredentials credentials = null;
try {
       credentials = new ProfileCredentialsProvider("default").getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
   "Cannot load the credentials from the credential profiles file. "
   + "Please make sure that your credentials file is at the correct "
   + "location (/home/username/.aws/credentials), and is in valid format.", e);
}
```

## Etapa 2: inicializar um cliente de AWS Health API
<a name="step-2"></a>

Use o objeto de credenciais de inicialização da etapa anterior para criar um cliente do AWS Health :

```
import com.amazonaws.services.health.AWSHealthClient;

AWSHealth awsHealthClient = new AWSHealthClient(credentials);
```

## Etapa 3: usar operações de AWS Health API para obter informações do evento
<a name="step-3"></a>

**DescribeEvents**

```
import com.amazonaws.services.health.model.DescribeEventsRequest;
import com.amazonaws.services.health.model.DescribeEventsResult;
import com.amazonaws.services.health.model.Event;
import com.amazonaws.services.health.model.EventFilter;

DescribeEventsRequest request = new DescribeEventsRequest();

EventFilter filter = new EventFilter();
// Filter on any field from the supported AWS Health EventFilter model. 
// Here is an example for Region us-east-1 events from the EC2 service.
filter.setServices(singletonList("EC2"));
filter.setRegions(singletonList("us-east-1"));
request.setFilter(filter);

DescribeEventsResult response = awsHealthClient.describeEvents(request);
List<Event> resultEvents = response.getEvents();

Event currentEvent = null;
for (Event event : resultEvents) {
    // Display result event data; here is a subset.
    System.out.println(event.getArn());
    System.out.println(event.getService());
    System.out.println(event.getRegion());
    System.out.println(event.getAvailabilityZone());
    System.out.println(event.getStartTime());
    System.out.println(event.getEndTime());
 }
```

**DescribeEventAggregates**

```
import com.amazonaws.services.health.model.DescribeEventAggregatesRequest;
import com.amazonaws.services.health.model.DescribeEventAggregatesResult;
import com.amazonaws.services.health.model.EventAggregate;
import com.amazonaws.services.health.model.EventFilter;

DescribeEventAggregatesRequest request = new DescribeEventAggregatesRequest();
// set the aggregation field
request.setAggregateField("eventTypeCategory");

// filter more on result if needed
EventFilter filter = new EventFilter();
filter.setRegions(singleton("us-east-1"));
request.setFilter(filter);

DescribeEventAggregatesResult response = awsHealthClient.describeEventAggregates(request);

// print event count for each eventTypeCategory
for (EventAggregate aggregate: response.getEventAggregates()) {
    System.out.println("Event Category:" + aggregate.getAggregateValue());
    System.out.println("Event Count:" + aggregate.getCount());
 }
```

**DescribeEventDetails**

```
import com.amazonaws.services.health.model.DescribeEventDetailsRequest;
import com.amazonaws.services.health.model.DescribeEventDetailsResult;
import com.amazonaws.services.health.model.Event;
import com.amazonaws.services.health.model.EventDetails;


DescribeEventDetailsRequest describeEventDetailsRequest = new DescribeEventDetailsRequest();
// set event ARN and local value

describeEventDetailsRequest.setEventArns(singletonList("arn:aws:health:us-east-1::event/service/eventTypeCode/eventId"));
describeEventDetailsRequest.setLocale("en-US");
filter.setEventArns
DescribeEventDetailsResult describeEventDetailsResult = awsHealthClient.describeEventDetails(request);
EventDetails eventDetail = describeEventDetailsResult.getSuccessfulSet().get(0);

// check event-related fields
Event event = eventDetail.getEvent();
System.out.println(event.getService());
System.out.println(event.getRegion());
System.out.println(event.getAvailabilityZone());
System.out.println(event.getStartTime());
System.out.println(event.getEndTime());

// print out event description
System.out.println(eventDetail.getEventDescription().getLatestDescription());
```

**DescribeAffectedEntities**

```
import com.amazonaws.services.health.model.AffectedEntity;
import com.amazonaws.services.health.model.DateTimeRange;
import com.amazonaws.services.health.model.DescribeAffectedEntitiesRequest;
import com.amdescribeEventDetailsRequestazonaws.services.health.model.DescribeAffectedEntitiesResult;

DescribeAffectedEntitiesRequest request = new DescribeAffectedEntitiesRequest();
EntityFilter filter = new EntityFilter();

filter.setEventArns(singletonList("arn:aws:health:us-east-1::event/service/eventTypeCode/eventId"));

DescribeAffectedEntitiesResult response = awsHealthClient.describeAffectedEntities(request);

for (AffectedEntity affectedEntity: response.getEntities()) {
    System.out.println(affectedEntity.getEntityValue());
    System.out.println(affectedEntity.getAwsAccountId());
    System.out.println(affectedEntity.getEntityArn());
 }
```

**DescribeEntityAggregates**

```
import com.amazonaws.services.health.model.DescribeEntityAggregatesRequest;
import com.amazonaws.services.health.model.DescribeEntityAggregatesResult;
import com.amazonaws.services.health.model.EntityAggregate;

DescribeEntityAggregatesRequest request = new DescribeEntityAggregatesRequest();

request.setEventArns(singletonList("arn:aws:health:us-east-1::event/service/eventTypeCode/eventId"));

DescribeEntityAggregatesResult response = awsHealthClient.describeEntityAggregates(request);

for (EntityAggregate entityAggregate : response.getEntityAggregates()) {
    System.out.println(entityAggregate.getEventArn());
    System.out.println(entityAggregate.getCount());
 }
```