• Facebook
  • Twitter
  • Youtube
  • LinedIn
  • RSS
  • Docs
  • Comparisons
  • Blogs
  • Download
  • Contact Us
Download
Show / Hide Table of Contents

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:

  1. 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.

  2. NCache Exposes Metrics Through HTTP: The NCache Service makes the collected metrics available through an HTTP endpoint on port 9804. The /metrics endpoint provides metrics in a Prometheus-compatible format, while /metrics/json provides the latest available metrics in JSON format. The monitoring.ncconf file determines which performance counters are published.

  3. 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 /metrics endpoint and retrieves the currently available metrics. This process is known as scraping. The frequency of these requests is controlled by the scrape_interval setting.

  4. 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.

  5. 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.

Diagram explaining how prometheus collects operations occuring on NCache components

How to Configure NCache Prometheus Monitoring

To configure monitoring using Prometheus, follow these steps:

Step 1: Enable Metrics in NCache Service Settings

  • Windows
  • Linux

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.EnableMetricsPublishing tag as True: The NCacheServer.EnableMetricsPublishing tag enables metrics publishing to NCache service. This tag is False by default.

  • Set NCacheServer.EnablePrometheusMonitoring tag as True: The NCacheServer.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.

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.EnableSystemCountersMonitoring tag as True: The NCacheServer.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.

The Alachisoft.NCache.Daemon.dll.config configuration file, located at /opt/ncache/bin/service/, allows you to enable or disable Prometheus monitoring for NCache through configurable tags. These tags are:

<add key="NCacheServer.EnableMetricsPublishing" value="true"/>
<add key="NCacheServer.EnablePrometheusMonitoring" value="true"/>
Important

Apply the relevant monitoring configuration changes to the NCache service configuration files on all applicable NCache server and client machines.

  • Set NCacheServer.EnableMetricsPublishing to true: Enables metrics publishing to the NCache service.

  • Set NCacheServer.EnablePrometheusMonitoring to true: Enables the NCache service to expose collected metrics through its Prometheus monitoring endpoint.

  • Save Changes: Save the configuration file and restart the NCache service using the following command:

    sudo systemctl restart ncached.service
    

    Restart the relevant NCache Bridge service, cache processes, and client applications as required for the configuration changes to take effect.

Optional System Counter Settings

You can also enable system counter monitoring by adding or updating the following setting in the NCache service configuration file:

<add key="NCacheServer.EnableSystemCountersMonitoring" value="true"/>
  • Set NCacheServer.EnableSystemCountersMonitoring to true: Enables the publishing of system performance counters through the NCache monitoring endpoint.
Note

To monitor NCache client performance counters through Prometheus, NCache must be installed on the client machines.

  • Save Changes: Save the configuration file and restart the NCache service using:

    sudo systemctl restart ncached.service
    

    If Bridge monitoring is required, restart the NCache Bridge service using:

    sudo systemctl restart ncachebridged.service
    

    Restart any relevant cache processes and client applications to apply the changes.

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.

  • Windows
  • Linux
  • 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 1 minute.

  • 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 the Alachisoft.NCache.Service.dll.config file. 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.
  • Install Prometheus on your Linux machine using the following commands:

    sudo apt update
    sudo apt install prometheus -y
    
Note

You can install Prometheus on a separate machine, the client machine, or the NCache server. A single Prometheus server can monitor multiple NCache environments.

  • Open the prometheus.yml file in an editor using the following command:

    sudo nano /etc/prometheus/prometheus.yml
    
  • Set scrape_interval according to your requirements. This setting determines how frequently Prometheus retrieves metrics from the NCache monitoring endpoint. In the following example, the interval is set to 1 minute.

  • Set job_name to ncache-metrics to identify the NCache monitoring targets.

  • Set targets to the IP address and metrics port of your NCache server. In the verified Linux installation, the NCache HTTP metrics endpoint was accessible on port 9804. The configuration will look as follows:

    scrape_configs:
      - job_name: 'ncache-metrics'
        scrape_interval: 15s
        static_configs:
          - targets:
              - '20.200.20.11:9804'
    
Important

If the scrape_configs section already exists in prometheus.yml, add the ncache-metrics job under the existing section instead of creating another one. For multiple NCache servers, specify each server address as a separate target.

  • Save the prometheus.yml file and validate the configuration using:

    promtool check config /etc/prometheus/prometheus.yml
    
  • Restart Prometheus to apply the changes:

    sudo systemctl restart prometheus
    

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.

  • Windows
  • Linux
  • 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.

  • Start the Prometheus service on Linux using the following command:

    sudo systemctl start prometheus
    

    Verify that Prometheus is running using:

    sudo systemctl status prometheus
    

    If the service displays active (running), the Prometheus server has started successfully and is ready to scrape metrics from the configured NCache monitoring endpoints.

  • Open a web browser of your choice and enter the IP address of the machine running Prometheus, followed by the default Prometheus server port, 9090. For example, if Prometheus is running on 20.200.20.11, enter http://20.200.20.11:9090/ in the address bar.

  • This will open the Prometheus server on your machine.

Prometheus Server Dashboard

  • 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.

NCache Counters Monitor Prometheus Server

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:

Multiple NCache Counters Monitor Prometheus Server

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

Contact Us

PHONE

+1 214-619-2601   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top