@lbrlabs/pulumi-grafana
Version:
A Pulumi package for creating and managing grafana.
174 lines • 6.08 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleGroup = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* 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}}
* ```
*/
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, id, state, opts) {
return new RuleGroup(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === RuleGroup.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["folderUid"] = state ? state.folderUid : undefined;
resourceInputs["intervalSeconds"] = state ? state.intervalSeconds : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["orgId"] = state ? state.orgId : undefined;
resourceInputs["rules"] = state ? state.rules : undefined;
}
else {
const args = argsOrState;
if ((!args || args.folderUid === undefined) && !opts.urn) {
throw new Error("Missing required property 'folderUid'");
}
if ((!args || args.intervalSeconds === undefined) && !opts.urn) {
throw new Error("Missing required property 'intervalSeconds'");
}
if ((!args || args.orgId === undefined) && !opts.urn) {
throw new Error("Missing required property 'orgId'");
}
if ((!args || args.rules === undefined) && !opts.urn) {
throw new Error("Missing required property 'rules'");
}
resourceInputs["folderUid"] = args ? args.folderUid : undefined;
resourceInputs["intervalSeconds"] = args ? args.intervalSeconds : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["orgId"] = args ? args.orgId : undefined;
resourceInputs["rules"] = args ? args.rules : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(RuleGroup.__pulumiType, name, resourceInputs, opts);
}
}
exports.RuleGroup = RuleGroup;
/** @internal */
RuleGroup.__pulumiType = 'grafana:index/ruleGroup:RuleGroup';
//# sourceMappingURL=ruleGroup.js.map