SQL Alerter – Post to Slack

On this page

SQL Alerter

SQL Alerter is used to send a predefined message based on the result of an SQL query.

Post to Slack

The Post to Slack action will execute your SQL Query against a remote database. If the query returns a True result, then your message will be posted in your Slack Channel. If the query returns anything other than True, your message will not be posted. It requires you to provide a Slack token, a Slack channel, the text of the message that you want to send to the channel, a target database Connection and a SQL Query string to run against the database.

Alias

All Tasks contain this field. Set an Alias name that is meaningful and memorable as it will appear in the list of Tasks on your Nominode.

Slack Token

A Slack Token is a long string of characters used to specify both which Slack workspace contains the Slack channel that the message will be sent to and who the message will appear to come from.

This link contains more information about how to generate a token for your Slack workspace:

https://slack.com/help/articles/215770388-Create-and-regenerate-API-tokens

Slack Tokens are stored in a Slack:API:Token Connection on your Nominode.

This link contains more information about creating a Connection on a Nominode:

https://support.nomnomdata.com/portal/kb/articles/managing-connections-on-a-nominode#Creating_a_Connection

The Slack:API:Token Connection has two fields, Alias and Token.

  • Set the Alias field to something meaningful like “YourCompany Workspace as YourUser”.
  • Set the Token field to the text string that you obtained by following the steps in the first link.

Once the Connection is created, you can select its Alias from the drop down list for the Slack Token field on this Task.

Channel

Type in the Slack Channel name that you want to post the message into. The Channel has to already exist in the Slack Workspace that your Slack Token is associated with. The user that your Slack Token is associated with has to have access to post into the Channel. The Channel name that you specify in this Task has to match the name of the existing Channel in Slack exactly. Remember that Slack Channel names are in all lower case, do not contain spaces and are 21 characters or less.

Message

Type in a plain text string that you would like to be posted into the Slack Channel.

Target Database Connection

SQL Database access information is stored in a Generic:Database Connection on your Nominode.

This link contains more information about creating a Connection on a Nominode:

https://support.nomnomdata.com/portal/kb/articles/managing-connections-on-a-nominode#Creating_a_Connection

The Generic:Database Connection has seven fields.

  • Set the Alias field to something meaningful like “YourDatabase on YourSQLServer”.
  • Leave the Engine Type field set to the default value of “mysql”.
  • Set the Hostname field to the DNS name of the server running the software hosting your database.
  • Set the Database Name field to the name of your database.
  • Set the Username field to the name of the SQL user that has the desired access to your database.
  • Set the Password field to the SQL user’s password.
  • Set the Port field to the port number that your database server is listening on. MySQL servers listen on port 3306 by default.

Once the Connection is created, you can select its Alias from the drop down list for the Target Database Connection field on this Task.

SQL Query

Type in an SQL query that equates to either True or False. For example, this SQL query tests whether or not a row exists in YourTable with the YourValue column equal to 1000:

SELECT CASE WHEN EXISTS (
SELECT *
FROM [YourTable]
WHERE YourValue = 1000
)
THEN CAST(1 AS BIT)
ELSE CAST(0 AS BIT) END

Byte sized updates delivered to your inbox
  • This field is for validation purposes and should be left unchanged.