logzio.GrafanaAlertRule
Explore with Pulumi AI
# Grafana Alert Rule Resource
Provides a Logz.io Grafana alert rule resource. This can be used to create and manage Grafana alert rules in Logz.io.
- Learn more about Logz.io’s Grafana alert rule API in Logz.io Docs.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as logzio from "@pulumi/logzio";
const testGrafanaAlert = new logzio.GrafanaAlertRule("testGrafanaAlert", {
    annotations: {
        foo: "bar",
        hello: "world",
    },
    condition: "A",
    datas: [{
        refId: "B",
        datasourceUid: "AB1C234567D89012E",
        queryType: "",
        model: JSON.stringify({
            hide: false,
            refId: "B",
        }),
        relativeTimeRange: {
            from: 700,
            to: 0,
        },
    }],
    labels: {
        hey: "oh",
        lets: "go",
    },
    isPaused: false,
    folderUid: "my-folder-uid",
    "for": "3m",
    noDataState: "OK",
    ruleGroup: "rule_group_1",
    title: "my_grafana_alert",
});
import pulumi
import json
import pulumi_logzio as logzio
test_grafana_alert = logzio.GrafanaAlertRule("testGrafanaAlert",
    annotations={
        "foo": "bar",
        "hello": "world",
    },
    condition="A",
    datas=[{
        "ref_id": "B",
        "datasource_uid": "AB1C234567D89012E",
        "query_type": "",
        "model": json.dumps({
            "hide": False,
            "refId": "B",
        }),
        "relative_time_range": {
            "from_": 700,
            "to": 0,
        },
    }],
    labels={
        "hey": "oh",
        "lets": "go",
    },
    is_paused=False,
    folder_uid="my-folder-uid",
    for_="3m",
    no_data_state="OK",
    rule_group="rule_group_1",
    title="my_grafana_alert")
package main
import (
	"encoding/json"
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/logzio/logzio"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"hide":  false,
			"refId": "B",
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = logzio.NewGrafanaAlertRule(ctx, "testGrafanaAlert", &logzio.GrafanaAlertRuleArgs{
			Annotations: pulumi.StringMap{
				"foo":   pulumi.String("bar"),
				"hello": pulumi.String("world"),
			},
			Condition: pulumi.String("A"),
			Datas: logzio.GrafanaAlertRuleDataArray{
				&logzio.GrafanaAlertRuleDataArgs{
					RefId:         pulumi.String("B"),
					DatasourceUid: pulumi.String("AB1C234567D89012E"),
					QueryType:     pulumi.String(""),
					Model:         pulumi.String(json0),
					RelativeTimeRange: &logzio.GrafanaAlertRuleDataRelativeTimeRangeArgs{
						From: pulumi.Float64(700),
						To:   pulumi.Float64(0),
					},
				},
			},
			Labels: pulumi.StringMap{
				"hey":  pulumi.String("oh"),
				"lets": pulumi.String("go"),
			},
			IsPaused:    pulumi.Bool(false),
			FolderUid:   pulumi.String("my-folder-uid"),
			For:         pulumi.String("3m"),
			NoDataState: pulumi.String("OK"),
			RuleGroup:   pulumi.String("rule_group_1"),
			Title:       pulumi.String("my_grafana_alert"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Logzio = Pulumi.Logzio;
return await Deployment.RunAsync(() => 
{
    var testGrafanaAlert = new Logzio.GrafanaAlertRule("testGrafanaAlert", new()
    {
        Annotations = 
        {
            { "foo", "bar" },
            { "hello", "world" },
        },
        Condition = "A",
        Datas = new[]
        {
            new Logzio.Inputs.GrafanaAlertRuleDataArgs
            {
                RefId = "B",
                DatasourceUid = "AB1C234567D89012E",
                QueryType = "",
                Model = JsonSerializer.Serialize(new Dictionary<string, object?>
                {
                    ["hide"] = false,
                    ["refId"] = "B",
                }),
                RelativeTimeRange = new Logzio.Inputs.GrafanaAlertRuleDataRelativeTimeRangeArgs
                {
                    From = 700,
                    To = 0,
                },
            },
        },
        Labels = 
        {
            { "hey", "oh" },
            { "lets", "go" },
        },
        IsPaused = false,
        FolderUid = "my-folder-uid",
        For = "3m",
        NoDataState = "OK",
        RuleGroup = "rule_group_1",
        Title = "my_grafana_alert",
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.logzio.GrafanaAlertRule;
import com.pulumi.logzio.GrafanaAlertRuleArgs;
import com.pulumi.logzio.inputs.GrafanaAlertRuleDataArgs;
import com.pulumi.logzio.inputs.GrafanaAlertRuleDataRelativeTimeRangeArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        var testGrafanaAlert = new GrafanaAlertRule("testGrafanaAlert", GrafanaAlertRuleArgs.builder()
            .annotations(Map.ofEntries(
                Map.entry("foo", "bar"),
                Map.entry("hello", "world")
            ))
            .condition("A")
            .datas(GrafanaAlertRuleDataArgs.builder()
                .refId("B")
                .datasourceUid("AB1C234567D89012E")
                .queryType("")
                .model(serializeJson(
                    jsonObject(
                        jsonProperty("hide", false),
                        jsonProperty("refId", "B")
                    )))
                .relativeTimeRange(GrafanaAlertRuleDataRelativeTimeRangeArgs.builder()
                    .from(700)
                    .to(0)
                    .build())
                .build())
            .labels(Map.ofEntries(
                Map.entry("hey", "oh"),
                Map.entry("lets", "go")
            ))
            .isPaused(false)
            .folderUid("my-folder-uid")
            .for_("3m")
            .noDataState("OK")
            .ruleGroup("rule_group_1")
            .title("my_grafana_alert")
            .build());
    }
}
resources:
  testGrafanaAlert:
    type: logzio:GrafanaAlertRule
    properties:
      annotations:
        foo: bar
        hello: world
      condition: A
      datas:
        - refId: B
          datasourceUid: AB1C234567D89012E
          queryType: ""
          model:
            fn::toJSON:
              hide: false
              refId: B
          relativeTimeRange:
            from: 700
            to: 0
      labels:
        hey: oh
        lets: go
      isPaused: false
      folderUid: my-folder-uid
      for: 3m
      noDataState: OK
      ruleGroup: rule_group_1
      title: my_grafana_alert
Create GrafanaAlertRule Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new GrafanaAlertRule(name: string, args: GrafanaAlertRuleArgs, opts?: CustomResourceOptions);@overload
def GrafanaAlertRule(resource_name: str,
                     args: GrafanaAlertRuleArgs,
                     opts: Optional[ResourceOptions] = None)
@overload
def GrafanaAlertRule(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     condition: Optional[str] = None,
                     datas: Optional[Sequence[GrafanaAlertRuleDataArgs]] = None,
                     folder_uid: Optional[str] = None,
                     for_: Optional[str] = None,
                     rule_group: Optional[str] = None,
                     title: Optional[str] = None,
                     annotations: Optional[Mapping[str, str]] = None,
                     grafana_alert_rule_id: Optional[str] = None,
                     is_paused: Optional[bool] = None,
                     labels: Optional[Mapping[str, str]] = None,
                     no_data_state: Optional[str] = None)func NewGrafanaAlertRule(ctx *Context, name string, args GrafanaAlertRuleArgs, opts ...ResourceOption) (*GrafanaAlertRule, error)public GrafanaAlertRule(string name, GrafanaAlertRuleArgs args, CustomResourceOptions? opts = null)
public GrafanaAlertRule(String name, GrafanaAlertRuleArgs args)
public GrafanaAlertRule(String name, GrafanaAlertRuleArgs args, CustomResourceOptions options)
type: logzio:GrafanaAlertRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args GrafanaAlertRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args GrafanaAlertRuleArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args GrafanaAlertRuleArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args GrafanaAlertRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args GrafanaAlertRuleArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var grafanaAlertRuleResource = new Logzio.GrafanaAlertRule("grafanaAlertRuleResource", new()
{
    Condition = "string",
    Datas = new[]
    {
        new Logzio.Inputs.GrafanaAlertRuleDataArgs
        {
            DatasourceUid = "string",
            Model = "string",
            RefId = "string",
            RelativeTimeRange = new Logzio.Inputs.GrafanaAlertRuleDataRelativeTimeRangeArgs
            {
                From = 0,
                To = 0,
            },
            QueryType = "string",
        },
    },
    FolderUid = "string",
    For = "string",
    RuleGroup = "string",
    Title = "string",
    Annotations = 
    {
        { "string", "string" },
    },
    GrafanaAlertRuleId = "string",
    IsPaused = false,
    Labels = 
    {
        { "string", "string" },
    },
    NoDataState = "string",
});
example, err := logzio.NewGrafanaAlertRule(ctx, "grafanaAlertRuleResource", &logzio.GrafanaAlertRuleArgs{
	Condition: pulumi.String("string"),
	Datas: logzio.GrafanaAlertRuleDataArray{
		&logzio.GrafanaAlertRuleDataArgs{
			DatasourceUid: pulumi.String("string"),
			Model:         pulumi.String("string"),
			RefId:         pulumi.String("string"),
			RelativeTimeRange: &logzio.GrafanaAlertRuleDataRelativeTimeRangeArgs{
				From: pulumi.Float64(0),
				To:   pulumi.Float64(0),
			},
			QueryType: pulumi.String("string"),
		},
	},
	FolderUid: pulumi.String("string"),
	For:       pulumi.String("string"),
	RuleGroup: pulumi.String("string"),
	Title:     pulumi.String("string"),
	Annotations: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	GrafanaAlertRuleId: pulumi.String("string"),
	IsPaused:           pulumi.Bool(false),
	Labels: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	NoDataState: pulumi.String("string"),
})
var grafanaAlertRuleResource = new GrafanaAlertRule("grafanaAlertRuleResource", GrafanaAlertRuleArgs.builder()
    .condition("string")
    .datas(GrafanaAlertRuleDataArgs.builder()
        .datasourceUid("string")
        .model("string")
        .refId("string")
        .relativeTimeRange(GrafanaAlertRuleDataRelativeTimeRangeArgs.builder()
            .from(0.0)
            .to(0.0)
            .build())
        .queryType("string")
        .build())
    .folderUid("string")
    .for_("string")
    .ruleGroup("string")
    .title("string")
    .annotations(Map.of("string", "string"))
    .grafanaAlertRuleId("string")
    .isPaused(false)
    .labels(Map.of("string", "string"))
    .noDataState("string")
    .build());
grafana_alert_rule_resource = logzio.GrafanaAlertRule("grafanaAlertRuleResource",
    condition="string",
    datas=[{
        "datasource_uid": "string",
        "model": "string",
        "ref_id": "string",
        "relative_time_range": {
            "from_": 0,
            "to": 0,
        },
        "query_type": "string",
    }],
    folder_uid="string",
    for_="string",
    rule_group="string",
    title="string",
    annotations={
        "string": "string",
    },
    grafana_alert_rule_id="string",
    is_paused=False,
    labels={
        "string": "string",
    },
    no_data_state="string")
const grafanaAlertRuleResource = new logzio.GrafanaAlertRule("grafanaAlertRuleResource", {
    condition: "string",
    datas: [{
        datasourceUid: "string",
        model: "string",
        refId: "string",
        relativeTimeRange: {
            from: 0,
            to: 0,
        },
        queryType: "string",
    }],
    folderUid: "string",
    "for": "string",
    ruleGroup: "string",
    title: "string",
    annotations: {
        string: "string",
    },
    grafanaAlertRuleId: "string",
    isPaused: false,
    labels: {
        string: "string",
    },
    noDataState: "string",
});
type: logzio:GrafanaAlertRule
properties:
    annotations:
        string: string
    condition: string
    datas:
        - datasourceUid: string
          model: string
          queryType: string
          refId: string
          relativeTimeRange:
            from: 0
            to: 0
    folderUid: string
    for: string
    grafanaAlertRuleId: string
    isPaused: false
    labels:
        string: string
    noDataState: string
    ruleGroup: string
    title: string
GrafanaAlertRule Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The GrafanaAlertRule resource accepts the following input properties:
- Condition string
- Datas
List<GrafanaAlert Rule Data> 
- FolderUid string
- For string
- RuleGroup string
- Title string
- Annotations Dictionary<string, string>
- GrafanaAlert stringRule Id 
- IsPaused bool
- Labels Dictionary<string, string>
- NoData stringState 
- Condition string
- Datas
[]GrafanaAlert Rule Data Args 
- FolderUid string
- For string
- RuleGroup string
- Title string
- Annotations map[string]string
- GrafanaAlert stringRule Id 
- IsPaused bool
- Labels map[string]string
- NoData stringState 
- condition String
- datas
List<GrafanaAlert Rule Data> 
- folderUid String
- for_ String
- ruleGroup String
- title String
- annotations Map<String,String>
- grafanaAlert StringRule Id 
- isPaused Boolean
- labels Map<String,String>
- noData StringState 
- condition string
- datas
GrafanaAlert Rule Data[] 
- folderUid string
- for string
- ruleGroup string
- title string
- annotations {[key: string]: string}
- grafanaAlert stringRule Id 
- isPaused boolean
- labels {[key: string]: string}
- noData stringState 
- condition str
- datas
Sequence[GrafanaAlert Rule Data Args] 
- folder_uid str
- for_ str
- rule_group str
- title str
- annotations Mapping[str, str]
- grafana_alert_ strrule_ id 
- is_paused bool
- labels Mapping[str, str]
- no_data_ strstate 
- condition String
- datas List<Property Map>
- folderUid String
- for String
- ruleGroup String
- title String
- annotations Map<String>
- grafanaAlert StringRule Id 
- isPaused Boolean
- labels Map<String>
- noData StringState 
Outputs
All input properties are implicitly available as output properties. Additionally, the GrafanaAlertRule resource produces the following output properties:
- AlertRule doubleId 
- ExecErr stringState 
- Id string
- The provider-assigned unique ID for this managed resource.
- Uid string
- AlertRule float64Id 
- ExecErr stringState 
- Id string
- The provider-assigned unique ID for this managed resource.
- Uid string
- alertRule DoubleId 
- execErr StringState 
- id String
- The provider-assigned unique ID for this managed resource.
- uid String
- alertRule numberId 
- execErr stringState 
- id string
- The provider-assigned unique ID for this managed resource.
- uid string
- alert_rule_ floatid 
- exec_err_ strstate 
- id str
- The provider-assigned unique ID for this managed resource.
- uid str
- alertRule NumberId 
- execErr StringState 
- id String
- The provider-assigned unique ID for this managed resource.
- uid String
Look up Existing GrafanaAlertRule Resource
Get an existing GrafanaAlertRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: GrafanaAlertRuleState, opts?: CustomResourceOptions): GrafanaAlertRule@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        alert_rule_id: Optional[float] = None,
        annotations: Optional[Mapping[str, str]] = None,
        condition: Optional[str] = None,
        datas: Optional[Sequence[GrafanaAlertRuleDataArgs]] = None,
        exec_err_state: Optional[str] = None,
        folder_uid: Optional[str] = None,
        for_: Optional[str] = None,
        grafana_alert_rule_id: Optional[str] = None,
        is_paused: Optional[bool] = None,
        labels: Optional[Mapping[str, str]] = None,
        no_data_state: Optional[str] = None,
        rule_group: Optional[str] = None,
        title: Optional[str] = None,
        uid: Optional[str] = None) -> GrafanaAlertRulefunc GetGrafanaAlertRule(ctx *Context, name string, id IDInput, state *GrafanaAlertRuleState, opts ...ResourceOption) (*GrafanaAlertRule, error)public static GrafanaAlertRule Get(string name, Input<string> id, GrafanaAlertRuleState? state, CustomResourceOptions? opts = null)public static GrafanaAlertRule get(String name, Output<String> id, GrafanaAlertRuleState state, CustomResourceOptions options)resources:  _:    type: logzio:GrafanaAlertRule    get:      id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- AlertRule doubleId 
- Annotations Dictionary<string, string>
- Condition string
- Datas
List<GrafanaAlert Rule Data> 
- ExecErr stringState 
- FolderUid string
- For string
- GrafanaAlert stringRule Id 
- IsPaused bool
- Labels Dictionary<string, string>
- NoData stringState 
- RuleGroup string
- Title string
- Uid string
- AlertRule float64Id 
- Annotations map[string]string
- Condition string
- Datas
[]GrafanaAlert Rule Data Args 
- ExecErr stringState 
- FolderUid string
- For string
- GrafanaAlert stringRule Id 
- IsPaused bool
- Labels map[string]string
- NoData stringState 
- RuleGroup string
- Title string
- Uid string
- alertRule DoubleId 
- annotations Map<String,String>
- condition String
- datas
List<GrafanaAlert Rule Data> 
- execErr StringState 
- folderUid String
- for_ String
- grafanaAlert StringRule Id 
- isPaused Boolean
- labels Map<String,String>
- noData StringState 
- ruleGroup String
- title String
- uid String
- alertRule numberId 
- annotations {[key: string]: string}
- condition string
- datas
GrafanaAlert Rule Data[] 
- execErr stringState 
- folderUid string
- for string
- grafanaAlert stringRule Id 
- isPaused boolean
- labels {[key: string]: string}
- noData stringState 
- ruleGroup string
- title string
- uid string
- alert_rule_ floatid 
- annotations Mapping[str, str]
- condition str
- datas
Sequence[GrafanaAlert Rule Data Args] 
- exec_err_ strstate 
- folder_uid str
- for_ str
- grafana_alert_ strrule_ id 
- is_paused bool
- labels Mapping[str, str]
- no_data_ strstate 
- rule_group str
- title str
- uid str
- alertRule NumberId 
- annotations Map<String>
- condition String
- datas List<Property Map>
- execErr StringState 
- folderUid String
- for String
- grafanaAlert StringRule Id 
- isPaused Boolean
- labels Map<String>
- noData StringState 
- ruleGroup String
- title String
- uid String
Supporting Types
GrafanaAlertRuleData, GrafanaAlertRuleDataArgs        
- DatasourceUid string
- The UID of the datasource being queried, or "-100" if this stage is an expression stage.
- Model string
- Custom JSON data to send to the specified datasource when querying.
- RefId string
- A unique string to identify this query stage within a rule.
- RelativeTime GrafanaRange Alert Rule Data Relative Time Range 
- The time range, relative to when the query is executed, across which to query. See below for nested schema.
- QueryType string
- An optional identifier for the type of query being executed.
- DatasourceUid string
- The UID of the datasource being queried, or "-100" if this stage is an expression stage.
- Model string
- Custom JSON data to send to the specified datasource when querying.
- RefId string
- A unique string to identify this query stage within a rule.
- RelativeTime GrafanaRange Alert Rule Data Relative Time Range 
- The time range, relative to when the query is executed, across which to query. See below for nested schema.
- QueryType string
- An optional identifier for the type of query being executed.
- datasourceUid String
- The UID of the datasource being queried, or "-100" if this stage is an expression stage.
- model String
- Custom JSON data to send to the specified datasource when querying.
- refId String
- A unique string to identify this query stage within a rule.
- relativeTime GrafanaRange Alert Rule Data Relative Time Range 
- The time range, relative to when the query is executed, across which to query. See below for nested schema.
- queryType String
- An optional identifier for the type of query being executed.
- datasourceUid string
- The UID of the datasource being queried, or "-100" if this stage is an expression stage.
- model string
- Custom JSON data to send to the specified datasource when querying.
- refId string
- A unique string to identify this query stage within a rule.
- relativeTime GrafanaRange Alert Rule Data Relative Time Range 
- The time range, relative to when the query is executed, across which to query. See below for nested schema.
- queryType string
- An optional identifier for the type of query being executed.
- datasource_uid str
- The UID of the datasource being queried, or "-100" if this stage is an expression stage.
- model str
- Custom JSON data to send to the specified datasource when querying.
- ref_id str
- A unique string to identify this query stage within a rule.
- relative_time_ Grafanarange Alert Rule Data Relative Time Range 
- The time range, relative to when the query is executed, across which to query. See below for nested schema.
- query_type str
- An optional identifier for the type of query being executed.
- datasourceUid String
- The UID of the datasource being queried, or "-100" if this stage is an expression stage.
- model String
- Custom JSON data to send to the specified datasource when querying.
- refId String
- A unique string to identify this query stage within a rule.
- relativeTime Property MapRange 
- The time range, relative to when the query is executed, across which to query. See below for nested schema.
- queryType String
- An optional identifier for the type of query being executed.
GrafanaAlertRuleDataRelativeTimeRange, GrafanaAlertRuleDataRelativeTimeRangeArgs              
Package Details
- Repository
- logzio logzio/terraform-provider-logzio
- License
- Notes
- This Pulumi package is based on the logzioTerraform Provider.