@pulumiverse/grafana
Version:
A Pulumi package for creating and managing grafana.
177 lines • 6.14 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.RuleGroup = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages Grafana Alerting rule groups.
*
* * Official documentation
* * [HTTP API](https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/api-legacy/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 "@pulumiverse/grafana";
*
* const ruleFolder = new grafana.oss.Folder("rule_folder", {title: "My Alert Rule Folder"});
* const myAlertRule = new grafana.alerting.RuleGroup("my_alert_rule", {
* name: "My Rule Group",
* 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
* terraform import grafana_rule_group.name "{{ folderUID }}:{{ title }}"
* terraform import grafana_rule_group.name "{{ orgID }}:{{ folderUID }}:{{ title }}"
* ```
*/
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, { ...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["disableProvenance"] = state?.disableProvenance;
resourceInputs["folderUid"] = state?.folderUid;
resourceInputs["intervalSeconds"] = state?.intervalSeconds;
resourceInputs["name"] = state?.name;
resourceInputs["orgId"] = state?.orgId;
resourceInputs["rules"] = state?.rules;
}
else {
const args = argsOrState;
if (args?.folderUid === undefined && !opts.urn) {
throw new Error("Missing required property 'folderUid'");
}
if (args?.intervalSeconds === undefined && !opts.urn) {
throw new Error("Missing required property 'intervalSeconds'");
}
if (args?.rules === undefined && !opts.urn) {
throw new Error("Missing required property 'rules'");
}
resourceInputs["disableProvenance"] = args?.disableProvenance;
resourceInputs["folderUid"] = args?.folderUid;
resourceInputs["intervalSeconds"] = args?.intervalSeconds;
resourceInputs["name"] = args?.name;
resourceInputs["orgId"] = args?.orgId;
resourceInputs["rules"] = args?.rules;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "grafana:index/ruleGroup:RuleGroup" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
super(RuleGroup.__pulumiType, name, resourceInputs, opts);
}
}
exports.RuleGroup = RuleGroup;
/** @internal */
RuleGroup.__pulumiType = 'grafana:alerting/ruleGroup:RuleGroup';
//# sourceMappingURL=ruleGroup.js.map