How to use opsgenie-sdk - 2 common examples

To help you get started, we’ve selected a few opsgenie-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opsgenie / slack-to-opsgenie-alert-creator / main.js View on Github external
exports.handler = function (event, context, callback) {

    const slackToken = process.env.slackToken;
    const params = qs.parse(event.body);

    // token check to make sure that requests come from Slack
    if (params.token !== slackToken) {
        console.error(`Request token (${params.token}) does not match expected`);
        return callback('Invalid request token');
    }

    const opsgenieApiKey = process.env.opsgenieApiKey;

    opsgenie.configure({
        'api_key': opsgenieApiKey
    });

    var create_alert_json = {
        message: params.text
    };

    opsgenie.alertV2.create(create_alert_json, function (error, alert) {
        if (!error) {
            console.log("Alert creating response is a success!", alert);
            callback(null, "successful");
        } else {
            console.log("Error while trying to create an alert", error);
            callback(error);
        }
    });
github opsgenie / slack-to-opsgenie-alert-creator / main.js View on Github external
if (params.token !== slackToken) {
        console.error(`Request token (${params.token}) does not match expected`);
        return callback('Invalid request token');
    }

    const opsgenieApiKey = process.env.opsgenieApiKey;

    opsgenie.configure({
        'api_key': opsgenieApiKey
    });

    var create_alert_json = {
        message: params.text
    };

    opsgenie.alertV2.create(create_alert_json, function (error, alert) {
        if (!error) {
            console.log("Alert creating response is a success!", alert);
            callback(null, "successful");
        } else {
            console.log("Error while trying to create an alert", error);
            callback(error);
        }
    });
};

opsgenie-sdk

OpsGenie Node.js SDK

Apache-2.0
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular opsgenie-sdk functions