A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/monitor/query/azlogs below:

azlogs package - github.com/Azure/azure-sdk-for-go/sdk/monitor/query/azlogs - Go Packages

Cloud Service Names for Monitor Query Logs, used to identify the respective cloud.ServiceConfiguration

This section is empty.

This section is empty.

BatchQueryRequest - An single request in a batch.

MarshalJSON implements the json.Marshaller interface for type BatchQueryRequest.

UnmarshalJSON implements the json.Unmarshaller interface for type BatchQueryRequest.

BatchQueryResponse - Contains the batch query response and the headers, id, and status of the request

MarshalJSON implements the json.Marshaller interface for type BatchQueryResponse.

UnmarshalJSON implements the json.Unmarshaller interface for type BatchQueryResponse.

BatchQueryResults - Contains the tables, columns & rows resulting from a query.

MarshalJSON implements the json.Marshaller interface for type BatchQueryResults.

UnmarshalJSON implements the json.Unmarshaller interface for type BatchQueryResults.

BatchRequest - An array of requests.

MarshalJSON implements the json.Marshaller interface for type BatchRequest.

UnmarshalJSON implements the json.Unmarshaller interface for type BatchRequest.

BatchResponse - Response to a batch query.

MarshalJSON implements the json.Marshaller interface for type BatchResponse.

UnmarshalJSON implements the json.Unmarshaller interface for type BatchResponse.

Client contains the methods for the Logs group. Don't use this type directly, use a constructor function instead.

NewClient creates a client that accesses Azure Monitor logs data.

package main

import (
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/monitor/query/azlogs"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		//TODO: handle error
	}

	client, err := azlogs.NewClient(cred, nil)
	if err != nil {
		//TODO: handle error
	}
	_ = client
}

QueryBatch - Executes a batch of Analytics queries for data. Here [https://learn.microsoft.com/azure/azure-monitor/logs/api/batch-queries] is an example for using POST with an Analytics query. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2022-10-27

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/monitor/query/azlogs"
)

var (
	client      azlogs.Client
	kustoQuery1 string
	kustoQuery2 string
	kustoQuery3 string
)

func main() {
	// `QueryBatch` is an advanced method allowing users to execute multiple log queries in a single request.

	workspaceID := "g4d1e129-fb1e-4b0a-b234-250abc987ea65" // example Azure Log Analytics Workspace ID
	timespan := azlogs.NewTimeInterval(time.Date(2022, 12, 25, 0, 0, 0, 0, time.UTC), time.Date(2022, 12, 25, 12, 0, 0, 0, time.UTC))

	batchRequest := azlogs.BatchRequest{[]azlogs.BatchQueryRequest{
		{Body: &azlogs.QueryBody{Query: to.Ptr(kustoQuery1), Timespan: to.Ptr(timespan)}, ID: to.Ptr("1"), WorkspaceID: to.Ptr(workspaceID)},
		{Body: &azlogs.QueryBody{Query: to.Ptr(kustoQuery2), Timespan: to.Ptr(timespan)}, ID: to.Ptr("2"), WorkspaceID: to.Ptr(workspaceID)},
		{Body: &azlogs.QueryBody{Query: to.Ptr(kustoQuery3), Timespan: to.Ptr(timespan)}, ID: to.Ptr("3"), WorkspaceID: to.Ptr(workspaceID)},
	}}

	res, err := client.QueryBatch(context.TODO(), batchRequest, nil)
	if err != nil {
		//TODO: handle error
	}

	// `QueryBatch` can return results in any order, usually by time it takes each individual query to complete.
	// Use the `ID` field to identify the correct response.
	responses := res.Responses
	fmt.Println("ID's of successful responses:")
	for _, response := range responses {
		if response.Body.Error == nil {
			fmt.Println(*response.ID)
		}
	}
}

QueryResource - Executes an Analytics query for data in the context of a resource. Here [https://learn.microsoft.com/azure/azure-monitor/logs/api/azure-resource-queries] is an example for using POST with an Analytics query. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2022-10-27

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/monitor/query/azlogs"
)

var client azlogs.Client

func main() {
	// Instead of requiring a Log Analytics workspace,
	// QueryResource allows users to query logs directly from an Azure resource through a resource ID.

	// To find the resource ID:
	// 1. Navigate to your resource's page in the Azure portal.
	// 2. From the **Overview** blade, select the **JSON View** link.
	// 3. In the resulting JSON, copy the value of the `id` property.

	resourceID := "/subscriptions/fajfkx93-c1d8-40ad-9cce-e49c10ca8qe6/resourceGroups/testgroup/providers/Microsoft.Storage/storageAccounts/mystorageacount" // example resource ID

	res, err := client.QueryResource(
		context.TODO(),
		resourceID,
		azlogs.QueryBody{
			Query:    to.Ptr("StorageBlobLogs | where TimeGenerated > ago(3d)"), // example Kusto query
			Timespan: to.Ptr(azlogs.NewTimeInterval(time.Date(2022, 12, 25, 0, 0, 0, 0, time.UTC), time.Date(2022, 12, 25, 12, 0, 0, 0, time.UTC))),
		},
		nil)
	if err != nil {
		//TODO: handle error
	}
	if res.Error != nil {
		//TODO: handle partial error
	}

	// Print Rows
	for _, table := range res.Tables {
		for _, row := range table.Rows {
			fmt.Println(row)
		}
	}
}

QueryWorkspace - Executes an Analytics query for data. Here [https://learn.microsoft.com/azure/azure-monitor/logs/api/request-format] is an example for using POST with an Analytics query. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2022-10-27

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/monitor/query/azlogs"
)

var client azlogs.Client

func main() {
	// QueryWorkspace allows users to query log data.

	// A workspace ID is required to query logs. To find the workspace ID:
	// 1. If not already made, create a Log Analytics workspace (https://learn.microsoft.com/azure/azure-monitor/logs/quick-create-workspace).
	// 2. Navigate to your workspace's page in the Azure portal.
	// 3. From the **Overview** blade, copy the value of the ***Workspace ID*** property.

	workspaceID := "g4d1e129-fb1e-4b0a-b234-250abc987ea65" // example Azure Log Analytics Workspace ID

	res, err := client.QueryWorkspace(
		context.TODO(),
		workspaceID,
		azlogs.QueryBody{
			Query:    to.Ptr("AzureActivity | top 10 by TimeGenerated"), // example Kusto query
			Timespan: to.Ptr(azlogs.NewTimeInterval(time.Date(2022, 12, 25, 0, 0, 0, 0, time.UTC), time.Date(2022, 12, 25, 12, 0, 0, 0, time.UTC))),
		},
		nil)
	if err != nil {
		//TODO: handle error
	}
	if res.Error != nil {
		//TODO: handle partial error
	}

	// Print Rows
	for _, table := range res.Tables {
		for _, row := range table.Rows {
			fmt.Println(row)
		}
	}
}
// `QueryWorkspace` also has more advanced options, including querying multiple workspaces
// and QueryOptions (including statistics and visualization information and increasing default timeout).

// When multiple workspaces are included in the query, the logs in the result table are not grouped
// according to the workspace from which it was retrieved.
workspaceID1 := "g4d1e129-fb1e-4b0a-b234-250abc987ea65" // example Azure Log Analytics Workspace ID
workspaceID2 := "h4bc4471-2e8c-4b1c-8f47-12b9a4d5ac71"
additionalWorkspaces := []string{workspaceID2}

// Advanced query options
// Setting Statistics to true returns stats information in Results.Statistics
// Setting Visualization to true returns visualization information in Results.Visualization
options := &azlogs.QueryWorkspaceOptions{
	Options: &azlogs.QueryOptions{
		Statistics:    to.Ptr(true),
		Visualization: to.Ptr(true),
		Wait:          to.Ptr(600),
	},
}

res, err := client.QueryWorkspace(
	context.TODO(),
	workspaceID1,
	azlogs.QueryBody{
		Query:                to.Ptr(query),
		Timespan:             to.Ptr(azlogs.NewTimeInterval(time.Date(2022, 12, 25, 0, 0, 0, 0, time.UTC), time.Date(2022, 12, 25, 12, 0, 0, 0, time.UTC))),
		AdditionalWorkspaces: additionalWorkspaces,
	},
	options)
if err != nil {
	//TODO: handle error
}
if res.Error != nil {
	//TODO: handle partial error
}

// Example of converting table data into a slice of structs.
// Query results are returned in Table Rows and are of type any.
// Type assertion is required to access the underlying value of each index in a Row.
var QueryResults []queryResult
for _, table := range res.Tables {
	QueryResults = make([]queryResult, len(table.Rows))
	for index, row := range table.Rows {
		QueryResults[index] = queryResult{
			Bool:   row[0].(bool),
			Long:   int64(row[1].(float64)),
			Double: float64(row[2].(float64)),
			String: row[3].(string),
		}
	}
}

fmt.Println(QueryResults)

// Print out Statistics
fmt.Printf("Statistics: %s", string(res.Statistics))

// Print out Visualization information
fmt.Printf("Visualization: %s", string(res.Visualization))

ClientOptions contains optional settings for Client.

type Column

Column - A column in a table.

func (Column) MarshalJSON

MarshalJSON implements the json.Marshaller interface for type Column.

func (*Column) UnmarshalJSON

UnmarshalJSON implements the json.Unmarshaller interface for type Column.

type ColumnType added in v1.0.0

ColumnType - The data type of this column.

func PossibleColumnTypeValues added in v1.0.0

PossibleColumnTypeValues returns the possible values for the ColumnType const type.

type ErrorInfo struct {
	
	Code string
	
}

ErrorInfo - The code and message for an error.

Error implements a custom error for type ErrorInfo.

UnmarshalJSON implements the json.Unmarshaller interface for type ErrorInfo.

type QueryBatchOptions struct {
}

QueryBatchOptions contains the optional parameters for the Client.QueryBatch method.

QueryBatchResponse contains the response from method Client.QueryBatch.

type QueryOptions struct {
	
	
	Statistics *bool

	
	
	Visualization *bool

	
	
	
	
	Wait *int
}

QueryOptions sets server timeout, query statistics and visualization information

QueryResourceOptions contains the optional parameters for the Client.QueryResource method.

QueryResourceResponse contains the response from method Client.QueryResource.

QueryResults - Contains the tables, columns & rows resulting from a query.

MarshalJSON implements the json.Marshaller interface for type QueryResults.

UnmarshalJSON implements the json.Unmarshaller interface for type QueryResults.

QueryWorkspaceOptions contains the optional parameters for the Client.QueryWorkspace method.

QueryWorkspaceResponse contains the response from method Client.QueryWorkspace.

Row of data in a table, types of data used by service specified in ColumnType

Table - Contains the columns and rows for one table in a query response.

MarshalJSON implements the json.Marshaller interface for type Table.

UnmarshalJSON implements the json.Unmarshaller interface for type Table.

TimeInterval specifies the time range over which to query. Use NewTimeInterval() for help formatting. Follows the ISO8601 time interval standard with most common format being startISOTime/endISOTime. ISO8601 durations also supported (ex "PT2H" for last two hours). Use UTC for all times.

NewTimeInterval creates a TimeInterval for use in a query. Use UTC for start and end times.

Values returns the interval's start and end times if it's in the format startISOTime/endISOTime, else it will return an error.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4