GithubHelp home page GithubHelp logo

quota_alert_api_script's Introduction

Automatically Create Alert App Packs Via Script

Summary:

The essentials

  • Run this API script to create Alert App Pack rules for ALL projects within an org.
  • ⚠️ Use the script carefully; it will create alerts for every project in an org. With great power... πŸ•ΈοΈ
    • A good future feature for this would be to be able to pass it a list of projects to create alerts for.

Other things to know

  • The alerts are created without being assigned any teams. SEs or customers will need to assign teams.
  • The alerts are created with zero actions. SEs will need to encourage customers to add actions (i.e. set up an email/slack notification)
  • Alert creation via the script is idempotent, i.e. you can run the script as many times as you want and it will not create duplicate alerts.

Initial Setup

To setup the python env for this script:

  1. Create env - python3 -m venv env
  2. Activate venv - source env/bin/activate
  3. Install requirements - pip install -r ./requirements.txt

Configure

Prior to running create_alerts.py, you can configure the following fields in the config.properties file:

  1. ORG_NAME= <org name> - This should be assigned to your Organization Slug, found under Settings --> General Settings.

  2. AUTH_KEY= <auth_key> - Your org level auth key can be found under Settings --> Developer Settings --> Internal Integrations.

    a. If you don't have Internal Integrations set up, select New Internal Integrations and provide a Name for your integration.

    b. The Project and Organization permissions should be set to Read & Write. Screen Shot 2021-05-17 at 2 29 02 PM

    c. Once the above fields have been configured, click on Save Changes.

    d. This should redirect you to your Internal Integrations page with a token. This token is your org level auth key.

  3. CRITICAL=10000 - Critical threshold is set in the config file. No need to modify this value.

  4. WARNING=8000 - Warning threshold is set in the config file. No need to modify this value.

  5. SLEEP_TIME=<milliseconds> - When updating sleep time, please provide this value in milliseconds.

  6. ALERT_RULE_SUFFIX=_quota_limit - If you would like to rename the alert rule suffix, this can be done in the config file.

Run Script

Create Alerts for All Projects

`$ python3 create_alerts.py`

Confirm Alert Creation

  1. To confirm via UI navigate to the Alerts page to view the created alerts.
  2. By running python3 create_alerts.py a second time you can confirm if the alert already exists. (Check the log file for "alert already exists for + [project name]!")

Debug and Logging

After running the script you will see a log file created with the following naming convention - alert_logfile_{current_datetime}.log

Potential error and info logs will be displayed here.

Adding New Alerts to the Script

You can add new alerts to the script. Add them to the relevant ISSUE_ALERTS or METRIC_ALERTS constant. To successfully create a metric alert make sure each project has at least one team assigned to it!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.