UNPKG

@pulumiverse/grafana

Version:

A Pulumi package for creating and managing grafana.

301 lines 11.2 kB
"use strict"; // *** 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.SLO = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * Resource manages Grafana SLOs. * * * [Official documentation](https://grafana.com/docs/grafana-cloud/alerting-and-irm/slo/) * * [API documentation](https://grafana.com/docs/grafana-cloud/alerting-and-irm/slo/api/) * * [Additional Information On Alerting Rule Annotations and Labels](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/#templating/) * * ## Example Usage * * ### Ratio * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as grafana from "@pulumiverse/grafana"; * * const ratio = new grafana.slo.SLO("ratio", { * name: "Terraform Testing - Ratio Query", * description: "Terraform Description - Ratio Query", * queries: [{ * ratio: { * successMetric: "kubelet_http_requests_total{status!~\"5..\"}", * totalMetric: "kubelet_http_requests_total", * groupByLabels: [ * "job", * "instance", * ], * }, * type: "ratio", * }], * objectives: [{ * value: 0.995, * window: "30d", * }], * destinationDatasource: { * uid: "grafanacloud-prom", * }, * labels: [{ * key: "slo", * value: "terraform", * }], * alertings: [{ * fastburns: [{ * annotations: [ * { * key: "name", * value: "SLO Burn Rate Very High", * }, * { * key: "description", * value: "Error budget is burning too fast", * }, * ], * }], * slowburns: [{ * annotations: [ * { * key: "name", * value: "SLO Burn Rate High", * }, * { * key: "description", * value: "Error budget is burning too fast", * }, * ], * }], * }], * }); * ``` * * ### Advanced * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as grafana from "@pulumiverse/grafana"; * * const test = new grafana.slo.SLO("test", { * name: "Terraform Testing", * description: "Terraform Description", * queries: [{ * freeform: { * query: "sum(rate(apiserver_request_total{code!=\"500\"}[$__rate_interval])) / sum(rate(apiserver_request_total[$__rate_interval]))", * }, * type: "freeform", * }], * objectives: [{ * value: 0.995, * window: "30d", * }], * destinationDatasource: { * uid: "grafanacloud-prom", * }, * labels: [{ * key: "slo", * value: "terraform", * }], * alertings: [{ * fastburns: [{ * annotations: [ * { * key: "name", * value: "SLO Burn Rate Very High", * }, * { * key: "description", * value: "Error budget is burning too fast", * }, * ], * }], * slowburns: [{ * annotations: [ * { * key: "name", * value: "SLO Burn Rate High", * }, * { * key: "description", * value: "Error budget is burning too fast", * }, * ], * }], * }], * }); * ``` * * ### Grafana Queries - Any supported datasource * * Grafana Queries use the grafanaQueries field. It expects a JSON string list of valid grafana query JSON objects, the same as you'll find assigned to a Grafana Dashboard panel `targets` field. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as grafana from "@pulumiverse/grafana"; * * const test = new grafana.slo.SLO("test", { * name: "Terraform Testing", * description: "Terraform Description", * queries: [{ * grafanaQueries: { * grafanaQueries: JSON.stringify([ * { * datasource: { * type: "graphite", * uid: "datasource-uid", * }, * refId: "Success", * target: "groupByNode(perSecond(web.*.http.2xx_success.*.*), 3, 'avg')", * }, * { * datasource: { * type: "graphite", * uid: "datasource-uid", * }, * refId: "Total", * target: "groupByNode(perSecond(web.*.http.5xx_errors.*.*), 3, 'avg')", * }, * { * datasource: { * type: "__expr__", * uid: "__expr__", * }, * expression: "$Success / $Total", * refId: "Expression", * type: "math", * }, * ]), * }, * type: "grafana_queries", * }], * destinationDatasource: { * uid: "grafanacloud-prom", * }, * objectives: [{ * value: 0.995, * window: "30d", * }], * labels: [{ * key: "slo", * value: "terraform", * }], * alertings: [{ * fastburns: [{ * annotations: [ * { * key: "name", * value: "SLO Burn Rate Very High", * }, * { * key: "description", * value: "Error budget is burning too fast", * }, * ], * }], * slowburns: [{ * annotations: [ * { * key: "name", * value: "SLO Burn Rate High", * }, * { * key: "description", * value: "Error budget is burning too fast", * }, * ], * }], * }], * }); * ``` * * For a complete list, see [supported data sources](https://grafana.com/docs/grafana-cloud/alerting-and-irm/slo/set-up/additionaldatasources/#supported-data-sources). * * For additional help with SLOs, view our [documentation](https://grafana.com/docs/grafana-cloud/alerting-and-irm/slo/). * * ## Import * * ```sh * $ pulumi import grafana:index/sLO:SLO name "{{ uuid }}" * ``` * * @deprecated grafana.index/slo.SLO has been deprecated in favor of grafana.slo/slo.SLO */ class SLO extends pulumi.CustomResource { /** * Get an existing SLO 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) { pulumi.log.warn("SLO is deprecated: grafana.index/slo.SLO has been deprecated in favor of grafana.slo/slo.SLO"); return new SLO(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of SLO. 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'] === SLO.__pulumiType; } /** @deprecated grafana.index/slo.SLO has been deprecated in favor of grafana.slo/slo.SLO */ constructor(name, argsOrState, opts) { pulumi.log.warn("SLO is deprecated: grafana.index/slo.SLO has been deprecated in favor of grafana.slo/slo.SLO"); let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["alertings"] = state ? state.alertings : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["destinationDatasource"] = state ? state.destinationDatasource : undefined; resourceInputs["folderUid"] = state ? state.folderUid : undefined; resourceInputs["labels"] = state ? state.labels : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["objectives"] = state ? state.objectives : undefined; resourceInputs["queries"] = state ? state.queries : undefined; resourceInputs["searchExpression"] = state ? state.searchExpression : undefined; } else { const args = argsOrState; if ((!args || args.description === undefined) && !opts.urn) { throw new Error("Missing required property 'description'"); } if ((!args || args.destinationDatasource === undefined) && !opts.urn) { throw new Error("Missing required property 'destinationDatasource'"); } if ((!args || args.objectives === undefined) && !opts.urn) { throw new Error("Missing required property 'objectives'"); } if ((!args || args.queries === undefined) && !opts.urn) { throw new Error("Missing required property 'queries'"); } resourceInputs["alertings"] = args ? args.alertings : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["destinationDatasource"] = args ? args.destinationDatasource : undefined; resourceInputs["folderUid"] = args ? args.folderUid : undefined; resourceInputs["labels"] = args ? args.labels : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["objectives"] = args ? args.objectives : undefined; resourceInputs["queries"] = args ? args.queries : undefined; resourceInputs["searchExpression"] = args ? args.searchExpression : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const aliasOpts = { aliases: [{ type: "grafana:index/sLO:SLO" }] }; opts = pulumi.mergeOptions(opts, aliasOpts); super(SLO.__pulumiType, name, resourceInputs, opts); } } exports.SLO = SLO; /** @internal */ SLO.__pulumiType = 'grafana:index/sLO:SLO'; //# sourceMappingURL=slo.js.map