Query Args
A Log Analytics QueryPack-Query definition. Uses Azure REST API version 2023-09-01. In version 2.x of the Azure Native provider, it used API version 2019-09-01. Other available API versions: 2019-09-01, 2019-09-01-preview, 2025-02-01. These can be accessed by generating a local SDK package using the CLI command pulumi package add azure-native operationalinsights [ApiVersion]
. See the ../../../version-guide/#accessing-any-api-version-via-local-packages for details.
Example Usage
QueryPut
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var query = new AzureNative.OperationalInsights.Query("query", new()
{
Body = @"let newExceptionsTimeRange = 1d;
let timeRangeToCheckBefore = 7d;
exceptions
| where timestamp < ago(timeRangeToCheckBefore)
| summarize count() by problemId
| join kind= rightanti (
exceptions
| where timestamp >= ago(newExceptionsTimeRange)
| extend stack = tostring(details[0].rawStack)
| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId
) on problemId
| order by count_ desc
",
Description = "my description",
DisplayName = "Exceptions - New in the last 24 hours",
Id = "a449f8af-8e64-4b3a-9b16-5a7165ff98c4",
QueryPackName = "my-querypack",
Related = new AzureNative.OperationalInsights.Inputs.LogAnalyticsQueryPackQueryPropertiesRelatedArgs
{
Categories = new[]
{
"analytics",
},
},
ResourceGroupName = "my-resource-group",
Tags =
{
{ "my-label", new[]
{
"label1",
} },
{ "my-other-label", new[]
{
"label2",
} },
},
});
});
package main
import (
operationalinsights "github.com/pulumi/pulumi-azure-native-sdk/operationalinsights/v2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := operationalinsights.NewQuery(ctx, "query", &operationalinsights.QueryArgs{
Body: pulumi.String(`let newExceptionsTimeRange = 1d;
let timeRangeToCheckBefore = 7d;
exceptions
| where timestamp < ago(timeRangeToCheckBefore)
| summarize count() by problemId
| join kind= rightanti (
exceptions
| where timestamp >= ago(newExceptionsTimeRange)
| extend stack = tostring(details[0].rawStack)
| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId
) on problemId
| order by count_ desc
`),
Description: pulumi.String("my description"),
DisplayName: pulumi.String("Exceptions - New in the last 24 hours"),
Id: pulumi.String("a449f8af-8e64-4b3a-9b16-5a7165ff98c4"),
QueryPackName: pulumi.String("my-querypack"),
Related: &operationalinsights.LogAnalyticsQueryPackQueryPropertiesRelatedArgs{
Categories: pulumi.StringArray{
pulumi.String("analytics"),
},
},
ResourceGroupName: pulumi.String("my-resource-group"),
Tags: pulumi.StringArrayMap{
"my-label": pulumi.StringArray{
pulumi.String("label1"),
},
"my-other-label": pulumi.StringArray{
pulumi.String("label2"),
},
},
})
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.operationalinsights.Query;
import com.pulumi.azurenative.operationalinsights.QueryArgs;
import com.pulumi.azurenative.operationalinsights.inputs.LogAnalyticsQueryPackQueryPropertiesRelatedArgs;
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 query = new Query("query", QueryArgs.builder()
.body("""
let newExceptionsTimeRange = 1d;
let timeRangeToCheckBefore = 7d;
exceptions
| where timestamp < ago(timeRangeToCheckBefore)
| summarize count() by problemId
| join kind= rightanti (
exceptions
| where timestamp >= ago(newExceptionsTimeRange)
| extend stack = tostring(details[0].rawStack)
| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId
) on problemId
| order by count_ desc
""")
.description("my description")
.displayName("Exceptions - New in the last 24 hours")
.id("a449f8af-8e64-4b3a-9b16-5a7165ff98c4")
.queryPackName("my-querypack")
.related(LogAnalyticsQueryPackQueryPropertiesRelatedArgs.builder()
.categories("analytics")
.build())
.resourceGroupName("my-resource-group")
.tags(Map.ofEntries(
Map.entry("my-label", "label1"),
Map.entry("my-other-label", "label2")
))
.build());
}
}
Import
An existing resource can be imported using its type token, name, and identifier, e.g.
$ pulumi import azure-native:operationalinsights:Query a449f8af-8e64-4b3a-9b16-5a7165ff98c4 /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}
Constructors
Properties
Description of the query.
Unique display name for your query within the Query Pack.
Additional properties that can be set for the query.
The name of the Log Analytics QueryPack resource.
The related metadata items for the function.
The name of the resource group. The name is case insensitive.