@pulumiverse/grafana
Version:
A Pulumi package for creating and managing grafana.
376 lines (375 loc) • 14.6 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
/**
* 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:slo/sLO:SLO name "{{ uuid }}"
* ```
*/
export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: SLOState, opts?: pulumi.CustomResourceOptions): SLO;
/**
* 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: any): obj is SLO;
/**
* Configures the alerting rules that will be generated for each
* time window associated with the SLO. Grafana SLOs can generate
* alerts when the short-term error budget burn is very high, the
* long-term error budget burn rate is high, or when the remaining
* error budget is below a certain threshold. Annotations and Labels support templating.
*/
readonly alertings: pulumi.Output<outputs.slo.SLOAlerting[] | undefined>;
/**
* Description is a free-text field that can provide more context to an SLO.
*/
readonly description: pulumi.Output<string>;
/**
* Destination Datasource sets the datasource defined for an SLO
*/
readonly destinationDatasource: pulumi.Output<outputs.slo.SLODestinationDatasource>;
/**
* UID for the SLO folder
*/
readonly folderUid: pulumi.Output<string | undefined>;
/**
* Additional labels that will be attached to all metrics generated from the query. These labels are useful for grouping SLOs in dashboard views that you create by hand. Labels must adhere to Prometheus label name schema - "^[a-zA-Z*][a-zA-Z0-9*]*$"
*/
readonly labels: pulumi.Output<outputs.slo.SLOLabel[] | undefined>;
/**
* Name should be a short description of your indicator. Consider names like "API Availability"
*/
readonly name: pulumi.Output<string>;
/**
* Over each rolling time window, the remaining error budget will be calculated, and separate alerts can be generated for each time window based on the SLO burn rate or remaining error budget.
*/
readonly objectives: pulumi.Output<outputs.slo.SLOObjective[]>;
/**
* Query describes the indicator that will be measured against the objective. Freeform Query types are currently supported.
*/
readonly queries: pulumi.Output<outputs.slo.SLOQuery[]>;
/**
* The name of a search expression in Grafana Asserts. This is used in the SLO UI to open the Asserts RCA workbench and in alerts to link to the RCA workbench.
*/
readonly searchExpression: pulumi.Output<string | undefined>;
/**
* Create a SLO 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: SLOArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering SLO resources.
*/
export interface SLOState {
/**
* Configures the alerting rules that will be generated for each
* time window associated with the SLO. Grafana SLOs can generate
* alerts when the short-term error budget burn is very high, the
* long-term error budget burn rate is high, or when the remaining
* error budget is below a certain threshold. Annotations and Labels support templating.
*/
alertings?: pulumi.Input<pulumi.Input<inputs.slo.SLOAlerting>[]>;
/**
* Description is a free-text field that can provide more context to an SLO.
*/
description?: pulumi.Input<string>;
/**
* Destination Datasource sets the datasource defined for an SLO
*/
destinationDatasource?: pulumi.Input<inputs.slo.SLODestinationDatasource>;
/**
* UID for the SLO folder
*/
folderUid?: pulumi.Input<string>;
/**
* Additional labels that will be attached to all metrics generated from the query. These labels are useful for grouping SLOs in dashboard views that you create by hand. Labels must adhere to Prometheus label name schema - "^[a-zA-Z*][a-zA-Z0-9*]*$"
*/
labels?: pulumi.Input<pulumi.Input<inputs.slo.SLOLabel>[]>;
/**
* Name should be a short description of your indicator. Consider names like "API Availability"
*/
name?: pulumi.Input<string>;
/**
* Over each rolling time window, the remaining error budget will be calculated, and separate alerts can be generated for each time window based on the SLO burn rate or remaining error budget.
*/
objectives?: pulumi.Input<pulumi.Input<inputs.slo.SLOObjective>[]>;
/**
* Query describes the indicator that will be measured against the objective. Freeform Query types are currently supported.
*/
queries?: pulumi.Input<pulumi.Input<inputs.slo.SLOQuery>[]>;
/**
* The name of a search expression in Grafana Asserts. This is used in the SLO UI to open the Asserts RCA workbench and in alerts to link to the RCA workbench.
*/
searchExpression?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a SLO resource.
*/
export interface SLOArgs {
/**
* Configures the alerting rules that will be generated for each
* time window associated with the SLO. Grafana SLOs can generate
* alerts when the short-term error budget burn is very high, the
* long-term error budget burn rate is high, or when the remaining
* error budget is below a certain threshold. Annotations and Labels support templating.
*/
alertings?: pulumi.Input<pulumi.Input<inputs.slo.SLOAlerting>[]>;
/**
* Description is a free-text field that can provide more context to an SLO.
*/
description: pulumi.Input<string>;
/**
* Destination Datasource sets the datasource defined for an SLO
*/
destinationDatasource: pulumi.Input<inputs.slo.SLODestinationDatasource>;
/**
* UID for the SLO folder
*/
folderUid?: pulumi.Input<string>;
/**
* Additional labels that will be attached to all metrics generated from the query. These labels are useful for grouping SLOs in dashboard views that you create by hand. Labels must adhere to Prometheus label name schema - "^[a-zA-Z*][a-zA-Z0-9*]*$"
*/
labels?: pulumi.Input<pulumi.Input<inputs.slo.SLOLabel>[]>;
/**
* Name should be a short description of your indicator. Consider names like "API Availability"
*/
name?: pulumi.Input<string>;
/**
* Over each rolling time window, the remaining error budget will be calculated, and separate alerts can be generated for each time window based on the SLO burn rate or remaining error budget.
*/
objectives: pulumi.Input<pulumi.Input<inputs.slo.SLOObjective>[]>;
/**
* Query describes the indicator that will be measured against the objective. Freeform Query types are currently supported.
*/
queries: pulumi.Input<pulumi.Input<inputs.slo.SLOQuery>[]>;
/**
* The name of a search expression in Grafana Asserts. This is used in the SLO UI to open the Asserts RCA workbench and in alerts to link to the RCA workbench.
*/
searchExpression?: pulumi.Input<string>;
}