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)
.to(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<Grafana
Alert Rule Data> - Folder
Uid string - For string
- Rule
Group string - Title string
- Annotations Dictionary<string, string>
- Grafana
Alert stringRule Id - Is
Paused bool - Labels Dictionary<string, string>
- No
Data stringState
- Condition string
- Datas
[]Grafana
Alert Rule Data Args - Folder
Uid string - For string
- Rule
Group string - Title string
- Annotations map[string]string
- Grafana
Alert stringRule Id - Is
Paused bool - Labels map[string]string
- No
Data stringState
- condition String
- datas
List<Grafana
Alert Rule Data> - folder
Uid String - for_ String
- rule
Group String - title String
- annotations Map<String,String>
- grafana
Alert StringRule Id - is
Paused Boolean - labels Map<String,String>
- no
Data StringState
- condition string
- datas
Grafana
Alert Rule Data[] - folder
Uid string - for string
- rule
Group string - title string
- annotations {[key: string]: string}
- grafana
Alert stringRule Id - is
Paused boolean - labels {[key: string]: string}
- no
Data stringState
- condition str
- datas
Sequence[Grafana
Alert 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>
- folder
Uid String - for String
- rule
Group String - title String
- annotations Map<String>
- grafana
Alert StringRule Id - is
Paused Boolean - labels Map<String>
- no
Data StringState
Outputs
All input properties are implicitly available as output properties. Additionally, the GrafanaAlertRule resource produces the following output properties:
- Alert
Rule doubleId - Exec
Err stringState - Id string
- The provider-assigned unique ID for this managed resource.
- Uid string
- Alert
Rule float64Id - Exec
Err stringState - Id string
- The provider-assigned unique ID for this managed resource.
- Uid string
- alert
Rule DoubleId - exec
Err StringState - id String
- The provider-assigned unique ID for this managed resource.
- uid String
- alert
Rule numberId - exec
Err 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
- alert
Rule NumberId - exec
Err 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) -> GrafanaAlertRule
func 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.
- Alert
Rule doubleId - Annotations Dictionary<string, string>
- Condition string
- Datas
List<Grafana
Alert Rule Data> - Exec
Err stringState - Folder
Uid string - For string
- Grafana
Alert stringRule Id - Is
Paused bool - Labels Dictionary<string, string>
- No
Data stringState - Rule
Group string - Title string
- Uid string
- Alert
Rule float64Id - Annotations map[string]string
- Condition string
- Datas
[]Grafana
Alert Rule Data Args - Exec
Err stringState - Folder
Uid string - For string
- Grafana
Alert stringRule Id - Is
Paused bool - Labels map[string]string
- No
Data stringState - Rule
Group string - Title string
- Uid string
- alert
Rule DoubleId - annotations Map<String,String>
- condition String
- datas
List<Grafana
Alert Rule Data> - exec
Err StringState - folder
Uid String - for_ String
- grafana
Alert StringRule Id - is
Paused Boolean - labels Map<String,String>
- no
Data StringState - rule
Group String - title String
- uid String
- alert
Rule numberId - annotations {[key: string]: string}
- condition string
- datas
Grafana
Alert Rule Data[] - exec
Err stringState - folder
Uid string - for string
- grafana
Alert stringRule Id - is
Paused boolean - labels {[key: string]: string}
- no
Data stringState - rule
Group string - title string
- uid string
- alert_
rule_ floatid - annotations Mapping[str, str]
- condition str
- datas
Sequence[Grafana
Alert 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
- alert
Rule NumberId - annotations Map<String>
- condition String
- datas List<Property Map>
- exec
Err StringState - folder
Uid String - for String
- grafana
Alert StringRule Id - is
Paused Boolean - labels Map<String>
- no
Data StringState - rule
Group String - title String
- uid String
Supporting Types
GrafanaAlertRuleData, GrafanaAlertRuleDataArgs
- Datasource
Uid 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.
- Ref
Id string - 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 string - An optional identifier for the type of query being executed.
- Datasource
Uid 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.
- Ref
Id string - 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 string - An optional identifier for the type of query being executed.
- datasource
Uid 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.
- ref
Id String - 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 String - An optional identifier for the type of query being executed.
- datasource
Uid 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.
- ref
Id string - 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 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.
- datasource
Uid 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.
- ref
Id String - A unique string to identify this query stage within a rule.
- relative
Time Property MapRange - The time range, relative to when the query is executed, across which to query. See below for nested schema.
- query
Type 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
logzio
Terraform Provider.