@pulumiverse/grafana
Version:
A Pulumi package for creating and managing grafana.
238 lines (237 loc) • 9.16 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
/**
* 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 }}"
* ```
*/
export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: NotificationPolicyState, opts?: pulumi.CustomResourceOptions): NotificationPolicy;
/**
* 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: any): obj is NotificationPolicy;
/**
* The default contact point to route all unmatched notifications to.
*/
readonly contactPoint: pulumi.Output<string>;
/**
* Allow modifying the notification policy from other sources than Terraform or the Grafana API. Defaults to `false`.
*/
readonly disableProvenance: pulumi.Output<boolean | undefined>;
/**
* A list of alert labels to group alerts into notifications by. Use the special label `...` to group alerts by all labels, effectively disabling grouping.
*/
readonly groupBies: pulumi.Output<string[]>;
/**
* Minimum time interval between two notifications for the same group. Default is 5 minutes.
*/
readonly groupInterval: pulumi.Output<string | undefined>;
/**
* Time to wait to buffer alerts of the same group before sending a notification. Default is 30 seconds.
*/
readonly groupWait: pulumi.Output<string | undefined>;
/**
* The Organization ID. If not set, the Org ID defined in the provider block will be used.
*/
readonly orgId: pulumi.Output<string | undefined>;
/**
* Routing rules for specific label sets.
*/
readonly policies: pulumi.Output<outputs.alerting.NotificationPolicyPolicy[] | undefined>;
/**
* Minimum time interval for re-sending a notification if an alert is still firing. Default is 4 hours.
*/
readonly repeatInterval: pulumi.Output<string | undefined>;
/**
* Create a NotificationPolicy resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: NotificationPolicyArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering NotificationPolicy resources.
*/
export interface NotificationPolicyState {
/**
* The default contact point to route all unmatched notifications to.
*/
contactPoint?: pulumi.Input<string>;
/**
* Allow modifying the notification policy from other sources than Terraform or the Grafana API. Defaults to `false`.
*/
disableProvenance?: pulumi.Input<boolean>;
/**
* A list of alert labels to group alerts into notifications by. Use the special label `...` to group alerts by all labels, effectively disabling grouping.
*/
groupBies?: pulumi.Input<pulumi.Input<string>[]>;
/**
* Minimum time interval between two notifications for the same group. Default is 5 minutes.
*/
groupInterval?: pulumi.Input<string>;
/**
* Time to wait to buffer alerts of the same group before sending a notification. Default is 30 seconds.
*/
groupWait?: pulumi.Input<string>;
/**
* The Organization ID. If not set, the Org ID defined in the provider block will be used.
*/
orgId?: pulumi.Input<string>;
/**
* Routing rules for specific label sets.
*/
policies?: pulumi.Input<pulumi.Input<inputs.alerting.NotificationPolicyPolicy>[]>;
/**
* Minimum time interval for re-sending a notification if an alert is still firing. Default is 4 hours.
*/
repeatInterval?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a NotificationPolicy resource.
*/
export interface NotificationPolicyArgs {
/**
* The default contact point to route all unmatched notifications to.
*/
contactPoint: pulumi.Input<string>;
/**
* Allow modifying the notification policy from other sources than Terraform or the Grafana API. Defaults to `false`.
*/
disableProvenance?: pulumi.Input<boolean>;
/**
* A list of alert labels to group alerts into notifications by. Use the special label `...` to group alerts by all labels, effectively disabling grouping.
*/
groupBies: pulumi.Input<pulumi.Input<string>[]>;
/**
* Minimum time interval between two notifications for the same group. Default is 5 minutes.
*/
groupInterval?: pulumi.Input<string>;
/**
* Time to wait to buffer alerts of the same group before sending a notification. Default is 30 seconds.
*/
groupWait?: pulumi.Input<string>;
/**
* The Organization ID. If not set, the Org ID defined in the provider block will be used.
*/
orgId?: pulumi.Input<string>;
/**
* Routing rules for specific label sets.
*/
policies?: pulumi.Input<pulumi.Input<inputs.alerting.NotificationPolicyPolicy>[]>;
/**
* Minimum time interval for re-sending a notification if an alert is still firing. Default is 4 hours.
*/
repeatInterval?: pulumi.Input<string>;
}