azure-native.operationalinsights.Query
Explore with Pulumi AI
A Log Analytics QueryPack-Query definition. Azure REST API version: 2019-09-01. Prior API version in Azure Native 1.x: 2019-09-01.
Other available API versions: 2019-09-01-preview, 2023-09-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",
            } },
        },
    });
});
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 * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";
const query = new azure_native.operationalinsights.Query("query", {
    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: {
        categories: ["analytics"],
    },
    resourceGroupName: "my-resource-group",
    tags: {
        "my-label": ["label1"],
        "my-other-label": ["label2"],
    },
});
import pulumi
import pulumi_azure_native as azure_native
query = azure_native.operationalinsights.Query("query",
    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",
    display_name="Exceptions - New in the last 24 hours",
    id="a449f8af-8e64-4b3a-9b16-5a7165ff98c4",
    query_pack_name="my-querypack",
    related={
        "categories": ["analytics"],
    },
    resource_group_name="my-resource-group",
    tags={
        "my-label": ["label1"],
        "my-other-label": ["label2"],
    })
resources:
  query:
    type: azure-native:operationalinsights:Query
    properties:
      body: "let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId  \n) on problemId \n| order by  count_ desc\n"
      description: my description
      displayName: Exceptions - New in the last 24 hours
      id: a449f8af-8e64-4b3a-9b16-5a7165ff98c4
      queryPackName: my-querypack
      related:
        categories:
          - analytics
      resourceGroupName: my-resource-group
      tags:
        my-label:
          - label1
        my-other-label:
          - label2
Create Query Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Query(name: string, args: QueryArgs, opts?: CustomResourceOptions);@overload
def Query(resource_name: str,
          args: QueryArgs,
          opts: Optional[ResourceOptions] = None)
@overload
def Query(resource_name: str,
          opts: Optional[ResourceOptions] = None,
          body: Optional[str] = None,
          display_name: Optional[str] = None,
          query_pack_name: Optional[str] = None,
          resource_group_name: Optional[str] = None,
          description: Optional[str] = None,
          id: Optional[str] = None,
          properties: Optional[Any] = None,
          related: Optional[LogAnalyticsQueryPackQueryPropertiesRelatedArgs] = None,
          tags: Optional[Mapping[str, Sequence[str]]] = None)func NewQuery(ctx *Context, name string, args QueryArgs, opts ...ResourceOption) (*Query, error)public Query(string name, QueryArgs args, CustomResourceOptions? opts = null)type: azure-native:operationalinsights:Query
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args QueryArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args QueryArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args QueryArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args QueryArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args QueryArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var queryResource = new AzureNative.OperationalInsights.Query("queryResource", new()
{
    Body = "string",
    DisplayName = "string",
    QueryPackName = "string",
    ResourceGroupName = "string",
    Description = "string",
    Id = "string",
    Properties = "any",
    Related = new AzureNative.OperationalInsights.Inputs.LogAnalyticsQueryPackQueryPropertiesRelatedArgs
    {
        Categories = new[]
        {
            "string",
        },
        ResourceTypes = new[]
        {
            "string",
        },
        Solutions = new[]
        {
            "string",
        },
    },
    Tags = 
    {
        { "string", new[]
        {
            "string",
        } },
    },
});
example, err := operationalinsights.NewQuery(ctx, "queryResource", &operationalinsights.QueryArgs{
	Body:              pulumi.String("string"),
	DisplayName:       pulumi.String("string"),
	QueryPackName:     pulumi.String("string"),
	ResourceGroupName: pulumi.String("string"),
	Description:       pulumi.String("string"),
	Id:                pulumi.String("string"),
	Properties:        pulumi.Any("any"),
	Related: &operationalinsights.LogAnalyticsQueryPackQueryPropertiesRelatedArgs{
		Categories: pulumi.StringArray{
			pulumi.String("string"),
		},
		ResourceTypes: pulumi.StringArray{
			pulumi.String("string"),
		},
		Solutions: pulumi.StringArray{
			pulumi.String("string"),
		},
	},
	Tags: pulumi.StringArrayMap{
		"string": pulumi.StringArray{
			pulumi.String("string"),
		},
	},
})
var queryResource = new Query("queryResource", QueryArgs.builder()
    .body("string")
    .displayName("string")
    .queryPackName("string")
    .resourceGroupName("string")
    .description("string")
    .id("string")
    .properties("any")
    .related(LogAnalyticsQueryPackQueryPropertiesRelatedArgs.builder()
        .categories("string")
        .resourceTypes("string")
        .solutions("string")
        .build())
    .tags(Map.of("string", "string"))
    .build());
query_resource = azure_native.operationalinsights.Query("queryResource",
    body="string",
    display_name="string",
    query_pack_name="string",
    resource_group_name="string",
    description="string",
    id="string",
    properties="any",
    related={
        "categories": ["string"],
        "resource_types": ["string"],
        "solutions": ["string"],
    },
    tags={
        "string": ["string"],
    })
const queryResource = new azure_native.operationalinsights.Query("queryResource", {
    body: "string",
    displayName: "string",
    queryPackName: "string",
    resourceGroupName: "string",
    description: "string",
    id: "string",
    properties: "any",
    related: {
        categories: ["string"],
        resourceTypes: ["string"],
        solutions: ["string"],
    },
    tags: {
        string: ["string"],
    },
});
type: azure-native:operationalinsights:Query
properties:
    body: string
    description: string
    displayName: string
    id: string
    properties: any
    queryPackName: string
    related:
        categories:
            - string
        resourceTypes:
            - string
        solutions:
            - string
    resourceGroupName: string
    tags:
        string:
            - string
Query Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Query resource accepts the following input properties:
- Body string
- Body of the query.
- DisplayName string
- Unique display name for your query within the Query Pack.
- QueryPack stringName 
- The name of the Log Analytics QueryPack resource.
- ResourceGroup stringName 
- The name of the resource group. The name is case insensitive.
- Description string
- Description of the query.
- Id string
- The id of a specific query defined in the Log Analytics QueryPack
- Properties object
- Additional properties that can be set for the query.
- 
Pulumi.Azure Native. Operational Insights. Inputs. Log Analytics Query Pack Query Properties Related 
- The related metadata items for the function.
- 
Dictionary<string, ImmutableArray<string>> 
- Tags associated with the query.
- Body string
- Body of the query.
- DisplayName string
- Unique display name for your query within the Query Pack.
- QueryPack stringName 
- The name of the Log Analytics QueryPack resource.
- ResourceGroup stringName 
- The name of the resource group. The name is case insensitive.
- Description string
- Description of the query.
- Id string
- The id of a specific query defined in the Log Analytics QueryPack
- Properties interface{}
- Additional properties that can be set for the query.
- 
LogAnalytics Query Pack Query Properties Related Args 
- The related metadata items for the function.
- map[string][]string
- Tags associated with the query.
- body String
- Body of the query.
- displayName String
- Unique display name for your query within the Query Pack.
- queryPack StringName 
- The name of the Log Analytics QueryPack resource.
- resourceGroup StringName 
- The name of the resource group. The name is case insensitive.
- description String
- Description of the query.
- id String
- The id of a specific query defined in the Log Analytics QueryPack
- properties Object
- Additional properties that can be set for the query.
- 
LogAnalytics Query Pack Query Properties Related 
- The related metadata items for the function.
- Map<String,List<String>>
- Tags associated with the query.
- body string
- Body of the query.
- displayName string
- Unique display name for your query within the Query Pack.
- queryPack stringName 
- The name of the Log Analytics QueryPack resource.
- resourceGroup stringName 
- The name of the resource group. The name is case insensitive.
- description string
- Description of the query.
- id string
- The id of a specific query defined in the Log Analytics QueryPack
- properties any
- Additional properties that can be set for the query.
- 
LogAnalytics Query Pack Query Properties Related 
- The related metadata items for the function.
- {[key: string]: string[]}
- Tags associated with the query.
- body str
- Body of the query.
- display_name str
- Unique display name for your query within the Query Pack.
- query_pack_ strname 
- The name of the Log Analytics QueryPack resource.
- resource_group_ strname 
- The name of the resource group. The name is case insensitive.
- description str
- Description of the query.
- id str
- The id of a specific query defined in the Log Analytics QueryPack
- properties Any
- Additional properties that can be set for the query.
- 
LogAnalytics Query Pack Query Properties Related Args 
- The related metadata items for the function.
- Mapping[str, Sequence[str]]
- Tags associated with the query.
- body String
- Body of the query.
- displayName String
- Unique display name for your query within the Query Pack.
- queryPack StringName 
- The name of the Log Analytics QueryPack resource.
- resourceGroup StringName 
- The name of the resource group. The name is case insensitive.
- description String
- Description of the query.
- id String
- The id of a specific query defined in the Log Analytics QueryPack
- properties Any
- Additional properties that can be set for the query.
- Property Map
- The related metadata items for the function.
- Map<List<String>>
- Tags associated with the query.
Outputs
All input properties are implicitly available as output properties. Additionally, the Query resource produces the following output properties:
- string
- Object Id of user creating the query.
- Id string
- The provider-assigned unique ID for this managed resource.
- Name string
- Azure resource name
- SystemData Pulumi.Azure Native. Operational Insights. Outputs. System Data Response 
- Read only system data
- TimeCreated string
- Creation Date for the Log Analytics Query, in ISO 8601 format.
- TimeModified string
- Last modified date of the Log Analytics Query, in ISO 8601 format.
- Type string
- Azure resource type
- string
- Object Id of user creating the query.
- Id string
- The provider-assigned unique ID for this managed resource.
- Name string
- Azure resource name
- SystemData SystemData Response 
- Read only system data
- TimeCreated string
- Creation Date for the Log Analytics Query, in ISO 8601 format.
- TimeModified string
- Last modified date of the Log Analytics Query, in ISO 8601 format.
- Type string
- Azure resource type
- String
- Object Id of user creating the query.
- id String
- The provider-assigned unique ID for this managed resource.
- name String
- Azure resource name
- systemData SystemData Response 
- Read only system data
- timeCreated String
- Creation Date for the Log Analytics Query, in ISO 8601 format.
- timeModified String
- Last modified date of the Log Analytics Query, in ISO 8601 format.
- type String
- Azure resource type
- string
- Object Id of user creating the query.
- id string
- The provider-assigned unique ID for this managed resource.
- name string
- Azure resource name
- systemData SystemData Response 
- Read only system data
- timeCreated string
- Creation Date for the Log Analytics Query, in ISO 8601 format.
- timeModified string
- Last modified date of the Log Analytics Query, in ISO 8601 format.
- type string
- Azure resource type
- str
- Object Id of user creating the query.
- id str
- The provider-assigned unique ID for this managed resource.
- name str
- Azure resource name
- system_data SystemData Response 
- Read only system data
- time_created str
- Creation Date for the Log Analytics Query, in ISO 8601 format.
- time_modified str
- Last modified date of the Log Analytics Query, in ISO 8601 format.
- type str
- Azure resource type
- String
- Object Id of user creating the query.
- id String
- The provider-assigned unique ID for this managed resource.
- name String
- Azure resource name
- systemData Property Map
- Read only system data
- timeCreated String
- Creation Date for the Log Analytics Query, in ISO 8601 format.
- timeModified String
- Last modified date of the Log Analytics Query, in ISO 8601 format.
- type String
- Azure resource type
Supporting Types
LogAnalyticsQueryPackQueryPropertiesRelated, LogAnalyticsQueryPackQueryPropertiesRelatedArgs              
- Categories List<string>
- The related categories for the function.
- ResourceTypes List<string>
- The related resource types for the function.
- Solutions List<string>
- The related Log Analytics solutions for the function.
- Categories []string
- The related categories for the function.
- ResourceTypes []string
- The related resource types for the function.
- Solutions []string
- The related Log Analytics solutions for the function.
- categories List<String>
- The related categories for the function.
- resourceTypes List<String>
- The related resource types for the function.
- solutions List<String>
- The related Log Analytics solutions for the function.
- categories string[]
- The related categories for the function.
- resourceTypes string[]
- The related resource types for the function.
- solutions string[]
- The related Log Analytics solutions for the function.
- categories Sequence[str]
- The related categories for the function.
- resource_types Sequence[str]
- The related resource types for the function.
- solutions Sequence[str]
- The related Log Analytics solutions for the function.
- categories List<String>
- The related categories for the function.
- resourceTypes List<String>
- The related resource types for the function.
- solutions List<String>
- The related Log Analytics solutions for the function.
LogAnalyticsQueryPackQueryPropertiesResponseRelated, LogAnalyticsQueryPackQueryPropertiesResponseRelatedArgs                
- Categories List<string>
- The related categories for the function.
- ResourceTypes List<string>
- The related resource types for the function.
- Solutions List<string>
- The related Log Analytics solutions for the function.
- Categories []string
- The related categories for the function.
- ResourceTypes []string
- The related resource types for the function.
- Solutions []string
- The related Log Analytics solutions for the function.
- categories List<String>
- The related categories for the function.
- resourceTypes List<String>
- The related resource types for the function.
- solutions List<String>
- The related Log Analytics solutions for the function.
- categories string[]
- The related categories for the function.
- resourceTypes string[]
- The related resource types for the function.
- solutions string[]
- The related Log Analytics solutions for the function.
- categories Sequence[str]
- The related categories for the function.
- resource_types Sequence[str]
- The related resource types for the function.
- solutions Sequence[str]
- The related Log Analytics solutions for the function.
- categories List<String>
- The related categories for the function.
- resourceTypes List<String>
- The related resource types for the function.
- solutions List<String>
- The related Log Analytics solutions for the function.
SystemDataResponse, SystemDataResponseArgs      
- CreatedAt string
- The timestamp of resource creation (UTC).
- CreatedBy string
- The identity that created the resource.
- CreatedBy stringType 
- The type of identity that created the resource.
- LastModified stringAt 
- The timestamp of resource last modification (UTC)
- LastModified stringBy 
- The identity that last modified the resource.
- LastModified stringBy Type 
- The type of identity that last modified the resource.
- CreatedAt string
- The timestamp of resource creation (UTC).
- CreatedBy string
- The identity that created the resource.
- CreatedBy stringType 
- The type of identity that created the resource.
- LastModified stringAt 
- The timestamp of resource last modification (UTC)
- LastModified stringBy 
- The identity that last modified the resource.
- LastModified stringBy Type 
- The type of identity that last modified the resource.
- createdAt String
- The timestamp of resource creation (UTC).
- createdBy String
- The identity that created the resource.
- createdBy StringType 
- The type of identity that created the resource.
- lastModified StringAt 
- The timestamp of resource last modification (UTC)
- lastModified StringBy 
- The identity that last modified the resource.
- lastModified StringBy Type 
- The type of identity that last modified the resource.
- createdAt string
- The timestamp of resource creation (UTC).
- createdBy string
- The identity that created the resource.
- createdBy stringType 
- The type of identity that created the resource.
- lastModified stringAt 
- The timestamp of resource last modification (UTC)
- lastModified stringBy 
- The identity that last modified the resource.
- lastModified stringBy Type 
- The type of identity that last modified the resource.
- created_at str
- The timestamp of resource creation (UTC).
- created_by str
- The identity that created the resource.
- created_by_ strtype 
- The type of identity that created the resource.
- last_modified_ strat 
- The timestamp of resource last modification (UTC)
- last_modified_ strby 
- The identity that last modified the resource.
- last_modified_ strby_ type 
- The type of identity that last modified the resource.
- createdAt String
- The timestamp of resource creation (UTC).
- createdBy String
- The identity that created the resource.
- createdBy StringType 
- The type of identity that created the resource.
- lastModified StringAt 
- The timestamp of resource last modification (UTC)
- lastModified StringBy 
- The identity that last modified the resource.
- lastModified StringBy Type 
- The type of identity that last modified the resource.
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} 
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Native pulumi/pulumi-azure-native
- License
- Apache-2.0