Query

class Query : KotlinCustomResource

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/v3"
"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}

Properties

Link copied to clipboard
val author: Output<String>

Object Id of user creating the query.

Link copied to clipboard
val azureApiVersion: Output<String>

The Azure API version of the resource.

Link copied to clipboard
val body: Output<String>

Body of the query.

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

Description of the query.

Link copied to clipboard
val displayName: Output<String>

Unique display name for your query within the Query Pack.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val name: Output<String>

The name of the resource

Link copied to clipboard
val properties: Output<Any>

Additional properties that can be set for the query.

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

The related metadata items for the function.

Link copied to clipboard

Azure Resource Manager metadata containing createdBy and modifiedBy information.

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

Tags associated with the query.

Link copied to clipboard
val timeCreated: Output<String>

Creation Date for the Log Analytics Query, in ISO 8601 format.

Link copied to clipboard
val timeModified: Output<String>

Last modified date of the Log Analytics Query, in ISO 8601 format.

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>