SQL Monitor 13

Setting up Webhook notifications

About Webhook notifications

You can set up SQL Monitor to push alert notifications to a Webhook URL of your choosing. This allows you to push alert notifications to a third-party tool such as ServiceNow or Microsoft Teams. 

Webhook notification messages are sent whenever any alert begins, escalates, de-escalates, or ends. You can customise the format of the message sent, including the use of custom parameters. See Custom Webhook messages for more details.

Configuring Webhook notifications

Go to the Configuration page. Under Alerts and Metrics, select Notification settings:

Configuring SQL Monitor to send Webhook notifications:

  1. Choose when SQL Monitor should send messages to your Webhook.
  2. Choose to send either the default message (see below) or define a custom message to send. See Custom Webhook messages for more details.
  3. Enter the Webhook URL into the URL box.
  4. Click Send Test Notification to check SQL Monitor can send messages to your Webhook.
  5. If you are using a proxy, see Proxy configuration at the end of this document.

Webhook Specification

  • Webhook notification messages are sent 20 seconds after the alert has been received.
  • If the message fails to be delivered, a second attempt will take place after 10 minutes.
  • Default Webhook messages are all predefined json payloads with the following content:

Field Definition

Field nameDescription
messageTypeType of message – all alert notification messages will have the value of "AlertNotification".
idInteger – Unique identifier per alert. [see uniquely identifying alerts]
baseMonitorGuidGuid – Unique identifier per Base Monitor service. [see uniquely identifying alerts]
nameName of the type of alert – for example: "Long-running query".
descriptionDescription of the alert – for example: "A SQL query runs for longer than a specified duration."
raisedDateTimeDate/time the alert was originally raised – ISO 8601 (UTC) for example: "2019-11-28T14:20:29.563Z".
eventDateTime

Date/time of this update to the alert – ISO 8601 (UTC) for example: "2019-11-28T14:20:29.563Z".

For Escalated, DeEscalated, or Ended statuses, this will be later than the raisedDateTime.

statusChangeOne of the following values:
  • Raised – The event has started.
  • Escalated – The event severity has increased.
  • DeEscalated – The event severity has decreased.
  • Ended – The event has come to an end.
severity

One of the following values:

  • None – Indicates that the event has come to an end.
  • Low – The severity is low.
  • Medium – The severity is medium.
  • High – The severity is high.
previousSeverity

One of the following values:

  • None – Indicates that the event has begun.
  • Low – The severity was low.
  • Medium – The severity was medium.
  • High – The severity was high.
monitoredEntity.cir

Internal path representation for the monitored entity in question. For example:

"Root[].[Cluster][[Name]=localhost].[SqlServer][[Name]=].[SqlProcess][[LoginTime]=28/11/2019 14:11:28;[SessionId]=59]"

represents a SqlProcess.

monitoredEntity.groupNameName of the SQL Monitor group within which the monitored entity is found. For example: "2 - Staging".
monitoredEntity.clusterNameName of the cluster. (If it exists for the given context.)
monitoredEntity.machineNameName of the machine. (if exists)
monitoredEntity.sqlInstance.nameName of the SQL Instance. (if exists)
monitoredEntity.sqlInstance.displayNameDisplay name of the SQL Instance. (if exists)
monitoredEntity.sqlInstance.AliasAliased name for the SQL Instance. (if exists)
monitoredEntity.azureSqlServerNameName of the Azure SQL Server. (if exists)
monitoredEntity.azureSqlDatabaseNameName of the Azure SQL Database. (if exists)
monitoredEntity.azureElasticPoolNameName of the Azure Elastic Pool. (if exists)
detailsUrlURL to the given alert's details page within SQL Monitor.

Uniquely identifying alerts

Sometimes it will be helpful to uniquely identify a SQL Monitor alert in another system. An alert id in SQL Monitor (the "id" property in this webhook message) is guaranteed to be unique to a single Base Monitor, but is not unique across multiple Base Monitors. To uniquely identify an alert globally in an environment which is fed alerts by multiple Base Monitors, use the combination of the "id" property and the "baseMonitorGuid" property, which distinguishes which Base Monitor it came from.

Sample message

{
  "messageType": "AlertNotification",
  "id": 1441792,
  "baseMonitorGuid": "a3d6fc66-c5f0-468f-a510-2d793439ff74",
  "name": "Long-running query",
  "description": "A SQL query runs for longer than a specified duration.",
  "raisedDateTime": "2019-11-28T14:20:29.563Z",
  "eventDateTime": "2019-11-28T15:04:12.123Z",
  "statusChange": "Raised",
  "severity": "Medium",
  "previousSeverity": "None",
  "monitoredEntity": {
    "cir": "Root[].[Cluster][[Name]=localhost].[SqlServer][[Name]=].[SqlProcess][[LoginTime]=28/11/2019 14:11:28;[SessionId]=59]",
    "groupName": "4 - Testing",
    "name": "localhost\\(local)",
    "machineName": "localhost",
    "sqlInstance": {
      "name": "",
      "displayName": "(local)"
    }
  },
  "detailsUrl": "https://sample.com:5000/show/alert/1441792?baseMonitorId=a3d6fc66-c5f0-468f-a510-2d793439ff74"
}

Proxy configuration

If using a proxy, you will need to configure SQL Monitor to use your proxy settings.

  • Go to the machine running the base monitor service.
  • Open file %PROGRAMDATA%\Red Gate\SQL Monitor\RedGate.SqlMonitor.Engine.Alerting.Base.Service.exe.settings.config and insert either of the following immediately below <networkSettings>, substituting the settings as appropriate.
<!-- Settings with bypass list -->
<defaultProxy address="http://192.168.1.10:8888" useDefaultCredentials="true" bypassLocal="true">
    <bypassList>
      <add address="http://example.com" />
      <add address="http://example2000.com" />
    </bypassList>
</defaultProxy>
<!-- Settings with no bypass list -->
<defaultProxy address="http://localhost:6000" useDefaultCredentials="true" bypassLocal="true" />
  • If not present, the following should also be added to the <configSections> section
<section name="defaultProxy" type="RedGate.SqlMonitor.Common.Networking.Configuration.DefaultProxySettingsSection, RedGate.SqlMonitor.Common.Networking" />
  • Save this file and restart the base monitor service

Do you have any feedback on this documentation?

Let us know at sqlmonitorfeedback@red-gate.com


Didn't find what you were looking for?