De opgeslagen zoekopdrachten voor een bepaalde Log Analytics-werkruimte ophalen
GET https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches?api-version=2020-08-01
URI-parameters
Name |
In |
Vereist |
Type |
Description |
resourceGroupName
|
path |
True
|
string
|
De naam van de resourcegroep. De naam is niet hoofdlettergevoelig.
|
subscriptionId
|
path |
True
|
string
|
De id van het doelabonnement.
|
workspaceName
|
path |
True
|
string
|
De naam van de werkruimte.
Regex pattern: ^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$
|
api-version
|
query |
True
|
string
|
De API-versie die voor deze bewerking moet worden gebruikt.
|
Antwoorden
Name |
Type |
Description |
200 OK
|
SavedSearchesListResult
|
Retourneert de lijst met opgeslagen zoekopdrachten voor de opgegeven Log Analytics-werkruimte.
|
Beveiliging
azure_auth
Azure Active Directory OAuth2-stroom
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
Uw gebruikersaccount imiteren
|
Voorbeelden
SavedSearchesList
Sample Request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-00000000000/resourcegroups/TestRG/providers/Microsoft.OperationalInsights/workspaces/TestWS/savedSearches?api-version=2020-08-01
/** Samples for SavedSearches ListByWorkspace. */
public final class Main {
/*
* x-ms-original-file: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesListByWorkspace.json
*/
/**
* Sample code: SavedSearchesList.
*
* @param manager Entry point to LogAnalyticsManager.
*/
public static void savedSearchesList(com.azure.resourcemanager.loganalytics.LogAnalyticsManager manager) {
manager.savedSearches().listByWorkspaceWithResponse("TestRG", "TestWS", com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.loganalytics import LogAnalyticsManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-loganalytics
# USAGE
python saved_searches_list_by_workspace.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = LogAnalyticsManagementClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-00000000000",
)
response = client.saved_searches.list_by_workspace(
resource_group_name="TestRG",
workspace_name="TestWS",
)
print(response)
# x-ms-original-file: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesListByWorkspace.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armoperationalinsights_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/operationalinsights/armoperationalinsights"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c767823fdfd9d5e96bad245e3ea4d14d94a716bb/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesListByWorkspace.json
func ExampleSavedSearchesClient_ListByWorkspace() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armoperationalinsights.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewSavedSearchesClient().ListByWorkspace(ctx, "TestRG", "TestWS", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.SavedSearchesListResult = armoperationalinsights.SavedSearchesListResult{
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { OperationalInsightsManagementClient } = require("@azure/arm-operationalinsights");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets the saved searches for a given Log Analytics Workspace
*
* @summary Gets the saved searches for a given Log Analytics Workspace
* x-ms-original-file: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesListByWorkspace.json
*/
async function savedSearchesList() {
const subscriptionId =
process.env["OPERATIONALINSIGHTS_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-00000000000";
const resourceGroupName = process.env["OPERATIONALINSIGHTS_RESOURCE_GROUP"] || "TestRG";
const workspaceName = "TestWS";
const credential = new DefaultAzureCredential();
const client = new OperationalInsightsManagementClient(credential, subscriptionId);
const result = await client.savedSearches.listByWorkspace(resourceGroupName, workspaceName);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.OperationalInsights;
using Azure.ResourceManager.OperationalInsights.Models;
// Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesListByWorkspace.json
// this example is just showing the usage of "SavedSearches_ListByWorkspace" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this OperationalInsightsWorkspaceResource created on azure
// for more information of creating OperationalInsightsWorkspaceResource, please refer to the document of OperationalInsightsWorkspaceResource
string subscriptionId = "00000000-0000-0000-0000-00000000000";
string resourceGroupName = "TestRG";
string workspaceName = "TestWS";
ResourceIdentifier operationalInsightsWorkspaceResourceId = OperationalInsightsWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName);
OperationalInsightsWorkspaceResource operationalInsightsWorkspace = client.GetOperationalInsightsWorkspaceResource(operationalInsightsWorkspaceResourceId);
// get the collection of this OperationalInsightsSavedSearchResource
OperationalInsightsSavedSearchCollection collection = operationalInsightsWorkspace.GetOperationalInsightsSavedSearches();
// invoke the operation and iterate over the result
await foreach (OperationalInsightsSavedSearchResource item in collection.GetAllAsync())
{
// the variable item is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
OperationalInsightsSavedSearchData resourceData = item.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
Console.WriteLine($"Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
[
{
"id": "subscriptions/00000000-0000-0000-0000-000000000005/resourceGroups/mms-eus/providers/Microsoft.OperationalInsights/workspaces/AtlantisDemo/savedSearches/test-new-saved-search-id-2015",
"etag": "W/\"datetime'2017-10-02T23%3A15%3A41.0709875Z'\"",
"properties": {
"Category": " Saved Search Test Category",
"DisplayName": "Create or Update Saved Search Test",
"Query": "* | measure Count() by Computer",
"Tags": [
{
"Name": "Group",
"Value": "Computer"
}
],
"Version": 1
}
}
]
Definities
Name |
Description |
SavedSearch
|
Waardeobject voor opgeslagen zoekresultaten.
|
SavedSearchesListResult
|
Het antwoord van de opgeslagen zoeklijstbewerking.
|
Tag
|
Een tag van een opgeslagen zoekopdracht.
|
SavedSearch
Waardeobject voor opgeslagen zoekresultaten.
Name |
Type |
Description |
etag
|
string
|
De ETag van de opgeslagen zoekopdracht. Als u een bestaande opgeslagen zoekopdracht wilt overschrijven, gebruikt u *of geeft u de huidige Etag op
|
id
|
string
|
Volledig gekwalificeerde resource-id voor de resource. Bijvoorbeeld - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
De naam van de resource
|
properties.category
|
string
|
De categorie van de opgeslagen zoekopdracht. Hierdoor kan de gebruiker een opgeslagen zoekopdracht sneller vinden.
|
properties.displayName
|
string
|
Weergavenaam van zoekactie opgeslagen.
|
properties.functionAlias
|
string
|
De functiealias als query fungeert als een functie.
|
properties.functionParameters
|
string
|
De optionele functieparameters als de query als functie fungeert. De waarde moet de volgende indeling hebben: 'param-name1:type1 = default_value1, param-name2:type2 = default_value2'. Raadpleeg https://docs.microsoft.com/en-us/azure/kusto/query/functions/user-defined-functionsvoor meer voorbeelden en de juiste syntaxis.
|
properties.query
|
string
|
De query-expressie voor de opgeslagen zoekopdracht.
|
properties.tags
|
Tag[]
|
De tags die zijn gekoppeld aan de opgeslagen zoekopdracht.
|
properties.version
|
integer
|
Het versienummer van de querytaal. De huidige versie is 2 en is de standaardversie.
|
type
|
string
|
Het type resource. Bijvoorbeeld 'Microsoft.Compute/virtualMachines' of 'Microsoft.Storage/storageAccounts'
|
SavedSearchesListResult
Het antwoord van de opgeslagen zoeklijstbewerking.
Name |
Type |
Description |
value
|
SavedSearch[]
|
De matrix met resultaatwaarden.
|
Tag
Een tag van een opgeslagen zoekopdracht.
Name |
Type |
Description |
name
|
string
|
De tagnaam.
|
value
|
string
|
De tagwaarde.
|