PrometheusAlertRuleArgs

data class PrometheusAlertRuleArgs(val annotations: Output<List<PrometheusAlertRuleAnnotationArgs>>? = null, val clusterId: Output<String>? = null, val dispatchRuleId: Output<String>? = null, val duration: Output<String>? = null, val expression: Output<String>? = null, val labels: Output<List<PrometheusAlertRuleLabelArgs>>? = null, val message: Output<String>? = null, val notifyType: Output<String>? = null, val prometheusAlertRuleName: Output<String>? = null, val type: Output<String>? = null) : ConvertibleToJava<PrometheusAlertRuleArgs>

Provides a Application Real-Time Monitoring Service (ARMS) Prometheus Alert Rule resource. For information about Application Real-Time Monitoring Service (ARMS) Prometheus Alert Rule and how to use it, see What is Prometheus Alert Rule.

NOTE: Available since v1.136.0.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
import * as random from "@pulumi/random";
const config = new pulumi.Config();
const name = config.get("name") || "tf-example";
const _default = new random.index.Integer("default", {
min: 10000,
max: 99999,
});
const defaultPrometheus = new alicloud.arms.Prometheus("default", {
clusterType: "remote-write",
clusterName: `${name}-${_default.result}`,
grafanaInstanceId: "free",
});
const example = new alicloud.arms.PrometheusAlertRule("example", {
clusterId: defaultPrometheus.clusterId,
duration: "1",
expression: "node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10",
message: "node available memory is less than 10%",
prometheusAlertRuleName: name,
notifyType: "ALERT_MANAGER",
});
import pulumi
import pulumi_alicloud as alicloud
import pulumi_random as random
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "tf-example"
default = random.index.Integer("default",
min=10000,
max=99999)
default_prometheus = alicloud.arms.Prometheus("default",
cluster_type="remote-write",
cluster_name=f"{name}-{default['result']}",
grafana_instance_id="free")
example = alicloud.arms.PrometheusAlertRule("example",
cluster_id=default_prometheus.cluster_id,
duration="1",
expression="node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10",
message="node available memory is less than 10%",
prometheus_alert_rule_name=name,
notify_type="ALERT_MANAGER")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "tf-example";
var @default = new Random.Index.Integer("default", new()
{
Min = 10000,
Max = 99999,
});
var defaultPrometheus = new AliCloud.Arms.Prometheus("default", new()
{
ClusterType = "remote-write",
ClusterName = $"{name}-{@default.Result}",
GrafanaInstanceId = "free",
});
var example = new AliCloud.Arms.PrometheusAlertRule("example", new()
{
ClusterId = defaultPrometheus.ClusterId,
Duration = "1",
Expression = "node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10",
Message = "node available memory is less than 10%",
PrometheusAlertRuleName = name,
NotifyType = "ALERT_MANAGER",
});
});
package main
import (
"fmt"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/arms"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "tf-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
Min: 10000,
Max: 99999,
})
if err != nil {
return err
}
defaultPrometheus, err := arms.NewPrometheus(ctx, "default", &arms.PrometheusArgs{
ClusterType: pulumi.String("remote-write"),
ClusterName: pulumi.Sprintf("%v-%v", name, _default.Result),
GrafanaInstanceId: pulumi.String("free"),
})
if err != nil {
return err
}
_, err = arms.NewPrometheusAlertRule(ctx, "example", &arms.PrometheusAlertRuleArgs{
ClusterId: defaultPrometheus.ClusterId,
Duration: pulumi.String("1"),
Expression: pulumi.String("node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10"),
Message: pulumi.String("node available memory is less than 10%"),
PrometheusAlertRuleName: pulumi.String(name),
NotifyType: pulumi.String("ALERT_MANAGER"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.random.integer;
import com.pulumi.random.integerArgs;
import com.pulumi.alicloud.arms.Prometheus;
import com.pulumi.alicloud.arms.PrometheusArgs;
import com.pulumi.alicloud.arms.PrometheusAlertRule;
import com.pulumi.alicloud.arms.PrometheusAlertRuleArgs;
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) {
final var config = ctx.config();
final var name = config.get("name").orElse("tf-example");
var default_ = new Integer("default", IntegerArgs.builder()
.min(10000)
.max(99999)
.build());
var defaultPrometheus = new Prometheus("defaultPrometheus", PrometheusArgs.builder()
.clusterType("remote-write")
.clusterName(String.format("%s-%s", name,default_.result()))
.grafanaInstanceId("free")
.build());
var example = new PrometheusAlertRule("example", PrometheusAlertRuleArgs.builder()
.clusterId(defaultPrometheus.clusterId())
.duration("1")
.expression("node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10")
.message("node available memory is less than 10%")
.prometheusAlertRuleName(name)
.notifyType("ALERT_MANAGER")
.build());
}
}
configuration:
name:
type: string
default: tf-example
resources:
default:
type: random:integer
properties:
min: 10000
max: 99999
defaultPrometheus:
type: alicloud:arms:Prometheus
name: default
properties:
clusterType: remote-write
clusterName: ${name}-${default.result}
grafanaInstanceId: free
example:
type: alicloud:arms:PrometheusAlertRule
properties:
clusterId: ${defaultPrometheus.clusterId}
duration: 1
expression: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10
message: node available memory is less than 10%
prometheusAlertRuleName: ${name}
notifyType: ALERT_MANAGER

Import

Application Real-Time Monitoring Service (ARMS) Prometheus Alert Rule can be imported using the id, e.g.

$ pulumi import alicloud:arms/prometheusAlertRule:PrometheusAlertRule example <cluster_id>:<prometheus_alert_rule_id>

Constructors

Link copied to clipboard
constructor(annotations: Output<List<PrometheusAlertRuleAnnotationArgs>>? = null, clusterId: Output<String>? = null, dispatchRuleId: Output<String>? = null, duration: Output<String>? = null, expression: Output<String>? = null, labels: Output<List<PrometheusAlertRuleLabelArgs>>? = null, message: Output<String>? = null, notifyType: Output<String>? = null, prometheusAlertRuleName: Output<String>? = null, type: Output<String>? = null)

Properties

Link copied to clipboard

The annotations of the alert rule. See annotations below.

Link copied to clipboard
val clusterId: Output<String>? = null

The ID of the cluster.

Link copied to clipboard
val dispatchRuleId: Output<String>? = null

The ID of the notification policy. This parameter is required when the notify_type parameter is set to DISPATCH_RULE.

Link copied to clipboard
val duration: Output<String>? = null

The duration of the alert.

Link copied to clipboard
val expression: Output<String>? = null

The alert rule expression that follows the PromQL syntax.

Link copied to clipboard

The labels of the resource. See labels below.

Link copied to clipboard
val message: Output<String>? = null

The message of the alert notification.

Link copied to clipboard
val notifyType: Output<String>? = null

The method of sending the alert notification. Valid values: ALERT_MANAGER, DISPATCH_RULE.

Link copied to clipboard
val prometheusAlertRuleName: Output<String>? = null

The name of the resource.

Link copied to clipboard
val type: Output<String>? = null

The type of the alert rule.

Functions

Link copied to clipboard
open override fun toJava(): PrometheusAlertRuleArgs