Monitor NCache Using Prometheus
Monitoring NCache with Prometheus enables you to track real-time performance metrics for Distributed Caches, Pub/Sub Message Stores, Clients, and Bridges. NCache publishes extensive performance counters that allow you to monitor cache status, resource utilization, and other statistics through a centralized monitoring platform.
Prometheus is an open-source monitoring tool that collects and stores metrics in a time-series database using an HTTP-based pull model. It supports flexible queries, performance visualization, and real-time alerting. NCache integrates with Prometheus by exposing performance counters through an HTTP endpoint.
The NCache Service exposes an HTTP endpoint on port 9804, allowing users to retrieve the latest available metrics through HTTP GET requests. The following endpoints are available:
/metrics: Returns performance metrics in Prometheus-compatible format for monitoring and querying./metrics/json: Returns the latest available metrics in JSON format for troubleshooting, scripting, and integration with other monitoring tools.
The performance counters published by NCache are controlled through the monitoring.ncconf configuration file, which allows you to specify which counters are available for monitoring.
How Prometheus Monitoring Works with NCache
NCache integrates with Prometheus to provide a centralized way of monitoring cache performance across servers, clients, and Bridges. Instead of requiring users to monitor each component separately, Prometheus collects the performance metrics published by NCache and makes them available for querying, visualization, and analysis.
NCache uses a pull-based monitoring approach, where the NCache Service collects performance counters from the relevant NCache components and makes them available through an HTTP endpoint. Prometheus periodically requests these metrics from the NCache Service, rather than requiring NCache to send them directly to Prometheus.
The monitoring process works as follows:
NCache Collects Performance Counters: NCache components, including cache servers, clients, and Bridges, generate performance counters during their operations. These counters provide information about cache activity, memory usage, requests per second, and other performance statistics. The collected metrics are published to the NCache Service, where they are made available for monitoring.
NCache Exposes Metrics Through HTTP: The NCache Service makes the collected metrics available through an HTTP endpoint on port
9804. The/metricsendpoint provides metrics in a Prometheus-compatible format, while/metrics/jsonprovides the latest available metrics in JSON format. The monitoring.ncconf file determines which performance counters are published.Prometheus Retrieves Metrics: Prometheus uses the targets configured in its prometheus.yml file to identify the NCache servers it needs to monitor. At regular intervals, Prometheus sends an HTTP GET request to each target's
/metricsendpoint and retrieves the currently available metrics. This process is known as scraping. The frequency of these requests is controlled by thescrape_intervalsetting.Prometheus Stores the Collected Metrics: After retrieving the metrics, Prometheus stores them in its time-series database along with timestamps and identifying labels. This allows users to track changes in cache performance over time and compare metrics across different NCache servers.
Users Monitor and Analyze Performance: Users can access the Prometheus web interface to query the collected metrics using PromQL (Prometheus Query Language). These queries can be used to view individual performance counters, generate graphs, compare cache activity, and identify performance trends. Prometheus also supports alerting based on defined conditions.
With this approach, NCache handles the collection and publishing of performance counters, while Prometheus handles their retrieval, storage, and analysis. This allows multiple NCache servers and components to be monitored through a single Prometheus instance without requiring NCache to push metrics directly to Prometheus as you can see below.

How to Configure NCache Prometheus Monitoring
To configure monitoring using Prometheus, follow these steps:
Step 1: Enable Metrics in NCache Service Settings
The Alachisoft.NCache.Service.dll.config config file shipped at %NCHOME%\bin\service allows you to enable/disable monitoring of your caches on Prometheus through configurable tags. These tags are:
<add key="NCacheServer.EnableMetricsPublishing" value="true"/>
<add key="NCacheServer.EnablePrometheusMonitoring" value="true"/>
Important
You must reflect your changes across all the NCache service config files of NCache servers and clients.
Set
NCacheServer.EnableMetricsPublishingtag as True: TheNCacheServer.EnableMetricsPublishingtag enables metrics publishing to NCache service. This tag is False by default.Set
NCacheServer.EnablePrometheusMonitoringtag as True: TheNCacheServer.EnablePrometheusMonitoringtag enables monitoring stats on the Prometheus agent. This tag is False by default.Save Changes: Save the config file and restart the NCache service and NCache Bridge service, cache host process, and client application(s) on all client and server machines for the changes to take effect.
Optional System Counter Settings
You can also make the following additional configurations in the NCache service configuration file:
<add key="NCacheServer.EnableSystemCountersMonitoring" value="true"/>
- Set
NCacheServer.EnableSystemCountersMonitoringtag as True: TheNCacheServer.EnableSystemCountersMonitoringtag enables or disables the monitoring of system counters. This tag is set to False by default.
Note
To monitor NCache client Performance Counters through Prometheus, NCache must be installed on your client machines.
- Save the config file and restart the NCache Service (NCacheSvc and NBridgeSvc, as well, if that is the dashboard you are interested in) using the Task Manager.
Step 2: Configure Prometheus Config File
The second step of monitoring NCache counters using Prometheus is to configure the prometheus.yml file that is shipped with the Prometheus server.
- Download and extract Prometheus on your machine.
Note
You can install Prometheus on a separate machine, the client machine, or the NCache server and only a single Prometheus server is enough to monitor all your environments.
Open the prometheus.yml file in an editor.
Set the
scrape_intervalper your requirement. This interval is the time after which the Prometheus server pulls metrics from the Prometheus agent. The default value of this tag is 1 minute.Set the
job_nameto a value containing the keyword "ncache-metrics" to distinguish multiple targets.Set your agent's address as the
targetsvalue. The port should be the same as the one mentioned in theAlachisoft.NCache.Service.dll.configfile. Your changes will look like this:
scrape_configs:
- job_name: 'ncache-metrics'
static_configs:
- targets:
- '20.200.20.11:9804'
- '20.200.20.12:9804'
- Save the .yml file.
Step 3: Run the Prometheus Application for Cache Monitoring
Important
Update the prometheus.yml file before running the server. In case the Prometheus server was already running when you updated the yml file, you need to restart the Prometheus server. Any change in the prometheus.yml file requires you to restart the Prometheus server.
Go to the folder where you extracted the Prometheus setup and run prometheus.exe. If you see the "Server is ready to receive web requests." message on the command prompt, it means your Prometheus server is ready to make calls to your Prometheus agent.
Open a web browser of your choice and add the IP of the node where you want the Prometheus server to run along with the default Prometheus server port, i.e., 9090 in the address bar of the browser. For example, if I want the Prometheus server to run on IP 20.200.20.11, I would request for 20.200.20.11:9090 in the address bar.
- This will open the Prometheus server on your machine.

- In the search bar, search for the counter you want to monitor. This will fetch all instances of that counter from all targets specified in the config file. Go to NCache Counters to see all server, client, Bridge, and Bridge cache counters supported in NCache.

Note
If the counter you want to monitor is not listed among the counters shown on Prometheus, it is most likely that its publishing has been turned off by default. To enable publishing of the counters that you want to monitor, you can use the monitoring.ncconf file shipped with NCache at %NCHOME%\config\ for Windows and /opt/ncache/config for Linux. Refer to Monitoring Config to understand how to configure this file according to your requirements. Please note that only the counters whose publishing has been set to true will be published on the Prometheus agent and server. After this configuration, restart the Caches, Client, and Bridges otherwise your changes won't be reflected.
- You can add panels to view multiple counters at the same time as follows:

Troubleshooting
In case you encounter any issue with the Prometheus agent, go to MetricServer logs found at %NCHOME%\log-files.
See Also
Monitor NCache using Windows PerfMon Tool
Monitor Caches using the NCache Management Center
Monitor Caches using the NCache Monitor
Logging