Monitor NCache Using Prometheus
This feature is only available in NCache Enterprise Edition
NCache offers multiple ways to monitor your cache clusters. You can monitor Distributed Caches, Distributed Cache with Persistence, the Pub/Sub Message Store, Distributed Lucene, Clients and Bridges through the extensive counters published by NCache. These counters allow you to monitor individual cache status and other statistics of your cache on a single platform.
Prometheus is an open source tool that allows you to monitor your systems. It records real-time metrics in a time series database built using a HTTPS pull model, with flexible queries and real-time alerting. NCache provides support for monitoring its performance counters through Prometheus.
Enable Prometheus Monitoring
To configure monitoring using Prometheus, follow these steps:
Step 1: Configure NCache Service Config
The Alachisoft.NCache.Service.exe.config (.NET Framework)/Alachisoft.NCache.Service.dll.config (.NET) config file shipped at %NCHOME%\bin\service allows you to enable/disable monitoring of your caches on Prometheus through configurable tags. These tags are:
You must reflect your changes across all the NCache service config files of NCache servers and clients.
<add key="NCacheServer.EnableMetricsPublishing" value="true"/> <add key="NCacheServer.EnablePrometheusMonitoring" value="true"/>
NCacheServer.EnableMetricsPublishingtag as True: The
NCacheServer.EnableMetricsPublishingtag enables metrics publishing to NCache service. This tag is False by default.
NCacheServer.EnablePrometheusMonitoringtag as True: The
NCacheServer.EnablePrometheusMonitoringtag enables monitoring stats on 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.
You can also make the following additional configurations in the NCache service configuration file:
<add key="NCacheServer.MetricServerPort" value="8255"/> <add key="NCacheServer.EnableSystemCountersMonitoring" value="true"/>
NCacheServer.MetricsServerPorttag configures the port where the prometheus-agent runs. By default, the port is
8255but you can configure it as per your need.
If you decide to change the
NCacheServer.MetricServerPort in the NCache Service config file, you'll also need to reflect this change in the Prometheus.yml file as well.
NCacheServer.EnableSystemCountersMonitoringtag as True: The
NCacheServer.EnableSystemCountersMonitoringtag enables or disables the monitoring of system counters. This tag is set to False by default.
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 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.
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.
scrape_intervalper your requirement. This interval is the time after which the Prometheus server pulls metrics from Prometheus agent. The default value of this tag is 15 seconds.
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 the
Alachisoft.NCache.Service.dll.configfile. Your changes will look like this:
scrape_configs: - job_name: 'ncache-metrics' static_configs: - targets: ['184.108.40.206:8255','220.127.116.11:8255']
- Save the yml file.
Step 3: Run Prometheus Application for Cache Monitoring
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 18.104.22.168, I would request for 22.214.171.124: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.
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:
In case you encounter any issue with the Prometheus agent, go to MetricServer logs found at %NCHOME%\log-files.