Get-​Service​Fabric​Replica​Health

Gets the health of a Service Fabric replica.

Syntax

Get-ServiceFabricReplicaHealth
   [-PartitionId] <Guid>
   [-ReplicaOrInstanceId] <Int64>
   [-ConsiderWarningAsError <Boolean>]
   [-EventsFilter <HealthStateFilter>]
   [-EventsHealthStateFilter <Int64>]
   [-TimeoutSec <Int32>]
   [<CommonParameters>]

Description

The Get-ServiceFabricReplicaHealth cmdlet gets the health of a Service Fabric replica. If the replica that you specify does not exist in the health store, this cmdlet returns an exception.

Before you perform any operation on a Service Fabric cluster, establish a connection to the cluster by using the Connect-ServiceFabricCluster cmdlet.

Examples

Example 1: Query the health of a service replica

PS C:\> $ToDoPartition01 = Get-ServiceFabricPartition -ServiceName fabric:/myapp/persistenttodolist/svc1PS
PS C:\> $ToDoPartition01ReplicaList = Get-ServiceFabricReplica -PartitionId $ToDoPartition01.PartitionId
PS C:\> Get-ServiceFabricReplicaHealth -PartitionId $ToDoPartition01.PartitionId -ReplicaOrInstanceId $ToDoPartition01ReplicaList[0].Id

The first command uses the Get-ServiceFabricPartition cmdlet to get a Service Fabric service partition object, and then stores it in the $ToDoPartition01 variable.

The second command gets the list of replicas in the partition, and then stores it in the $ToDoPartition01ReplicaList variable.

The third command gets the health of a service partition replica by using the PartitionID property of the partition object stored in $ToDoPartition01 and the ID of the first replica in $ToDoPartition01ReplicaList.

Example 2: Query the health of a service replica using custom health policy and return filters

PS C:\> $replicaList = Get-ServiceFabricPartition -ServiceName fabric:/myapp/persistenttodolist/svc1PS | Get-ServiceFabricReplica
PS C:\> Get-ServiceFabricReplicaHealth -PartitionId $replicaList[0].PartitionId -ReplicaOrInstanceId $replicaList[0].ReplicaId -ConsiderWarningAsError $True -EventsFilter Error

This example queries the health of the service replica. It specifies values for health policy. It uses filters to return only Error events.

Example 3: Get the health of all replicas of all partitions of all services in an application

PS C:\> Get-ServiceFabricApplication -ApplicationName fabric:/MyApplication | Get-ServiceFabricService | Get-ServiceFabricPartition | Get-ServiceFabricReplica | Get-ServiceFabricReplicaHealth

This example gets the health of all service replicas in the specified application.

Required Parameters

-PartitionId

Specifies the ID of a Service Fabric partition.

Type:Guid
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ReplicaOrInstanceId

Specifies a Service Fabric stateful service replica or stateless service instance ID.

Type:Int64
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-ConsiderWarningAsError

Indicates whether to treat a warning health report as error during health evaluation.

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-EventsFilter

Specifies the filter for the collection of HealthEvent reported on the entity based on health state. The value can be obtained from members or bitwise operations on members of HealthStateFilter. Only events that match the filter are returned. All events are used to evaluate the aggregated health state. If not specified, all entries are returned.

Type:HealthStateFilter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-EventsHealthStateFilter

This parameter has been deprecated. Specify the EventsFilter parameter instead.

Type:Int64
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TimeoutSec

Specifies the time-out period, in seconds, for the operation.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

System.Guid, Int64

This cmdlet accepts the ID or a Service Fabric partition, or a replica or instance ID.

Outputs

System.Object

This cmdlet returns a System.Fabric.Health object that represents the health of a Service Fabric replica.