Azure Classic

v5.24.0 published on Wednesday, Nov 9, 2022 by Pulumi

SavedSearch

Manages a Log Analytics (formally Operational Insights) Saved Search.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new()
    {
        Location = "West Europe",
    });

    var exampleAnalyticsWorkspace = new Azure.OperationalInsights.AnalyticsWorkspace("exampleAnalyticsWorkspace", new()
    {
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
        Sku = "PerGB2018",
        RetentionInDays = 30,
    });

    var exampleSavedSearch = new Azure.LogAnalytics.SavedSearch("exampleSavedSearch", new()
    {
        LogAnalyticsWorkspaceId = exampleAnalyticsWorkspace.Id,
        Category = "exampleCategory",
        DisplayName = "exampleDisplayName",
        Query = "exampleQuery",
    });

});
package main

import (
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/loganalytics"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/operationalinsights"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
			Location: pulumi.String("West Europe"),
		})
		if err != nil {
			return err
		}
		exampleAnalyticsWorkspace, err := operationalinsights.NewAnalyticsWorkspace(ctx, "exampleAnalyticsWorkspace", &operationalinsights.AnalyticsWorkspaceArgs{
			Location:          exampleResourceGroup.Location,
			ResourceGroupName: exampleResourceGroup.Name,
			Sku:               pulumi.String("PerGB2018"),
			RetentionInDays:   pulumi.Int(30),
		})
		if err != nil {
			return err
		}
		_, err = loganalytics.NewSavedSearch(ctx, "exampleSavedSearch", &loganalytics.SavedSearchArgs{
			LogAnalyticsWorkspaceId: exampleAnalyticsWorkspace.ID(),
			Category:                pulumi.String("exampleCategory"),
			DisplayName:             pulumi.String("exampleDisplayName"),
			Query:                   pulumi.String("exampleQuery"),
		})
		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.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.operationalinsights.AnalyticsWorkspace;
import com.pulumi.azure.operationalinsights.AnalyticsWorkspaceArgs;
import com.pulumi.azure.loganalytics.SavedSearch;
import com.pulumi.azure.loganalytics.SavedSearchArgs;
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 exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()        
            .location("West Europe")
            .build());

        var exampleAnalyticsWorkspace = new AnalyticsWorkspace("exampleAnalyticsWorkspace", AnalyticsWorkspaceArgs.builder()        
            .location(exampleResourceGroup.location())
            .resourceGroupName(exampleResourceGroup.name())
            .sku("PerGB2018")
            .retentionInDays(30)
            .build());

        var exampleSavedSearch = new SavedSearch("exampleSavedSearch", SavedSearchArgs.builder()        
            .logAnalyticsWorkspaceId(exampleAnalyticsWorkspace.id())
            .category("exampleCategory")
            .displayName("exampleDisplayName")
            .query("exampleQuery")
            .build());

    }
}
import pulumi
import pulumi_azure as azure

example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_analytics_workspace = azure.operationalinsights.AnalyticsWorkspace("exampleAnalyticsWorkspace",
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name,
    sku="PerGB2018",
    retention_in_days=30)
example_saved_search = azure.loganalytics.SavedSearch("exampleSavedSearch",
    log_analytics_workspace_id=example_analytics_workspace.id,
    category="exampleCategory",
    display_name="exampleDisplayName",
    query="exampleQuery")
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleAnalyticsWorkspace = new azure.operationalinsights.AnalyticsWorkspace("exampleAnalyticsWorkspace", {
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
    sku: "PerGB2018",
    retentionInDays: 30,
});
const exampleSavedSearch = new azure.loganalytics.SavedSearch("exampleSavedSearch", {
    logAnalyticsWorkspaceId: exampleAnalyticsWorkspace.id,
    category: "exampleCategory",
    displayName: "exampleDisplayName",
    query: "exampleQuery",
});
resources:
  exampleResourceGroup:
    type: azure:core:ResourceGroup
    properties:
      location: West Europe
  exampleAnalyticsWorkspace:
    type: azure:operationalinsights:AnalyticsWorkspace
    properties:
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
      sku: PerGB2018
      retentionInDays: 30
  exampleSavedSearch:
    type: azure:loganalytics:SavedSearch
    properties:
      logAnalyticsWorkspaceId: ${exampleAnalyticsWorkspace.id}
      category: exampleCategory
      displayName: exampleDisplayName
      query: exampleQuery

Create SavedSearch Resource

new SavedSearch(name: string, args: SavedSearchArgs, opts?: CustomResourceOptions);
@overload
def SavedSearch(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                category: Optional[str] = None,
                display_name: Optional[str] = None,
                function_alias: Optional[str] = None,
                function_parameters: Optional[Sequence[str]] = None,
                log_analytics_workspace_id: Optional[str] = None,
                name: Optional[str] = None,
                query: Optional[str] = None,
                tags: Optional[Mapping[str, str]] = None)
@overload
def SavedSearch(resource_name: str,
                args: SavedSearchArgs,
                opts: Optional[ResourceOptions] = None)
func NewSavedSearch(ctx *Context, name string, args SavedSearchArgs, opts ...ResourceOption) (*SavedSearch, error)
public SavedSearch(string name, SavedSearchArgs args, CustomResourceOptions? opts = null)
public SavedSearch(String name, SavedSearchArgs args)
public SavedSearch(String name, SavedSearchArgs args, CustomResourceOptions options)
type: azure:loganalytics:SavedSearch
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args SavedSearchArgs
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 SavedSearchArgs
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 SavedSearchArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args SavedSearchArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args SavedSearchArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

SavedSearch Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The SavedSearch resource accepts the following input properties:

Category string

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

DisplayName string

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

LogAnalyticsWorkspaceId string

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

Query string

The query expression for the saved search. Changing this forces a new resource to be created.

FunctionAlias string

The function alias if the query serves as a function. Changing this forces a new resource to be created.

FunctionParameters List<string>

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

Name string

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

Tags Dictionary<string, string>

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

Category string

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

DisplayName string

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

LogAnalyticsWorkspaceId string

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

Query string

The query expression for the saved search. Changing this forces a new resource to be created.

FunctionAlias string

The function alias if the query serves as a function. Changing this forces a new resource to be created.

FunctionParameters []string

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

Name string

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

Tags map[string]string

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

category String

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

displayName String

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

logAnalyticsWorkspaceId String

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

query String

The query expression for the saved search. Changing this forces a new resource to be created.

functionAlias String

The function alias if the query serves as a function. Changing this forces a new resource to be created.

functionParameters List<String>

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

name String

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

tags Map<String,String>

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

category string

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

displayName string

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

logAnalyticsWorkspaceId string

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

query string

The query expression for the saved search. Changing this forces a new resource to be created.

functionAlias string

The function alias if the query serves as a function. Changing this forces a new resource to be created.

functionParameters string[]

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

name string

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

tags {[key: string]: string}

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

category str

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

display_name str

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

log_analytics_workspace_id str

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

query str

The query expression for the saved search. Changing this forces a new resource to be created.

function_alias str

The function alias if the query serves as a function. Changing this forces a new resource to be created.

function_parameters Sequence[str]

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

name str

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

tags Mapping[str, str]

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

category String

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

displayName String

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

logAnalyticsWorkspaceId String

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

query String

The query expression for the saved search. Changing this forces a new resource to be created.

functionAlias String

The function alias if the query serves as a function. Changing this forces a new resource to be created.

functionParameters List<String>

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

name String

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

tags Map<String>

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

Outputs

All input properties are implicitly available as output properties. Additionally, the SavedSearch resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing SavedSearch Resource

Get an existing SavedSearch resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: SavedSearchState, opts?: CustomResourceOptions): SavedSearch
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        category: Optional[str] = None,
        display_name: Optional[str] = None,
        function_alias: Optional[str] = None,
        function_parameters: Optional[Sequence[str]] = None,
        log_analytics_workspace_id: Optional[str] = None,
        name: Optional[str] = None,
        query: Optional[str] = None,
        tags: Optional[Mapping[str, str]] = None) -> SavedSearch
func GetSavedSearch(ctx *Context, name string, id IDInput, state *SavedSearchState, opts ...ResourceOption) (*SavedSearch, error)
public static SavedSearch Get(string name, Input<string> id, SavedSearchState? state, CustomResourceOptions? opts = null)
public static SavedSearch get(String name, Output<String> id, SavedSearchState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Category string

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

DisplayName string

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

FunctionAlias string

The function alias if the query serves as a function. Changing this forces a new resource to be created.

FunctionParameters List<string>

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

LogAnalyticsWorkspaceId string

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

Name string

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

Query string

The query expression for the saved search. Changing this forces a new resource to be created.

Tags Dictionary<string, string>

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

Category string

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

DisplayName string

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

FunctionAlias string

The function alias if the query serves as a function. Changing this forces a new resource to be created.

FunctionParameters []string

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

LogAnalyticsWorkspaceId string

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

Name string

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

Query string

The query expression for the saved search. Changing this forces a new resource to be created.

Tags map[string]string

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

category String

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

displayName String

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

functionAlias String

The function alias if the query serves as a function. Changing this forces a new resource to be created.

functionParameters List<String>

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

logAnalyticsWorkspaceId String

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

name String

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

query String

The query expression for the saved search. Changing this forces a new resource to be created.

tags Map<String,String>

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

category string

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

displayName string

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

functionAlias string

The function alias if the query serves as a function. Changing this forces a new resource to be created.

functionParameters string[]

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

logAnalyticsWorkspaceId string

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

name string

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

query string

The query expression for the saved search. Changing this forces a new resource to be created.

tags {[key: string]: string}

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

category str

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

display_name str

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

function_alias str

The function alias if the query serves as a function. Changing this forces a new resource to be created.

function_parameters Sequence[str]

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

log_analytics_workspace_id str

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

name str

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

query str

The query expression for the saved search. Changing this forces a new resource to be created.

tags Mapping[str, str]

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

category String

The category that the Saved Search will be listed under. Changing this forces a new resource to be created.

displayName String

The name that Saved Search will be displayed as. Changing this forces a new resource to be created.

functionAlias String

The function alias if the query serves as a function. Changing this forces a new resource to be created.

functionParameters List<String>

The function parameters if the query serves as a function. Changing this forces a new resource to be created.

logAnalyticsWorkspaceId String

Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.

name String

Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.

query String

The query expression for the saved search. Changing this forces a new resource to be created.

tags Map<String>

A mapping of tags which should be assigned to the Logs Analytics Saved Search.

Import

Log Analytics Saved Searches can be imported using the resource id, e.g.

 $ pulumi import azure:loganalytics/savedSearch:SavedSearch search1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/savedSearches/search1

Package Details

Repository
https://github.com/pulumi/pulumi-azure
License
Apache-2.0
Notes

This Pulumi package is based on the azurerm Terraform Provider.