steampipe plugin install slack

Slack + Steampipe

Slack is a messaging program designed specifically for the workplace.

Steampipe is an open-source zero-ETL engine to instantly query cloud APIs using SQL.

For example:

select
email,
is_admin
from
slack_user;
+-----------------+----------+
| email| | is_admin |
+-----------------+----------+
| pam@dmi.com | false |
| creed@dmi.com | true |
| stanley@dmi.com | false |
| michael@dmi.com | true |
| dwight@dmi.com | false |
+-----------------+----------+

Documentation

Get started

Install

Download and install the latest Slack plugin:

steampipe plugin install slack

Credentials

API tokens in Slack are associated with Apps. To use Steampipe, you need to create an App in Slack with the appropriate permissions.

  1. Sign in to the Slack website, and view "Your Apps" at https://api.slack.com/apps.
  2. Select Create New App.
  3. Select From scratch.
  4. Enter an application name, e.g., Steampipe CLI, and select your workspace.
  5. Select Add features & functionality.
  6. Select Permissions.
  7. Scroll down to "Scopes" and then "User Token Scopes".
  8. Add permissions by scope, using the table below to grant the required read access.
  9. Scroll up to "OAuth Tokens for Your Workspace" and (re)install your app.
  10. Copy the user OAuth token for the application. It looks like xoxp-2556146250-EXAMPLE-1646968370949-df954218b5da5b8614c85cc454136b27.

Permissions and Scopes

Scopes are used to determine the permissions and access granted to your App in Slack. Steampipe requires different permissions for each table. We recommend granting the team:read scope and all of the scopes in the table below, but you can restrict them to specific tables if you prefer.

Please note that if you add scopes to an application, you will need to reinstall the application to the workspace for the changes to take effect.

TableScopes Required
All tablesteam:read (if querying the workspace_domain column)
slack_access_logadmin (paid plan required)
slack_connectionNone
slack_conversationchannels:read, groups:read, im:read, mpim:read
slack_conversation_memberchannels:read, groups:read, im:read, mpim:read
slack_emojiemoji:read
slack_groupusergroups:read
slack_searchsearch:read
slack_userusers:read, users:read.email

Configuration

Installing the latest slack plugin will create a config file (~/.steampipe/config/slack.spc) with a single connection named slack:

connection "slack" {
plugin = "slack"
# The Slack app token used to connect to the API.
# Can also be set with the SLACK_TOKEN environment variable.
#token = "xoxp-YOUR_TOKEN_HERE"
}

Postgres FDW

This plugin is available as a native Postgres FDW. Unlike Steampipe CLI, which ships with an embedded Postgres server instance, the Postgres FDW can be installed in any supported Postgres database version.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_postgres_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/postgres.sh)" -- slack

The installer will prompt you for the plugin name and version, download and install the appropriate files for your OS, system architecture, and Postgres version.

To configure the Postgres FDW, you will create an extension, foreign server, and schema and import the foreign schema.

CREATE EXTENSION IF NOT EXISTS steampipe_postgres_slack;
CREATE SERVER steampipe_slack FOREIGN DATA WRAPPER steampipe_postgres_slack OPTIONS (config '<your_config>');
CREATE SCHEMA slack;
IMPORT FOREIGN SCHEMA slack FROM SERVER steampipe_slack INTO slack;

SQLite Extension

This plugin is available as a SQLite Extension, making the tables available as SQLite virtual tables.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_sqlite_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/sqlite.sh)" -- slack

The installer will prompt you for the plugin name, version, and destination directory. It will then determine the OS and system architecture, and it will download and install the appropriate package.

To configure the SQLite extension, load the extension module and then run the steampipe_configure_slack function to configure it with plugin-specific options.

$ sqlite3
sqlite> .load ./steampipe_sqlite_extension_slack.so
sqlite> select steampipe_configure_slack('<your_config>');

Export

This plugin is available as a standalone Export CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- slack

You can pass the configuration to the command with the --config argument:

steampipe_export_slack --config '<your_config>' <table_name>