Query
A Log Analytics QueryPack-Query definition. Uses Azure REST API version 2019-09-01. In version 1.x of the Azure Native provider, it used API version 2019-09-01. Other available API versions: 2019-09-01-preview, 2023-09-01, 2025-02-01.
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",
} },
},
});
});
Content copied to clipboard
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
})
}
Content copied to clipboard
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());
}
}
Content copied to clipboard
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}
Content copied to clipboard
Properties
Link copied to clipboard
Description of the query.
Link copied to clipboard
Unique display name for your query within the Query Pack.
Link copied to clipboard
Additional properties that can be set for the query.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
The related metadata items for the function.
Link copied to clipboard
Read only system data
Link copied to clipboard
Creation Date for the Log Analytics Query, in ISO 8601 format.
Link copied to clipboard
Last modified date of the Log Analytics Query, in ISO 8601 format.