pivotal-cf/service-alerts-client

Name: service-alerts-client

Owner: Pivotal Cloud Foundry

Description: Service Alerts Client for CF Notifications

Created: 2017-06-02 13:24:01.0

Updated: 2017-06-05 15:11:00.0

Pushed: 2017-09-18 10:07:39.0

Homepage:

Size: 867

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Service Alerts Client

Service Alerts Client allows service authors to send alert emails via the Cloud Foundry Notifications Service to all users with the SpaceDeveloper role in the configured Cloud Foundry space.

Installation

Clone the git repository at $GOPATH/src/github.com/pivotal-cf and compile it with go install github.com/pivotal-cf/service-alerts-client/cmd/send-service-alert.

Cloud Foundry set up

The tool requires:

Here is an example setup:

CF space auditor

We recommend creating a CF user with least privilege to query the CF API and provide their credentials in the config file. They need to have a space role in the configured space:

arget -o CF_ORG -s CF_SPACE
reate-user SPACE_AUDITOR_USERNAME SPACE_AUDITOR_PASSWORD
et-space-role SPACE_AUDITOR_USERNAME CF_ORG CF_SPACE SpaceAuditor
Service alert recipient

Only CF users with the space developer role in the configured space will receive emails.

et-space-role SPACE_DEV_USERNAME CF_ORG CF_SPACE SpaceDeveloper
UAA client

We recommend creating a UAA client with the least privilege to send notifications to a space. A full list of related permissions can be found in the CF notifications service documentation.

 client add CLIENT_NAME \
secret CLIENT_SECRET \
authorized_grant_types client_credentials \
authorities notifications.write

Usage

As a library

There is an example go program that calls the service-alerts-client here. The config values are redacted so ensure to fill with values of your set up. Make sure the space you use has a user with an email address.

On the command line
-service-alert \
onfig <config file path> \
roduct <product name> \
ervice-instance <OPTIONAL: service instance ID> \
ubject <email subject> \
ontent <email content>

The format of the config file:

d_controller:
l: <Cloud Foundry API URL>
er: <Cloud Foundry username with SpaceAuditor role in cf_space>
ssword: <Cloud Foundry password>
fications:
rvice_url: <Cloud Foundry notification service URL>
_org: <Cloud Foundry org name>
_space: <Cloud Foundry space name>
ply_to: <OPTIONAL: email reply-to address. This is required for some SMTP servers>
ient_id: <UAA client ID with authorities to send notifications>
ient_secret: <UAA client secret>
out_seconds: <OPTIONAL: default is 60>
_ssl_validation: <OPTIONAL: ignore TLS certification verification errors>
HTTP retry strategy

HTTP requests will be retried if they fail due to a network error, a response status code of 5xx, or 404 from the Cloud Foundry Router. HTTP requests will be attempted with exponential back-off between attempts.

The timeout refers to a global maximum time to send a service alert, not a timeout per HTTP request.

Email content

The email that is sent will have the subject CF Notification: [Service Alert][<product>] <subject>. The body is plain text only.

When the service-instance flag is set, the body will be in the following format:

received this message because you belong to the "<org>" space in the "<space>" organization.
t from <product>, service instance <service instance ID>:

tent>

rt generated at <RFC 3339 datetime>]

When service-instance flag is not set, the body will be in the following format:

t from <product>:

tent>

rt generated at <RFC 3339 datetime>]

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.