Monitor the AF Health Check counter
- Last UpdatedDec 11, 2025
- 2 minute read
The AF Health Check counter is a Windows Performance Monitor (perfmon) that allows you to determine if the PI AF application service and the SQL Server are running and responsive. This allows you to monitor the health of the connection between the AF Server and the SQL Server that hosts the PI AF database (PIFD). When both are responsive, the counter returns a value of 1.
You can access this information using one of the following methods:
-
Any tool that reads Windows performance counters, such as the Windows Performance Monitor (see Monitor PI AF Server and SQL Server communication).
-
Using the PI Interface for Performance Monitor to store the historical values of this counter in a PI tag. The interface can be installed on any machine and configured to remotely capture performance counter values. See Configure the Windows Service. Once the counter is historized in the PI System, alerts can be configured using PI Notifications.
-
Through a Web page that displays the current status of the AF Health Check counter. This approach is useful for an AF Network Load Balancer that does not read performance counters directly, but instead uses a Web page to display them.
Create a Web page to display the status of the AF Health Check counter
The following steps explain how to create a Web page that displays the value of the AF Health Check counter.
Note: This procedure requires the Windows Performance Monitor (perfmon) utility. It does not require the PI Performance Monitor interface.
-
Install Internet Information Services (IIS) on the AF server.
-
Install the ASP.NET 4.x feature.
-
Create a text file in the following directory: C:\inetpub\wwwroot\
-
Copy and paste the code from the code example below into a text editor, then save the file as <filename>.aspx.
-
In IIS Manager, find the DefaultAppPool identity, then add this account to the local Performance Monitor Users group.
-
(Optional) Change the AppPool identity to an account that has access to performance counters.
-
Under Default Web Site, select Default Document, then select Add and add the <filename>.aspx file created in step 4.
Note: This setting can be configured on a non-default Web site.
-
Restart the default Web site.
-
Browse to the default Web site and confirm that the AF health status value appears.
Code example: Display the value of the perfmon counter
The following code example shows how to display the AF health status value on a Web page.
<%@ Import Namespace = "System.Diagnostics" %>
<script runat="server">
sub Page_Load(sender as Object, e as EventArgs)
Dim perfAFHealth as New PerformanceCounter("PI AF Server", "Health")
If perfAFHealth.NextValue() = 0
lblperfAFHealth.Text = "DOWN"
ElseIf perfAFHealth.NextValue() = 1
lblperfAFHealth.Text = "UP"
Else lblperfAFHealth.Text = "INVALID"
End If
end sub
</script>
<!DOCTYPE html>
<html>
<head>
<title>AF Health Check</title>
<meta http-equiv="refresh" content="5" />
</head>
<body>
<form id="Form1" runat="server">
AF Health Status :
<asp:Label id="lblperfAFHealth" runat="server" />
</form>
</body>
</html>