@pulumiverse/grafana
Version:
A Pulumi package for creating and managing grafana.
174 lines • 6.77 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotificationPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Sets the global notification policy for Grafana.
*
* !> This resource manages the entire notification policy tree and overwrites its policies. However, it does not overwrite internal policies created when alert rules directly set a contact point for notifications.
*
* * Official documentation
* * [HTTP API](https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/api-legacy/alerting_provisioning/#notification-policies)
*
* This resource requires Grafana 9.1.0 or later.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as grafana from "@pulumiverse/grafana";
*
* const aContactPoint = new grafana.alerting.ContactPoint("a_contact_point", {
* name: "A Contact Point",
* emails: [{
* addresses: [
* "one@company.org",
* "two@company.org",
* ],
* message: "{{ len .Alerts.Firing }} firing.",
* }],
* });
* const aMuteTiming = new grafana.alerting.MuteTiming("a_mute_timing", {
* name: "Some Mute Timing",
* intervals: [{
* weekdays: ["monday"],
* }],
* });
* const workingHours = new grafana.alerting.MuteTiming("working_hours", {
* name: "Working Hours",
* intervals: [{
* times: [{
* start: "09:00",
* end: "18:00",
* }],
* }],
* });
* const myNotificationPolicy = new grafana.alerting.NotificationPolicy("my_notification_policy", {
* groupBies: ["..."],
* contactPoint: aContactPoint.name,
* groupWait: "45s",
* groupInterval: "6m",
* repeatInterval: "3h",
* policies: [
* {
* matchers: [
* {
* label: "mylabel",
* match: "=",
* value: "myvalue",
* },
* {
* label: "alertname",
* match: "=",
* value: "CPU Usage",
* },
* {
* label: "Name",
* match: "=~",
* value: "host.*|host-b.*",
* },
* ],
* contactPoint: aContactPoint.name,
* "continue": true,
* muteTimings: [aMuteTiming.name],
* activeTimings: [workingHours.name],
* groupWait: "45s",
* groupInterval: "6m",
* repeatInterval: "3h",
* policies: [{
* matchers: [{
* label: "sublabel",
* match: "=",
* value: "subvalue",
* }],
* contactPoint: aContactPoint.name,
* groupBies: ["..."],
* }],
* },
* {
* matchers: [{
* label: "anotherlabel",
* match: "=~",
* value: "another value.*",
* }],
* contactPoint: aContactPoint.name,
* groupBies: ["..."],
* },
* ],
* });
* ```
*
* ## Import
*
* ```sh
* terraform import grafana_notification_policy.name "{{ anyString }}"
* terraform import grafana_notification_policy.name "{{ orgID }}:{{ anyString }}"
* ```
*/
class NotificationPolicy extends pulumi.CustomResource {
/**
* Get an existing NotificationPolicy resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new NotificationPolicy(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of NotificationPolicy. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === NotificationPolicy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["contactPoint"] = state?.contactPoint;
resourceInputs["disableProvenance"] = state?.disableProvenance;
resourceInputs["groupBies"] = state?.groupBies;
resourceInputs["groupInterval"] = state?.groupInterval;
resourceInputs["groupWait"] = state?.groupWait;
resourceInputs["orgId"] = state?.orgId;
resourceInputs["policies"] = state?.policies;
resourceInputs["repeatInterval"] = state?.repeatInterval;
}
else {
const args = argsOrState;
if (args?.contactPoint === undefined && !opts.urn) {
throw new Error("Missing required property 'contactPoint'");
}
if (args?.groupBies === undefined && !opts.urn) {
throw new Error("Missing required property 'groupBies'");
}
resourceInputs["contactPoint"] = args?.contactPoint;
resourceInputs["disableProvenance"] = args?.disableProvenance;
resourceInputs["groupBies"] = args?.groupBies;
resourceInputs["groupInterval"] = args?.groupInterval;
resourceInputs["groupWait"] = args?.groupWait;
resourceInputs["orgId"] = args?.orgId;
resourceInputs["policies"] = args?.policies;
resourceInputs["repeatInterval"] = args?.repeatInterval;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "grafana:index/notificationPolicy:NotificationPolicy" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
super(NotificationPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.NotificationPolicy = NotificationPolicy;
/** @internal */
NotificationPolicy.__pulumiType = 'grafana:alerting/notificationPolicy:NotificationPolicy';
//# sourceMappingURL=notificationPolicy.js.map