Skip to content

seratch/new-relic-dashboard-in-slack

Repository files navigation

Personalized New Relic Dashboard App in Slack

This tiny Bolt ⚡️ app demonstrates how to build Slack apps utilizing Slack's new features and New Relic APIs. This app displays the list of New Relic applications and Slack users can choose one to check from the list. Also, users can run NRQL (New Relic Query Language) queries in modals (=without leaving Slack).

App Home

Slack apps can leverage any of Block Kit, a collection of powerful built-in UI components, to make Home Tab not only informative, furthermore interactive. This app illustrates how to build a kind of dashboard UI and also place buttons and drop-down menus in a user-friendly manner.

Modals

Modals are dynamic and interactive space for collecting data from Slack users and displaying information. Needless to say, we can use Block Kit in modals. In addition, Input blocks are available only in modals.

Prerequisites

Slack App

  • Create a Slack App at https://api.slack.com/
  • Sign up for App Home Beta (the feature is in the open beta as of Nov 2019)
  • Enable bot scopes (app_mentions:read, users:read)
  • Enable event subscriptions (app_home_opened, app_mention)
  • Enable Interactive Components (Just set Request URL correctly and save the change)
  • Install the App into your workspace

New Relic

  • REST API Key - https://rpm.newrelic.com/accounts/{your account id}/integrations?page=api_keys
  • Insights API Key - https://insights.newrelic.com/accounts/{your account id}/manage/api_keys

Local Development

export SLACK_APP_DEBUG=1
export SLACK_BOT_TOKEN=xoxb-xxx-yyy
export SLACK_SIGNING_SECRET=abc
npm i
npm run local
docker build -t new-relic-app .
docker run \
  -p 3000:3000 \
  -e SLACK_APP_DEBUG=1 \
  -e SLACK_BOT_TOKEN=xoxb-xxx-yyy \
  -e SLACK_SIGNING_SECRET=abc \
  -it new-relic-app

Also, run ngrok on localhost and set the URL at https://api.slack.com/apps/{your app id}.

ngrok http 3000

Deployment

If you prefer using a real database, feel free to fork this repository 👍

Heroku

Deploy

Google Cloud Run

gcloud config list # make sure if the project is valid
export GLOUD_PROJECT={your project}
export IMAGE_NAME=new-relic-bolt-app
export SLACK_BOT_TOKEN=xoxb-xxx-yyy-zzz
export SLACK_SIGNING_SECRET=the-value

git clone git@github.com:seratch/new-relic-dashboard-in-slack.git
cd new-relic-dashboard-in-slack

# Build a Docker image and upload it to Google's registry
gcloud builds submit --tag gcr.io/${GLOUD_PROJECT}/${IMAGE_NAME} .

# Deploy a Docker container to Google Cloud Run
gcloud run deploy \
  --image gcr.io/${GLOUD_PROJECT}/${IMAGE_NAME} \
  --platform managed \
  --update-env-vars SLACK_BOT_TOKEN=${SLACK_BOT_TOKEN},SLACK_SIGNING_SECRET=${SLACK_SIGNING_SECRET}

Resources

License

The MIT License

About

Tiny Bolt ⚡️ app demonstrating how to build Slack apps utilizing Slack's new features and New Relic APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published