Skip to main content

Parse yml file and update alerts

Project description

Logo

License

Ignore Alerts

Set Ignore status for alert based on input YAML file



Supported Operating Systems

  • Linux (Bash): CentOS, Debian, Ubuntu
  • Windows (PowerShell): 10, 2012, 2016

Prerequisites

  • Python 3.9+
  • Mend user with admin permissions

Installation

$ pip install mend-ignore-alerts

Note: Depending on whether the package was installed as a root user or not, you need to make sure the package installation location was added to the $PATH environment variable.

Configuration Parameters

Note: Parameters can be specified as either command-line arguments, environment variables, or a combination of both.

Command-line arguments take precedence over environment variables.

CLI argument Env. Variable Type Required Description
‑‑help switch No Show help and exit
‑‑user-key WS_USERKEY string Yes Mend User Key
‑‑api-key WS_APIKEY string Yes Mend API Key
‑‑url WS_URL string Yes Mend Server URL
‑‑yaml WS_YAML string Yes Yaml file's name for parsing in case mode is equal load. If mode is create then Yaml file will be created
‑‑mode WS_MODE string Yes create or load value
‑‑ghpat WS_GHPAT string No GitHub PAT
‑‑ghowner WS_GHOWNER string No GitHub Owner
‑‑ghrepo WS_GHREPO string No GitHub Repo name

Usage

Using command-line arguments only:

ignore_alerts --user-key WS_USERKEY --api-key WS_APIKEY --url $WS_WSS_URL --yaml $WS_YAML --mode create

Using environment variables:

export WS_USERKEY=xxxxxxxxxxx
export WS_APIKEY=xxxxxxxxxxx
export WS_URL=https://saas.mend.io
export WS_YAML=waiverexample.yml

ignore_alerts

Note: Either form is accepted. For the rest of the examples, the latter form would be used

Getting waiver file from GitHub Repo:

export WS_USERKEY=xxxxxxxxxxx
export WS_APIKEY=xxxxxxxxxxx
export WS_URL=https://saas.mend.io
export WS_YAML=waiverexample.yml
export WS_GHPAT=xxxxxxxxxxx
export WS_GHOWNER = xxxxxxxxxxx
export WS_GHREPO = TestRepoName 

ignore_alerts

Running script as part of CI process: The example of CI yaml file

name: Ignore Alert Workflow

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.9']
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Install dependencies
        run: |
          pip install mend-ignore-alerts

      - name: Run ignore_alert script
        env:
          WS_APIKEY: ${{ secrets.apikey }}
          USER_KEY: ${{ secrets.userkey }}
          WS_URL: "saas.mend.io"
          YAML: "examplewaiver.yml"
          
        run: 
          ignore_alerts --url $WS_URL --yaml $YAML --apiKey $WS_APIKEY --user-key $USER_KEY --mode load

The YAML file should be placed in the Repo folder on GitHub

Execution Examples

Note: In the following examples, $WS_USERKEY, $WS_APIKEY, $WS_URL and $WS_MODE are assumed to have been exported as environment variables.

$ ignore_alerts --yaml whaiverexample.yml

Usind examplewaiver.yml file from some Repo

$ ignore_alerts --yaml whaiverexample.yml --ghpat xxxxxxx --ghowner Owner --ghrepo RepoName --mode create 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

mend_ignore_alerts-0.3.2-py3-none-any.whl (12.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page