Obtém as pesquisas guardadas de uma determinada Área de Trabalho do Log Analytics
GET https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches?api-version=2020-08-01
Parâmetros do URI
Name |
Em |
Necessário |
Tipo |
Description |
resourceGroupName
|
path |
True
|
string
|
O nome do grupo de recursos. O nome não é sensível a maiúsculas e minúsculas.
|
subscriptionId
|
path |
True
|
string
|
O ID da subscrição de destino.
|
workspaceName
|
path |
True
|
string
|
O nome da área de trabalho.
Regex pattern: ^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$
|
api-version
|
query |
True
|
string
|
A versão da API a utilizar para esta operação.
|
Respostas
Name |
Tipo |
Description |
200 OK
|
SavedSearchesListResult
|
Devolve a lista de pesquisas guardadas para a Área de Trabalho do Log Analytics especificada.
|
Segurança
azure_auth
Fluxo OAuth2 do Azure Active Directory
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
representar a sua conta de utilizador
|
Exemplos
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
}
}
]
Definições
Name |
Description |
SavedSearch
|
Objeto de valor para resultados de pesquisa guardados.
|
SavedSearchesListResult
|
A resposta da operação da lista de pesquisa guardada.
|
Tag
|
Uma etiqueta de uma pesquisa guardada.
|
SavedSearch
Objeto de valor para resultados de pesquisa guardados.
Name |
Tipo |
Description |
etag
|
string
|
O ETag da pesquisa guardada. Para substituir uma pesquisa guardada existente, utilize "*" ou especifique o Etag atual
|
id
|
string
|
ID de recurso completamente qualificado para o recurso. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
O nome do recurso
|
properties.category
|
string
|
A categoria da pesquisa guardada. Isto ajuda o utilizador a encontrar uma pesquisa guardada mais rapidamente.
|
properties.displayName
|
string
|
Nome a apresentar da pesquisa guardado.
|
properties.functionAlias
|
string
|
O alias de função se a consulta servir como uma função.
|
properties.functionParameters
|
string
|
Os parâmetros de função opcionais se a consulta servir como uma função. O valor deve estar no seguinte formato: "param-name1:type1 = default_value1, param-name2:type2 = default_value2". Para obter mais exemplos e sintaxe adequada, veja https://docs.microsoft.com/en-us/azure/kusto/query/functions/user-defined-functions.
|
properties.query
|
string
|
A expressão de consulta da pesquisa guardada.
|
properties.tags
|
Tag[]
|
As etiquetas anexadas à pesquisa guardada.
|
properties.version
|
integer
|
O número da versão da linguagem de consulta. A versão atual é 2 e é a predefinição.
|
type
|
string
|
O tipo de recurso. Por exemplo, "Microsoft.Compute/virtualMachines" ou "Microsoft.Storage/storageAccounts"
|
SavedSearchesListResult
A resposta da operação da lista de pesquisa guardada.
Name |
Tipo |
Description |
value
|
SavedSearch[]
|
A matriz de valores de resultados.
|
Tag
Uma etiqueta de uma pesquisa guardada.
Name |
Tipo |
Description |
name
|
string
|
O nome da etiqueta.
|
value
|
string
|
O valor da etiqueta.
|