Lync KHI Performance Data collection and analysis


Key Health Indicators are performance counters with thresholds aimed at revealing user experience issues.

Typically we look at performance data when we are seeing Voice Quality issues or Performance issues (slowness/call drops & etc) to identify what’s causing Performance bottleneck

These KHIs are used in addition to standard Lync Monitoring Solutions (e.g. System Center Operations Manager, Synthetic Transactions, Monitoring Server) and not instead of those solutions.

Overall process is straight forward:

  1. Collect the KHI performance counters.
  2. Populate the Average and Maximum values in KHI spreadsheet.
  3. Analyze the same and compare with thresholds to identify what’s causing performance bottleneck.

My Suggestion to Lync administrators is to run through this monthly once to identify if there are any performance related issues and tackle them proactively or reactively in case of an incidents.

Steps to collect KHI Data

  1. Download KHI Collection Script “Create_KHI_Collection” from Lync2010 Networking Guide  or Lync2013/SFB KHI : (downloaded files might be blocked, need to unblock them before using).
  2. We have different KHI Collection Script for different version of Lync Server (2010/2013).

  1. Copy the “Create_KHI_Collection” file to each front end server where we want to collect the performance data and run this script using windows PowerShell (launched with administrator rights); Depending on the Server version, we need to provide ‘-Version LyncServer2010 / LyncServer2013 / Skype4B’ switch


  1. This will create a user defined data collector set named “KHI”. Start -> run -> perfmon -> Performance -> Data Collector sets -> User Defined (you will see data collector set created)

  1. This Data Collector set contain a list of all Performance Counters that are required for Lync Server performance analysis. (to view list of counters : KHI -> properties -> performance counters)

  1. In order to run the KHI collector set, right click on KHI and choose Start.

Please note: This Data Collector should be started before the company business start and should be stopped at the end of that business day (approx. 8 hours).

  1. Once the data collector is started, it will generate a CSV file under the C:\PerfLogs folder. This CSV file will contain all counters data and it will update the file every 15 seconds by default.

  1. At the end of business day go ahead and stop the data collector set, right click on KHI and choose Stop:

  1. Once completed we will have set of KHI performance data files stored in “C:\perflogs” location on respective Lync Servers.

Analyzing KHI Data:

Method 1: (Using KHI Importer)

We can make use of KHI Importer to automatically generate the output files after comparing the KHI Data with the threshold values.

  1. Download KHI Importer tool from here (KHI Importer is basically a Script that we use to read the KHI output data and fill the respective values in KHI threshold file)
  2. We will have 2 files ‘import_khi_data’ Script that we will run against the perf data collected (Lync KHI data) and ‘files.csv’ file (where you specify the filenames of the KHI Data)

  1. Copy the KHI Importer files, Threshold file (here) and the KHI File (performance data that we collected from Lync Server) to some common location

  1. Open files.csv and add the filenames of the KHI Perf data that we collected earlier from Lync server.

  1. Here, you need to add all the KHI output filenames that you got as shown above, ServerType can be set to one of below, based on what data we would like to get analyzed.

1        Lync Front-End Server

2        Lync Mediation Server

4        Lync Front-End Server collocated with meditation server

8        Lync Edge Server

16      SQL Back-End Server

  1. Run below command from Windows Powershell (launched with administrator rights) to initiate the process of importing the Output files and its analysis.

Import_khi_data.ps1 –CSVFile files.csv –KHIFile Lync_Server_2013_Key_Health_Indicators.xlsx –SingleServer

In the above command;

CSVFile                 files.csv (where we added the filenames of all the KHI Datafiles)

KHIFile                  Threshold file (downloaded earlier in Lync Networking Guide)

SingleServer          Optional Switch if we are running against Std edition Server

  1. The above mentioned script will run for a while, during the process, all that it does is below:
    • Read the filename present in files.csv
    • Read the Average and Maximum values for each counters (which all counters depends on what ServerType was selected)
    • Fill these Average and Maximum values against the threshold values in the KHI Threshold file.
    • Once completed, you will see output similar to this in the KHI threshold file.

Method 2: (Using KHI Summarizer)

We can make use of KHI summarizer to get the Average and Maximum values for each of performance counters using the performance data that was collected earlier, to do that perform below steps:

  1. Download KHI Summarizer, It includes a CSV File that has inbuilt Macros Written
  2. Copy the KHI Output files to location ‘d:\temp\khi’ (because this summarizer tool is designed to look for KHI File in this location)

  1. Ensure that you have Enabled Macros in Excel to run this tool (if Macros isn’t enabled you would get warning that Macros is disabled, we can enable the same)

  1. Click “summarize KHI CSVs” to import and process KHI data in a separate Sheet


  1. We will get the output with summary of each counters and its average and its maximum value, as shown below:

  1. Save this file over to different location for further comparison with Lync threshold file “Lync_Server_2013_Key_Health_Indicators.xslx” which is available in Lync networking guide (Lync2010 Networking Guide or Lync2013/SFB KHI ).

7.  Fill in the Average and Maximum values for Each counters in Lync Threshold file (by looking at the maximum and average values that we got summarizer output file).

There are different sheets specifying different performance counters that refers to specific services (like, FE, Edge, Mediation, System…etc), we need to identify where are we have Red (High Alerts) and take corrective actions to fix the same.

PS: you can also view these data manually and compare values with threshold, the above mentioned steps would simply and ease the analyzing process.


Pragathi Raj S

Premier Field Engineer – Microsoft

Comments (9)

  1. Prashant says:

    awesome post

  2. bharat says:

    Great Post

  3. Joel says:

    This website will also allow you to upload KHI files for processing.

  4. Swaathi says:

    Thank you so much Raj 🙂

  5. Jeff McBride says:

    For the common error I had and see other hads, this was corrected for me when specifying the exact location within the command. For example, It was successful when I ran:

    .Import_KHI_data.ps1 -CSVFile "C:Direct Pathfiles.csv" -KHIFile "C:Direct PathLync_Server_2013_Key_Health_Indicators.xlsx" -SingleServer

    However, it failed when I ran the following even though PS was in the same folder as the called files;

    .Import_KHI_data.ps1 -CSVFile ".files.csv" -KHIFile ".Lync_Server_2013_Key_Health_Indicators.xlsx" -SingleServer

  6. Many thanks for this useful tool. The script however does not work for me, and hit the following exception

    "You cannot call a method on a null-valued expression."

    and a lot of them. Do the headers in the KHI output files need to be of a specific format? Could you help with this issue please?


  7. jude says:

    Excellent step by step article Raj. I will be using this blog to share with our customers!

  8. Pragathi Raj says:


    May I know what’s the exact command you are running ? (Ensure to Unblock the Script before running)

    If we supply incorrect files for CSVFile and KHIFile parameter in the commmand is when we would get such Error:

    You cannot call a method on a null-valued expression.
    At C:usersprajdesktopkhiimport_khi_data.ps1:675 char:2
    + $objExcel.ActiveWorkBook.Save()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Ensure you supply below command with right file as input:

    Import_khi_data.ps1 –CSVFile files.csv –KHIFile Lync_Server_2013_Key_Health_Indicators.xlsx

    KHIFile "Lync_Server_2013_Key_Health_Indicators.xlsx" for KHIFile Parameter
    CSVFile files.csv
    Files.csv Should contain list of all the KHI CSV files


Skip to main content