Monitor NCache Using Prometheus
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.
Note
This feature is only available in NCache Enterprise
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:
Important
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"/>
Set
NCacheServer.EnableMetricsPublishing
tag as True: TheNCacheServer.EnableMetricsPublishing
tag enables metrics publishing to NCache service. This tag is False by default.Set
NCacheServer.EnablePrometheusMonitoring
tag as True: TheNCacheServer.EnablePrometheusMonitoring
tag 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.
Additional Configuration
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"/>
- The
NCacheServer.MetricsServerPort
tag configures the port where the prometheus-agent runs. By default, the port is8255
but you can configure it as per your need.
Important
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.
- Set
NCacheServer.EnableSystemCountersMonitoring
tag as True: TheNCacheServer.EnableSystemCountersMonitoring
tag 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_interval
per 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 15 seconds.Set the
job_name
to a value containing the keyword "ncache-metrics" to distinguish multiple targets.Set your agent's address as the
targets
value. The port should be the same as the one mentioned in theAlachisoft.NCache.Service.dll.config
file. Your changes will look like this:
scrape_configs:
- job_name: 'ncache-metrics'
static_configs:
- targets: ['20.200.20.39:8255','20.200.20.40:8255']
- 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.39, I would request for 20.200.20.39: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