PrometheusRuleGroup

class PrometheusRuleGroup : KotlinCustomResource

The Prometheus rule group resource. Uses Azure REST API version 2023-03-01. In version 2.x of the Azure Native provider, it used API version 2023-03-01. Other available API versions: 2021-07-22-preview. These can be accessed by generating a local SDK package using the CLI command pulumi package add azure-native alertsmanagement [ApiVersion]. See the ../../../version-guide/#accessing-any-api-version-via-local-packages for details.

Example Usage

Create or Update a PrometheusRuleGroup

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var prometheusRuleGroup = new AzureNative.AlertsManagement.PrometheusRuleGroup("prometheusRuleGroup", new()
{
ClusterName = "myClusterName",
Description = "This is the description of the following rule group",
Enabled = true,
Interval = "PT10M",
Location = "East US",
ResourceGroupName = "promResourceGroup",
RuleGroupName = "myPrometheusRuleGroup",
Rules = new[]
{
new AzureNative.AlertsManagement.Inputs.PrometheusRuleArgs
{
Expression = "histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))",
Labels =
{
{ "team", "prod" },
},
Record = "job_type:billing_jobs_duration_seconds:99p5m",
},
new AzureNative.AlertsManagement.Inputs.PrometheusRuleArgs
{
Actions = new[]
{
new AzureNative.AlertsManagement.Inputs.PrometheusRuleGroupActionArgs
{
ActionGroupId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myactiongroup",
ActionProperties =
{
{ "key11", "value11" },
{ "key12", "value12" },
},
},
new AzureNative.AlertsManagement.Inputs.PrometheusRuleGroupActionArgs
{
ActionGroupId = "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myotheractiongroup",
ActionProperties =
{
{ "key21", "value21" },
{ "key22", "value22" },
},
},
},
Alert = "Billing_Processing_Very_Slow",
Annotations =
{
{ "annotationName1", "annotationValue1" },
},
Enabled = true,
Expression = "job_type:billing_jobs_duration_seconds:99p5m 30",
For = "PT5M",
Labels =
{
{ "team", "prod" },
},
ResolveConfiguration = new AzureNative.AlertsManagement.Inputs.PrometheusRuleResolveConfigurationArgs
{
AutoResolved = true,
TimeToResolve = "PT10M",
},
Severity = 2,
},
},
Scopes = new[]
{
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace",
},
});
});
package main
import (
alertsmanagement "github.com/pulumi/pulumi-azure-native-sdk/alertsmanagement/v2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := alertsmanagement.NewPrometheusRuleGroup(ctx, "prometheusRuleGroup", &alertsmanagement.PrometheusRuleGroupArgs{
ClusterName: pulumi.String("myClusterName"),
Description: pulumi.String("This is the description of the following rule group"),
Enabled: pulumi.Bool(true),
Interval: pulumi.String("PT10M"),
Location: pulumi.String("East US"),
ResourceGroupName: pulumi.String("promResourceGroup"),
RuleGroupName: pulumi.String("myPrometheusRuleGroup"),
Rules: alertsmanagement.PrometheusRuleArray{
&alertsmanagement.PrometheusRuleArgs{
Expression: pulumi.String("histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))"),
Labels: pulumi.StringMap{
"team": pulumi.String("prod"),
},
Record: pulumi.String("job_type:billing_jobs_duration_seconds:99p5m"),
},
&alertsmanagement.PrometheusRuleArgs{
Actions: alertsmanagement.PrometheusRuleGroupActionArray{
&alertsmanagement.PrometheusRuleGroupActionArgs{
ActionGroupId: pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myactiongroup"),
ActionProperties: pulumi.StringMap{
"key11": pulumi.String("value11"),
"key12": pulumi.String("value12"),
},
},
&alertsmanagement.PrometheusRuleGroupActionArgs{
ActionGroupId: pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myotheractiongroup"),
ActionProperties: pulumi.StringMap{
"key21": pulumi.String("value21"),
"key22": pulumi.String("value22"),
},
},
},
Alert: pulumi.String("Billing_Processing_Very_Slow"),
Annotations: pulumi.StringMap{
"annotationName1": pulumi.String("annotationValue1"),
},
Enabled: pulumi.Bool(true),
Expression: pulumi.String("job_type:billing_jobs_duration_seconds:99p5m 30"),
For: pulumi.String("PT5M"),
Labels: pulumi.StringMap{
"team": pulumi.String("prod"),
},
ResolveConfiguration: &alertsmanagement.PrometheusRuleResolveConfigurationArgs{
AutoResolved: pulumi.Bool(true),
TimeToResolve: pulumi.String("PT10M"),
},
Severity: pulumi.Int(2),
},
},
Scopes: pulumi.StringArray{
pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"),
},
})
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.azurenative.alertsmanagement.PrometheusRuleGroup;
import com.pulumi.azurenative.alertsmanagement.PrometheusRuleGroupArgs;
import com.pulumi.azurenative.alertsmanagement.inputs.PrometheusRuleArgs;
import com.pulumi.azurenative.alertsmanagement.inputs.PrometheusRuleResolveConfigurationArgs;
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 prometheusRuleGroup = new PrometheusRuleGroup("prometheusRuleGroup", PrometheusRuleGroupArgs.builder()
.clusterName("myClusterName")
.description("This is the description of the following rule group")
.enabled(true)
.interval("PT10M")
.location("East US")
.resourceGroupName("promResourceGroup")
.ruleGroupName("myPrometheusRuleGroup")
.rules(
PrometheusRuleArgs.builder()
.expression("histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))")
.labels(Map.of("team", "prod"))
.record("job_type:billing_jobs_duration_seconds:99p5m")
.build(),
PrometheusRuleArgs.builder()
.actions(
PrometheusRuleGroupActionArgs.builder()
.actionGroupId("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myactiongroup")
.actionProperties(Map.ofEntries(
Map.entry("key11", "value11"),
Map.entry("key12", "value12")
))
.build(),
PrometheusRuleGroupActionArgs.builder()
.actionGroupId("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myotheractiongroup")
.actionProperties(Map.ofEntries(
Map.entry("key21", "value21"),
Map.entry("key22", "value22")
))
.build())
.alert("Billing_Processing_Very_Slow")
.annotations(Map.of("annotationName1", "annotationValue1"))
.enabled(true)
.expression("job_type:billing_jobs_duration_seconds:99p5m 30")
.for_("PT5M")
.labels(Map.of("team", "prod"))
.resolveConfiguration(PrometheusRuleResolveConfigurationArgs.builder()
.autoResolved(true)
.timeToResolve("PT10M")
.build())
.severity(2)
.build())
.scopes("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace")
.build());
}
}

Create or Update a cluster centric PrometheusRuleGroup

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var prometheusRuleGroup = new AzureNative.AlertsManagement.PrometheusRuleGroup("prometheusRuleGroup", new()
{
ClusterName = "myClusterName",
Description = "This is a rule group with culster centric configuration",
Interval = "PT10M",
Location = "East US",
ResourceGroupName = "promResourceGroup",
RuleGroupName = "myPrometheusRuleGroup",
Rules = new[]
{
new AzureNative.AlertsManagement.Inputs.PrometheusRuleArgs
{
Actions = new() { },
Alert = "Billing_Processing_Very_Slow",
Annotations =
{
{ "annotationName1", "annotationValue1" },
},
Enabled = true,
Expression = "job_type:billing_jobs_duration_seconds:99p5m 30",
For = "PT5M",
Labels =
{
{ "team", "prod" },
},
ResolveConfiguration = new AzureNative.AlertsManagement.Inputs.PrometheusRuleResolveConfigurationArgs
{
AutoResolved = true,
TimeToResolve = "PT10M",
},
Severity = 2,
},
},
Scopes = new[]
{
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace",
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myClusterName",
},
});
});
package main
import (
alertsmanagement "github.com/pulumi/pulumi-azure-native-sdk/alertsmanagement/v2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := alertsmanagement.NewPrometheusRuleGroup(ctx, "prometheusRuleGroup", &alertsmanagement.PrometheusRuleGroupArgs{
ClusterName: pulumi.String("myClusterName"),
Description: pulumi.String("This is a rule group with culster centric configuration"),
Interval: pulumi.String("PT10M"),
Location: pulumi.String("East US"),
ResourceGroupName: pulumi.String("promResourceGroup"),
RuleGroupName: pulumi.String("myPrometheusRuleGroup"),
Rules: alertsmanagement.PrometheusRuleArray{
&alertsmanagement.PrometheusRuleArgs{
Actions: alertsmanagement.PrometheusRuleGroupActionArray{},
Alert: pulumi.String("Billing_Processing_Very_Slow"),
Annotations: pulumi.StringMap{
"annotationName1": pulumi.String("annotationValue1"),
},
Enabled: pulumi.Bool(true),
Expression: pulumi.String("job_type:billing_jobs_duration_seconds:99p5m 30"),
For: pulumi.String("PT5M"),
Labels: pulumi.StringMap{
"team": pulumi.String("prod"),
},
ResolveConfiguration: &alertsmanagement.PrometheusRuleResolveConfigurationArgs{
AutoResolved: pulumi.Bool(true),
TimeToResolve: pulumi.String("PT10M"),
},
Severity: pulumi.Int(2),
},
},
Scopes: pulumi.StringArray{
pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"),
pulumi.String("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myClusterName"),
},
})
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.azurenative.alertsmanagement.PrometheusRuleGroup;
import com.pulumi.azurenative.alertsmanagement.PrometheusRuleGroupArgs;
import com.pulumi.azurenative.alertsmanagement.inputs.PrometheusRuleArgs;
import com.pulumi.azurenative.alertsmanagement.inputs.PrometheusRuleResolveConfigurationArgs;
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 prometheusRuleGroup = new PrometheusRuleGroup("prometheusRuleGroup", PrometheusRuleGroupArgs.builder()
.clusterName("myClusterName")
.description("This is a rule group with culster centric configuration")
.interval("PT10M")
.location("East US")
.resourceGroupName("promResourceGroup")
.ruleGroupName("myPrometheusRuleGroup")
.rules(PrometheusRuleArgs.builder()
.actions()
.alert("Billing_Processing_Very_Slow")
.annotations(Map.of("annotationName1", "annotationValue1"))
.enabled(true)
.expression("job_type:billing_jobs_duration_seconds:99p5m 30")
.for_("PT5M")
.labels(Map.of("team", "prod"))
.resolveConfiguration(PrometheusRuleResolveConfigurationArgs.builder()
.autoResolved(true)
.timeToResolve("PT10M")
.build())
.severity(2)
.build())
.scopes(
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace",
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myClusterName")
.build());
}
}

Import

An existing resource can be imported using its type token, name, and identifier, e.g.

$ pulumi import azure-native:alertsmanagement:PrometheusRuleGroup myresource1 /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/prometheusRuleGroups/{ruleGroupName}

Properties

Link copied to clipboard
val azureApiVersion: Output<String>

The Azure API version of the resource.

Link copied to clipboard
val clusterName: Output<String>?

Apply rule to data from a specific cluster.

Link copied to clipboard
val description: Output<String>?

Rule group description.

Link copied to clipboard
val enabled: Output<Boolean>?

Enable/disable rule group.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val interval: Output<String>?

The interval in which to run the Prometheus rule group represented in ISO 8601 duration format. Should be between 1 and 15 minutes

Link copied to clipboard
val location: Output<String>

The geo-location where the resource lives

Link copied to clipboard
val name: Output<String>

The name of the resource

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Defines the rules in the Prometheus rule group.

Link copied to clipboard
val scopes: Output<List<String>>

Target Azure Monitor workspaces resource ids. This api-version is currently limited to creating with one scope. This may change in future.

Link copied to clipboard

Azure Resource Manager metadata containing createdBy and modifiedBy information.

Link copied to clipboard
val tags: Output<Map<String, String>>?

Resource tags.

Link copied to clipboard
val type: Output<String>

The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"

Link copied to clipboard
val urn: Output<String>