Let’s start this blog by making a supposition. Let’s assume that you have an e-business that uses NCache as a distributed cache for better performance and scalability. To keep a check on this performance, NCache supports monitoring with native tools like PerfMon on Windows and SNMP on Linux. However, for a more sophisticated and platform independent monitoring, NCache has recently given the support of majorly trending open-source solutions: Prometheus and Grafana.
Since Linux now supports .NET and Microsoft also declared the same PerfMon tool to be outdated, these monitoring tools help to collectively obtain all the cache statistics, keeps your cache status up to date and monitor your cache in a friendly manner.
NCache Details Monitor Caches SNMP Monitoring
Rich Set of Tools for Monitoring NCache
NCache provides multiple ways to monitor your cache clusters. You can monitor cache servers, client servers and bridge caches through the counters published by NCache. To monitor your stats on a single platform, NCache provides the support for the following feature rich tools:
- Prometheus for data storage: Prometheus is an open-source metric collection and storage tool which enables you to collect and view the accumulative collective cache statistics in a user-friendly manner.
- Monitoring with Grafana: Grafana is a multi-platform open-source monitoring GUI tool which uses Prometheus server as its data source to pull all the metrics and then collects and displays those metrics data from the NCache cluster.
How to Monitor NCache Using Prometheus
NCache provides the support of open-source Prometheus monitoring tool that allows the publishing of collective stats on one platform.
Monitoring NCache using Prometheus tool has following three components:
- Metrics Publisher: Metrics publisher is responsible for fetching and collecting stats from all metric sources such as cache servers, client servers and bridge caches. These metrics are exposed at node level. After a set time interval, it publishes the collected metrics on NCache service.
- Prometheus Agent: Prometheus agent or Metrics Agent is used to fetch metrics from NCache service on each node. If you have enabled metrics publishing, then you can view metrics details of a node that has NCache service running on it using its IP and the default port on which the agent runs.
- Prometheus Server: Prometheus server provides a platform to view the cache and bridge stats. It runs on 9090 port and can be downloaded from io.
To configure monitoring using Prometheus, following steps should be taken accordingly.
1. Configure NCache Service Config
The %NCHOME%/bin/service/Alachisoft.NCache.Service.exe.config file shipped with NCache allows you to enable or disable monitoring of your caches on Prometheus through configurable tags as follows:
<add key="NCacheServer.EnableMetricsPublishing" value="false"/>
<add key="NCacheServer.EnablePrometheusMonitoring" value="false"/>
<add key="NCacheServer.MetricServerPort" value="8255"/>
<add key="NCacheServer.EnableSystemCountersMonitoring" value="false"/>
For details on these tags, refer to Monitoring with Prometheus Docs.
2. Configure Prometheus Config File
For monitoring NCache using Prometheus, you have to populate a Prometheus.yml file which is shipped with the Prometheus server. You have to set certain variables according to your requirement which are:
- scrape_interval: Time interval after which Prometheus server pulls metrics from Prometheus agent.
- job_name: Used to distinguish multiple targets.
- targets: Used for setting the agents address.
For better understanding of these variables, refer to Monitoring with Prometheus.
3. Run Prometheus Application for Cache Monitoring
The Prometheus sever runs at the default 9090 port which is shown below.
4. Monitor Counters with Prometheus
After the server runs successfully, you can search for the counters that you want to monitor from the search bar and execute the query to add them to the panel. Prometheus will fetch all the instances of that counter from all the targets specified in the yml file.
Shown below are multiple cache counters being displayed along with multiple panels.
How to Monitor NCache Using Grafana
NCache supports the integration with Grafana GUI application that collects and displays metrics data from your NCache cache cluster. To use Grafana, you have to configure monitoring of NCache using Prometheus as Grafana collects metrics published on Prometheus server.
For using Grafana, you must first need to know about monitoring with Prometheus. To learn about it, go to Monitor NCache using Prometheus.
2. Setting up Grafana Application
Next, for installations details on how to setup Grafana, refer to the Grafana Getting Started Guide.
3. Add Prometheus as Data Source
As stated earlier, Grafana uses counters that are published on Prometheus agent as input data, which is why it is necessary to add Prometheus as Grafana’s default data source. To add Prometheus as a default data source, follow the Add Data Source Guide.
4. Create Dashboard for NCache Monitoring
Now, you need to start creating monitoring dashboards with multiple panels that show the NCache counters. Dashboards can be created by the following two ways:
- Through NCache Plugin: NCache plugin includes the pre-configured dashboards such as the Cache Dashboard for showing cache server counters, Client Dashboard for client cache counters and Bridge Dashboard for bridge and bridge cache counters. These pre-configured dashboards can be added by going to the Grafana marketplace and searching for NCache. An NCache application will be shown which holds these pre-configured dashboards and you can add them accordingly.
Following is Cache Dashboard which includes panels to monitor cache servers.
- Create Custom Dashboard: You can also create your own custom dashboard by first creating a dashboard and then adding a panel to it. Next, under the Metrics section, select ncache which will show you all the list of metrics collected from the Prometheus server.
Shown below is custom dashboard created with different cache counters.
Summing It All Up…
NCache is a feature-rich, in-memory, distributed data store that given faster response time and quality performance. Therefore, when your cache clusters are running in a high transaction load environment, it is necessary to monitor the cache nodes and the cluster together on a single platform. NCache comes with the support of Prometheus and Grafana which makes monitoring the cache cluster environment as convenient as possible.