send-query-result

command module
v0.0.0-...-e3da20d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2020 License: MIT Imports: 11 Imported by: 0

README

send-query-result

Stable Version

Sends the text output of a Postgres query to a Slack channel via Incoming Web Hook (or any web hook). The query is run on a configurable interval.

For example, if you wanted to know the count of records for a specific table in Postgres (and you don't have metrics), you could run this container with the following query:

select count(id) as user_count from app_users;

The message will appear as standard SQL output:

 user_count 
------------
          5 
(1 row)
Environment Variables

A configuration file would be better, but env vars will do for this project

Key Description
POSTGRES_USER Username of the Postgres user
POSTGRES_PW Password of the Postgres user
POSTGRES_HOST Postgres hostname or ip address
POSTGRES_DB Postgres database name
POSTGRES_SSL Postgres SSL Mode
STAT_QUERY The SQL query to be executed. Can result in single or multiple rows
STAT_INTERVAL The interval, in minutes, to run the query and send the result to the web hook url
STAT_URL The web hook URL to send the result (does not have to be Slack)
POST Body Format

This script is meant to send to a Slack Incoming Web Hook, so the request body will be formatted like so:

{
    "text": "```<sql_output>```"
}

Howevever, the sql output can be sent to any web hook

Dependencies

github.com/shomali11/xsql

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL