UNPKG

@lbrlabs/pulumi-grafana

Version:

A Pulumi package for creating and managing grafana.

204 lines (203 loc) 6.32 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "./types/input"; import * as outputs from "./types/output"; /** * Manages Grafana Alerting rule groups. * * * [Official documentation](https://grafana.com/docs/grafana/latest/alerting/alerting-rules/) * * [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/#alert-rules) * * This resource requires Grafana 9.1.0 or later. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as grafana from "@lbrlabs/pulumi-grafana"; * * const ruleFolder = new grafana.Folder("ruleFolder", {title: "My Alert Rule Folder"}); * const myAlertRule = new grafana.RuleGroup("myAlertRule", { * folderUid: ruleFolder.uid, * intervalSeconds: 240, * orgId: "1", * rules: [{ * name: "My Alert Rule 1", * "for": "2m", * condition: "B", * noDataState: "NoData", * execErrState: "Alerting", * annotations: { * a: "b", * c: "d", * }, * labels: { * e: "f", * g: "h", * }, * isPaused: false, * datas: [ * { * refId: "A", * queryType: "", * relativeTimeRange: { * from: 600, * to: 0, * }, * datasourceUid: "PD8C576611E62080A", * model: JSON.stringify({ * hide: false, * intervalMs: 1000, * maxDataPoints: 43200, * refId: "A", * }), * }, * { * refId: "B", * queryType: "", * relativeTimeRange: { * from: 0, * to: 0, * }, * datasourceUid: "-100", * model: `{ * "conditions": [ * { * "evaluator": { * "params": [ * 3 * ], * "type": "gt" * }, * "operator": { * "type": "and" * }, * "query": { * "params": [ * "A" * ] * }, * "reducer": { * "params": [], * "type": "last" * }, * "type": "query" * } * ], * "datasource": { * "type": "__expr__", * "uid": "-100" * }, * "hide": false, * "intervalMs": 1000, * "maxDataPoints": 43200, * "refId": "B", * "type": "classic_conditions" * } * `, * }, * ], * }], * }); * ``` * * ## Import * * ```sh * $ pulumi import grafana:index/ruleGroup:RuleGroup rule_group_name {{folder_uid}};{{rule_group_name}} * ``` */ export declare class RuleGroup extends pulumi.CustomResource { /** * Get an existing RuleGroup 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?: RuleGroupState, opts?: pulumi.CustomResourceOptions): RuleGroup; /** * Returns true if the given object is an instance of RuleGroup. 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 RuleGroup; /** * The UID of the folder that the group belongs to. */ readonly folderUid: pulumi.Output<string>; /** * The interval, in seconds, at which all rules in the group are evaluated. If a group contains many rules, the rules are evaluated sequentially. */ readonly intervalSeconds: pulumi.Output<number>; /** * The name of the alert rule. */ readonly name: pulumi.Output<string>; /** * The ID of the org to which the group belongs. */ readonly orgId: pulumi.Output<string>; /** * The rules within the group. */ readonly rules: pulumi.Output<outputs.RuleGroupRule[]>; /** * Create a RuleGroup 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: RuleGroupArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering RuleGroup resources. */ export interface RuleGroupState { /** * The UID of the folder that the group belongs to. */ folderUid?: pulumi.Input<string>; /** * The interval, in seconds, at which all rules in the group are evaluated. If a group contains many rules, the rules are evaluated sequentially. */ intervalSeconds?: pulumi.Input<number>; /** * The name of the alert rule. */ name?: pulumi.Input<string>; /** * The ID of the org to which the group belongs. */ orgId?: pulumi.Input<string>; /** * The rules within the group. */ rules?: pulumi.Input<pulumi.Input<inputs.RuleGroupRule>[]>; } /** * The set of arguments for constructing a RuleGroup resource. */ export interface RuleGroupArgs { /** * The UID of the folder that the group belongs to. */ folderUid: pulumi.Input<string>; /** * The interval, in seconds, at which all rules in the group are evaluated. If a group contains many rules, the rules are evaluated sequentially. */ intervalSeconds: pulumi.Input<number>; /** * The name of the alert rule. */ name?: pulumi.Input<string>; /** * The ID of the org to which the group belongs. */ orgId: pulumi.Input<string>; /** * The rules within the group. */ rules: pulumi.Input<pulumi.Input<inputs.RuleGroupRule>[]>; }