@pulumiverse/grafana
Version:
A Pulumi package for creating and managing grafana.
295 lines • 10.2 kB
JavaScript
"use strict";
// *** 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.SLO = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Resource manages Grafana SLOs (Service Level Objectives).
*
* * [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",
* }],
* alerting: {
* fastburn: {
* annotations: [
* {
* key: "name",
* value: "SLO Burn Rate Very High",
* },
* {
* key: "description",
* value: "Error budget is burning too fast",
* },
* ],
* },
* slowburn: {
* 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",
* }],
* alerting: {
* fastburn: {
* annotations: [
* {
* key: "name",
* value: "SLO Burn Rate Very High",
* },
* {
* key: "description",
* value: "Error budget is burning too fast",
* },
* ],
* enrichments: [{
* type: "assistantInvestigation",
* }],
* },
* slowburn: {
* annotations: [
* {
* key: "name",
* value: "SLO Burn Rate High",
* },
* {
* key: "description",
* value: "Error budget is burning too fast",
* },
* ],
* enrichments: [{
* type: "assistantInvestigation",
* }],
* },
* },
* });
* ```
*
* ### 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",
* }],
* alerting: {
* fastburn: {
* annotations: [
* {
* key: "name",
* value: "SLO Burn Rate Very High",
* },
* {
* key: "description",
* value: "Error budget is burning too fast",
* },
* ],
* },
* slowburn: {
* 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
* terraform import grafana_slo.name "{{ uuid }}"
* ```
*/
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) {
return new SLO(name, state, { ...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;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["alerting"] = state?.alerting;
resourceInputs["description"] = state?.description;
resourceInputs["destinationDatasource"] = state?.destinationDatasource;
resourceInputs["folderUid"] = state?.folderUid;
resourceInputs["labels"] = state?.labels;
resourceInputs["name"] = state?.name;
resourceInputs["objectives"] = state?.objectives;
resourceInputs["queries"] = state?.queries;
resourceInputs["searchExpression"] = state?.searchExpression;
resourceInputs["uuid"] = state?.uuid;
}
else {
const args = argsOrState;
if (args?.description === undefined && !opts.urn) {
throw new Error("Missing required property 'description'");
}
resourceInputs["alerting"] = args?.alerting;
resourceInputs["description"] = args?.description;
resourceInputs["destinationDatasource"] = args?.destinationDatasource;
resourceInputs["folderUid"] = args?.folderUid;
resourceInputs["labels"] = args?.labels;
resourceInputs["name"] = args?.name;
resourceInputs["objectives"] = args?.objectives;
resourceInputs["queries"] = args?.queries;
resourceInputs["searchExpression"] = args?.searchExpression;
resourceInputs["uuid"] = args?.uuid;
}
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:slo/sLO:SLO';
//# sourceMappingURL=slo.js.map