gbilling2slack

package module
v0.0.0-...-47fe771 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

gbilling2slack

Slack notifications tools for Google Cloud Platform Billing.

Overview

This package notifies gcp billing to your slack channel.

  • Cloud Scheduler sends message to Cloud Pub/Sub and Cloud Pub/Sub triggers Cloud Functions.
  • Cloud Functions gets billing from BigQuery table and sends it to your Slack channel.
  • You can see billing on Slack channel.

Requirements

Notify GCP Billing to Slack requires the following to run:

Variables

Notify GCP Billing to Slack requires only 3 variables to run:

# variables Note
1 TABLE_NAME Table name of billing on BigQuery
2 SLACK_API_TOKEN Slack api token
3 SLACK_CHANNEL Slack channel name

Usage

This package uses below services.

  • Google Cloud Billing(BigQuery)
  • Google Cloud Functions
  • Google Cloud Pub/Sub
  • Google Cloud Scheduler
  • Slack API

Steps

  1. Get Slack API Token
  2. Export your GCP billing to BigQuery (reference)
  3. Set Cloud Scheduler
gcloud beta scheduler jobs create pubsub notify-billing-to-slack --project <YOUR GCP PROJECT> \
  --schedule "55 23 * * *" \
  --topic topic-billing \
  --message-body="execute" \
  --time-zone "Asia/Tokyo" \
  --description "This job invokes cloud function via cloud pubsub and send GCP billing to slack"
  1. Deploy to Cloud Functions
gcloud functions deploy notifyBilling --project <YOUR GCP PROJECT> \
  --entry-point NotifyBilling \
  --trigger-resource topic-billing \
  --trigger-event google.pubsub.topic.publish \
  --runtime go111 \
  --set-env-vars TABLE_NAME=<billing table-name> \
  --set-env-vars SLACK_API_TOKEN=<slack-api-token> \
  --set-env-vars SLACK_CHANNEL=<slack-channel-name>
  1. Go to the Cloud Scheduler page and click the run now button of notify-billing-to-slack

Example

You can get below output on slack when it comes to the set time.

This automatically notify you of charges for all services charged on GCP.

example.png

License

This project is licensed under the Apache License 2.0 License - see the LICENSE file for details

Documentation

Overview

*

  • Copyright (c) 2019-present Future Corporation *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotifyBilling

func NotifyBilling(ctx context.Context, msg *pubsub.Message) error

Types

This section is empty.

Directories

Path Synopsis
* * Copyright (c) 2019-present Future Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright (c) 2019-present Future Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright (c) 2019-present Future Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright (c) 2019-present Future Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright (c) 2019-present Future Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright (c) 2019-present Future Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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