visit
heroku addons:create activitytogo:free
Connecting to Slack
For the purposes of this example, Activity To Go will be used to send alerts any time the Heroku Dyno changes. The use case here is to alert the feature team when changes are being pushed to Heroku.In order to accomplish this, the Add subscription button is used from the Activity To Go dashboard. That opens a new subscription form:
For the purposes of this example, I named my subscription Service Alerts and selected the Release and App options. Next, click the Configure button for "Send a Slack message."
This pops up a modal to allow access to Slack:From here, select the service-alerts Slack channel and choose the Allow button.
The Configure Slack action modal is displayed so the settings can be confirmed:
Upon pressing the Done button, you are ready to save the new subscription:
heroku addons:create coralogix:free-30mbday
Connecting to Slack
In order to connect to Slack, enter the Settings within the Coralogix dashboard. Next, select the Webhooks option and select the Add new webhook option (use the plus icon on the right side of the screen). Provide an alias as shown below and make sure to select the Slack option.
With the Slack instance open, launch the following URL:Select the channel you wish to use (or create a new one) and single-click the Add Incoming Webhooks Integration button:
If the page does not automatically refresh, refresh it yourself and note the Webhook URL value.
To validate, single-click the Test Configuration button. A message similar to what is displayed below should appear in the Slack instance:
Configuring Alerts
With Coralogix ready for use, I decided to create two custom alerts:Within the Alerts section of the Coralogix dashboard, I made a new alert with the following attributes to track activity for the API:
Out of Bounds Error Alert
Within the Alerts section of the Coralogix dashboard, I created this new alert with the following attributes to track when the out of bounds exception occurs:
heroku addons:create rollbar:free
The pom.xml file has already been updated in this repository to include the following dependency:<dependency>
<groupId>com.rollbar</groupId>
<artifactId>rollbar-spring-boot-webmvc</artifactId>
<version>1.7.4</version>
</dependency>
rollbar:
access-token: ${ROLLBAR_ACCESS_TOKEN}
branch: master
environment: ${ROLLBAR_ENVIRONMENT}
code-version: ${HEROKU_RELEASE_VERSION}
spring:
application:
name: heroku-slack
@RequiredArgsConstructor
@Slf4j
@Component
public class RollbarEvents {
private final Environment environment;
private final RollbarConfigurationProperties rollbarConfigurationProperties;
private final Rollbar rollbar;
@PostConstruct
public void postConstruct() {
log.info("Started {} on port #{} using Rollbar accessToken={} ({})",
environment.getProperty("spring.application.name"),
environment.getProperty("server.port"),
SecurityUtils.maskCredentialsRevealPrefix(rollbarConfigurationProperties.getAccessToken(), 5, '*'),
rollbarConfigurationProperties.getEnvironment());
rollbar.info(String.format("Started %s on port #%s using Rollbar accessToken=%s (%s)",
environment.getProperty("spring.application.name"),
environment.getProperty("server.port"),
SecurityUtils.maskCredentialsRevealPrefix(rollbarConfigurationProperties.getAccessToken(), 5, '*'),
rollbarConfigurationProperties.getEnvironment()));
}
}
Connecting to Slack
In order to connect to Slack, use the Settings menu from the Rollbar application (launched from Heroku). Once the Rollbar project is selected, navigate to the Integrations | Notifications option. Simply single-click the Slack icon in the list of Available Channels.
After selecting my existing access token, I selected the #application-errors channel and left all other defaults in place.
Pushing the Send Test Notification button will send a test message to Slack. Navigating to Slack and the #application-errors channel show the following test message:
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Artist {
private String name;
}
Deploying a New Release
Giving feature team members the ability to see when the application is deployed to a Heroku Dyno has a number of benefits. With the Activity To Go add-on in place, the following message will appear in the #service-alerts Slack channel:
Heroku Dyno Configuration Changes
The Activity To Go add-on will also post a message in the #service-alerts Slack channel when system variables change in the Heroku instance:
Making a Simple Request
In this simple repository, using the GET /artists URI returns a list of hard-coded artists. Coralogix Logging is configured to publish the following Slack message in the #coralogix channel:
Generating a Bad Request
When a bad request is created—in this case by requesting an Artist for a position value which does not exist—both the Coralogix Logging and Rollbar add-on products provide information to Slack.
Trigging off the ERROR alert, Coralogix Logging posts the following message in the #coralogix channel in Slack:
Based upon the Java code updates and the GlobalControllerExceptionHandler, Rollbar posts the following message in the #application-errors channel in Slack:
The Rollbar product provides additional value in its ability to assign the error to a configured team member, directly from the Slack instance:
Both Coralogix Logging and Rollbar provide additional information from their user interfaces.
The Coralogix Logging alert summary provides a nice break-down of all the alerts that have been captured:
Coralogix Logging provides a high-level dashboard as well:
Rollbar provides an advanced dashboard which can even link directly to the source code:
The Items view provides a high-level summary of each error as well: