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

Get NCache Alerts on Slack

Stay on top of your caching infrastructure without constantly checking dashboards. With NCache alerts delivered directly to Slack, your team can get real-time notifications about critical events, performance issues, and system health—right where collaboration already happens. This integration helps you respond faster, reduce downtime, and keep everyone aligned by bringing actionable insights into a shared communication channel. Whether it’s node failures, cache synchronization issues, or resource thresholds being exceeded, Slack alerts ensure you never miss what matters most.

Prerequisites

Before you start, make sure you have:

  • NCache is installed.
  • Administrative access to your NCache servers.
  • A Slack workspace where you can install apps.
  • Permission to create or manage apps in Slack (or access to someone who can).
  • Network connectivity from your NCache servers to Slack (outbound HTTPS allowed).

Step 1: Create a Slack Incoming Webhook

This sets up the URL that acts as the endpoint where your system will send alert data to Slack.

  • Go to your Slack workspace and open Apps.
  • Search for Incoming Webhooks and add it.
  • Choose or create the channel where alerts should be posted (#ncache-alerts).
  • Click Add Incoming Webhook.
  • Copy the generated Webhook URL (which will be something like, "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXX").
  • In order to verify the Webhook is working run the following .ps1 script:
$webhook = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXX"

$body = @{
    text = "NCache Slack integration is working"
} | ConvertTo-Json

Invoke-RestMethod -Uri $webhook -Method Post -Body $body -ContentType 'application/json'
Note

The $webhook provided is a placeholder, please replace it with yours.

NCache does not directly integrate with Slack. For Windows, you will instead use a PowerShell script triggered by Windows Event Logs (via Task Scheduler) to send alerts to Slack. And for Linux, you will use a script to read the NCache logs available through /opt/ncache/log-files/eventlogs/eventlogs.txt for the events you require.

Step 2: Decide What Alerts You Want from NCache

In NCache, alerts are tied to specific events and thresholds. Common ones include:

  • Cache node joined/left
  • Cache stopped or restarted
  • High CPU or memory usage
  • Network or connectivity issues
  • Cache synchronization or replication failures

Think about signal vs. noise—start with critical alerts and expand later. This page uses the CacheStart event with Event ID 1000 and source NCache.

Important

You can learn more about NCache Event ID's from the NCache Administrators Guide.

Step 3: Create a Simple Slack Alert Script

  • Windows
  • Linux

Create a PowerShell script file, for example: C:\NCache\Scripts\Send-NCacheAlert.ps1. The following script retrieves the most recent matching event from the Windows Event Log. In high-frequency environments, you may need to refine this logic to avoid duplicate or mismatched alerts.

$event = Get-WinEvent -FilterHashtable @{
    LogName = 'Application'
    ProviderName = 'NCache'
    Id = 1000
} -MaxEvents 1

$eventId = $event.Id
$messageText = $event.Message

# Extract cache name safely
if ($messageText -match '"([^"]+)"\s+started successfully')
{
    $cacheName = $matches[1]
}
else
{
    $cacheName = "Unknown Cache"
}

$node = $env:COMPUTERNAME

$webhook = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXX"

$message = @"
NCache Alert
Cache: $cacheName
Node: $node
Event: Cache Started (Event ID $eventId)
Details: $messageText
Time: $(Get-Date)
"@

$payload = @{
    text = $message
} | ConvertTo-Json

Invoke-RestMethod -Uri $webhook -Method Post -Body $payload -ContentType "application/json"
Note

Your ProviderName will change if you want to a notification based on an event with a NCache Service, NCacheBridgeServer, NCache Bridge, NBridgeSvc, or LoaderService source. Similarly, the message pattern (e.g., "started successfully") you are searching for, will also change.

Create a Bash script file, for example: /opt/ncache/scripts/send_ncache_alert.sh. The script monitors the NCache event log file for the most recent iteration of the event you require by searching for entries that match the pattern you are looking for. It extracts the latest entry, checks it against a stored state file to prevent duplicate alerts, and only proceeds if the event is new. It then parses the cache name from the log message, builds a formatted Slack notification containing the cache name, node hostname, event details, and timestamp, and safely encodes the message into valid JSON using Python to avoid payload formatting errors. Finally, it sends the alert to a Slack Incoming Webhook using curl.

  • You can do this by first creating a directory by running the following command:
sudo mkdir -p /opt/ncache/scripts
  • Next you need to create a file using the following command:
sudo nano /opt/ncache/scripts/send_ncache_alert.sh
  • Copy and paste the following script into this file after updating your webhook.
#!/bin/bash

WEBHOOK="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXX"
LOG_FILE="/opt/ncache/log-files/eventlogs/eventlogs.txt"
STATE_FILE="/tmp/ncache_last_event.txt"

EVENT=$(grep -E 'NCache.*1000.*"[^"]+"\s+started successfully\.' "$LOG_FILE" | tail -n 1)

if [ -n "$EVENT" ]; then

    LAST_EVENT=$(cat "$STATE_FILE" 2>/dev/null)

    if [ "$EVENT" != "$LAST_EVENT" ]; then

        echo "$EVENT" > "$STATE_FILE"

        CACHE_NAME=$(echo "$EVENT" | grep -oP '"\K[^"]+')

        MESSAGE="NCache Alert
Cache: $CACHE_NAME
Node: $(hostname)
Event: Cache Started (Event ID 1000)
Details: $EVENT
Time: $(date)"

        # SAFE JSON encoding using Python (fixes invalid_payload)
        PAYLOAD=$(python3 - <<EOF
import json
print(json.dumps({"text": """$MESSAGE"""}))
EOF
)

        curl -s -X POST -H "Content-type: application/json" \
        --data "$PAYLOAD" \
        "$WEBHOOK"

    fi
fi
Note

Your Event ID (e.g., "1000") will change and message pattern (e.g., "started successfully") will change as per your requirements.

  • Verify the existence of the file using the following:
ls -l /opt/ncache/sripts/
  • Make the script executable using the following:
sudo chmod +x /opt/ncache/scripts/send_ncache_alert.sh
Important

Make sure you have curl installed before running the script, if not use the following commands:

sudo apt update
sudo apt install curl -y

Step 4: Set Up A Trigger

  • Windows
  • Linux
  • Press Windows + R, then type "taskschd.msc", and press Enter.

Image showing how to access to the "taskschd.msc" application

  • Create a new task using Task Scheduler.
Warning

Do NOT use “Create Basic Task” (it doesn’t support event filtering properly).

Image showing how to create a task using Task Scheduler

  • In the resulting Task Scheduler prompt, Set the Task Name, enable "Run whether user is logged on or not" and "Run with highest privileges".

Image showing the general tab while creating a task.

  • In the Triggers Tab, click on New....

Image showing the triggers tab while creating a task.

  • In the resulting window, choose to begin the task on an event, set the Log to Application, choose the Source you require, and enter the appropriate Event ID. And click on OK.

Image showing the process for creating a task trigger.

  • In the Actions Tab, click on New....

Image showing the actions tab while creating a task.

  • In the resulting window, make sure the Action: is set to "Start a program". Choose to start the PowerShell application at %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe, using Browse. To execute your script add the following arguments, and click on OK.
-ExecutionPolicy Bypass -File "C:\NCache\Scripts\Send-NCacheAlert.ps1"
Note

The -File provided is a placeholder, please replace it with yours.

Image showing the process for creating the action a task will trigger.

Tip

In the Conditions Tab, you can enable “Start only if on AC power”, which is recommended for servers.

  • In the Settings Tab, enable "Allow task to be run on demand" and "Run task as soon as possible after a missed start".

Image showing the settings tab while creating a task.

  • Once the triggers, actions, and settings have been set, click OK.

  • In order to verify, the task has been created successfully, run the following PowerShell command.

Get-ScheduledTask -TaskName "NCache Slack Alerts"

Image showing the results of PowerShell verification after creating a task.

  • Create a custom system service file:
/etc/systemd/system/ncache-alert.service
  • Paste the following [Unit] and [Service] into this file, to ensure that the service runs a task once then exits:
[Unit]
Description=NCache Slack Alert Service

[Service]
Type=oneshot
ExecStart=/opt/ncache/scripts/send_ncache_alert.sh
  • Create a path watcher with the following path:
sudo nano /etc/systemd/system/ncache-alert.path
  • Paste the following [Unit], [Path], [Install] into this file, to ensure systemd watches the /opt/ncache/log-files/eventlogs/eventlogs.txt file.
[Unit]
Description=Watch NCache log file

[Path]
PathModified=/opt/ncache/log-files/eventlogs/eventlogs.txt

[Install]
WantedBy=multi-user.target
  • Reload systemd so it recognizes your new unit files.
sudo systemctl daemon-reload
  • Enables the path watcher to start automatically on boot.
sudo systemctl enable ncache-alert.path
  • Run the following command to start monitoring the file immediately.
sudo systemctl start ncache-alert.path

Now, if the event you chose occurs you will get a message on slack.

Image showing a slack message notifying of an event.

See Also

Monitor Caches
Logging
NCache Management Center

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