azquery

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 16 Imported by: 17

README

Azure Monitor Query client module for Go

The Azure Monitor Query client library is used to execute read-only queries against Azure Monitor's two data platforms:

  • Logs - Collects and organizes log and performance data from monitored resources. Data from different sources such as platform logs from Azure services, log and performance data from virtual machines agents, and usage and performance data from apps can be consolidated into a single Azure Log Analytics workspace. The various data types can be analyzed together using the Kusto Query Language. See the Kusto to SQL cheat sheet for more information.
  • Metrics - Collects numeric data from monitored resources into a time series database. Metrics are numerical values that are collected at regular intervals and describe some aspect of a system at a particular time. Metrics are lightweight and capable of supporting near real-time scenarios, making them particularly useful for alerting and fast detection of issues.

NOTE: This library is currently a beta. There may be breaking changes until it reaches semantic version v1.0.0.

Getting started

Install packages

Install azquery and azidentity with go get:

go get github.com/Azure/azure-sdk-for-go/sdk/monitor/azquery
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity

azidentity is used for Azure Active Directory authentication as demonstrated below.

Prerequisites
  • An Azure subscription
  • A supported Go version (the Azure SDK supports the two most recent Go releases)
  • For log queries, an Azure Log Analytics workspace ID.
  • For metric queries, the Resource URI of any Azure resource (Storage Account, Key Vault, CosmosDB, etc).
Authentication

This document demonstrates using azidentity.NewDefaultAzureCredential to authenticate. The client accepts any azidentity credential. See the azidentity documentation for more information about other credential types.

The clients default to the Azure Public Cloud. See the cloud documentation for more information about other cloud configurations.

Create a logs client

Example logs client: link

Create a metrics client

Example metrics client: link

Execute the query

For examples of Logs and Metrics queries, see the Examples section of this readme or in the example_test.go file of our GitHub repo for azquery.

Key concepts

Logs query rate limits and throttling

The Log Analytics service applies throttling when the request rate is too high. Limits, such as the maximum number of rows returned, are also applied on the Kusto queries. For more information, see Query API.

If you're executing a batch logs query, a throttled request will return a ErrorInfo object. That object's code value will be ThrottledError.

Metrics data structure

Each set of metric values is a time series with the following characteristics:

  • The time the value was collected
  • The resource associated with the value
  • A namespace that acts like a category for the metric
  • A metric name
  • The value itself
  • Some metrics may have multiple dimensions as described in multi-dimensional metrics. Custom metrics can have up to 10 dimensions.
Timespan

It's best practice to always query with a timespan (type TimeInterval) to prevent excessive queries of the entire logs or metrics data set. Logs uses the ISO8601 Time Interval Standard. All time should be represented in UTC. If the timespan is included in both the kusto query string and Timespan field, the timespan will be the intersection of the two values.

Use the NewTimeInterval() method for easy creation.

Example timespan: link

Examples

Logs query

The example below shows a basic logs query using the QueryWorkspace method. QueryWorkspace takes in a context, a Log Analytics Workspace ID string, a Body struct, and a LogsClientQueryWorkspaceOptions struct and returns a Results struct.

A workspace ID is required to query logs. To find the workspace ID:

  1. If not already made, create a Log Analytics 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.

Example QueryWorkspace: link

Logs query body structure
Body
|---Query *string                  // Kusto Query
|---Timespan *TimeInterval         // ISO8601 Standard Time Interval
|---AdditionalWorkspaces []*string // Optional- additional workspaces to query
Logs query result structure
Results
|---Tables []*Table
	|---Columns []*Column
		|---Name *string
		|---Type *LogsColumnType
	|---Name *string
	|---Rows []Row               // Rows contain the actual results of the query
|---Error *ErrorInfo
	|---Code *string
|---Visualization []byte
|---Statistics []byte
Batch query

QueryBatch is an advanced method allowing users to execute multiple logs queries in a single request. The method accepts a BatchRequest and returns a BatchResponse. QueryBatch can return results in any order (usually in order of completion/success). Use the CorrelationID field to identify the correct response.

Example QueryBatch: link

Batch query request structure
BatchRequest
|---Body *Body
	|---Query *string                 // Kusto Query
	|---Timespan *TimeInterval        // ISO8601 Standard Time Interval
	|---Workspaces []*string          // Optional- additional workspaces to query
|---CorrelationID *string             // unique identifier for each query in batch
|---WorkspaceID *string
|---Headers map[string]*string        // Optional- advanced query options in prefer header
|---Method *BatchQueryRequestMethod  // Optional- defaults to POST
|---Path *BatchQueryRequestPath      // Optional- defaults to /query
Batch query result structure
BatchResponse
|---Responses []*BatchQueryResponse
	|---Body *BatchQueryResults
		|---Error *ErrorInfo
			|---Code *string
		|---Visualization []byte
		|---Statistics []byte
		|---Tables []*Table
			|---Columns []*Column
				|---Name *string
				|---Type *LogsColumnType
			|---Name *string
			|---Rows []Row
	|---Headers map[string]*string
	|---CorrelationID *string
	|---Status *int32
Advanced logs query
Query multiple workspaces

To run the same query against multiple Log Analytics workspaces, add the additional workspace ID strings to the AdditionalWorkspaces slice in the Body struct.

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.

Example additional workspaces: link

Increase wait time, include statistics, include render (visualization)

The LogsQueryOptions type is used for advanced logs options.

By default, the Azure Monitor Query service will run your query for up to three minutes. To increase the default timeout, set LogsQueryOptions.Wait to desired number of seconds. Max wait time the service will allow is ten minutes (600 seconds).

To get logs query execution statistics, such as CPU and memory consumption, set LogsQueryOptions.Statistics to true.

To get visualization data for logs queries, set LogsQueryOptions.Visualization to true.

azquery.LogsClientQueryWorkspaceOptions{
			Options: &azquery.LogsQueryOptions{
				Statistics:    to.Ptr(true),
				Visualization: to.Ptr(true),
				Wait:          to.Ptr(600),
			},
		}

Example QueryWorkspace options: link

To do the same with QueryBatch, set the values in the BatchQueryRequest.Headers map with a key of "prefer".

Metrics query

You can query metrics on an Azure resource using the MetricsClient.QueryResource method. For each requested metric, a set of aggregated values is returned inside the Timeseries collection.

A resource ID is required to query metrics. 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.

Example QueryResource example: link

Metrics result structure
Response
|---Timespan *string
|---Value []*Metric
	|---ID *string
	|---Name *LocalizableString
	|---Timeseries []*TimeSeriesElement
		|---Data []*MetricValue
			|---TimeStamp *time.Time
			|---Average *float64
			|---Count *float64
			|---Maximum *float64
			|---Minimum *float64
			|---Total *float64
		|---Metadatavalues []*MetadataValue
			|---Name *LocalizableString
			|---Value *string 
	|---Type *string
	|---Unit *MetricUnit
	|---DisplayDescription *string
	|---ErrorCode *string
	|---ErrorMessage *string
|---Cost *int32
|---Interval *string
|---Namespace *string
|---Resourceregion *string
List Metric Definitions

To list the metric definitions for the resource, use the NewListDefinitionsPager method.

Example NewListDefinitionsPager: link

List Metric Namespaces

To list the metric namespaces for the resource, use the NewListNamespacesPager method.

Example NewListNamespacesPager: link

Troubleshooting

See our troubleshooting guide for details on how to diagnose various failure scenarios.

Next steps

To learn more about Azure Monitor, see the Azure Monitor service documentation.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Documentation

Index

Examples

Constants

View Source
const (
	ServiceNameLogs    cloud.ServiceName = "azqueryLogs"
	ServiceNameMetrics cloud.ServiceName = "azqueryMetrics"
)

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

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregationType

type AggregationType string

AggregationType - the aggregation type of the metric.

const (
	AggregationTypeNone    AggregationType = "None"
	AggregationTypeAverage AggregationType = "Average"
	AggregationTypeCount   AggregationType = "Count"
	AggregationTypeMinimum AggregationType = "Minimum"
	AggregationTypeMaximum AggregationType = "Maximum"
	AggregationTypeTotal   AggregationType = "Total"
)

func PossibleAggregationTypeValues

func PossibleAggregationTypeValues() []AggregationType

PossibleAggregationTypeValues returns the possible values for the AggregationType const type.

type BatchQueryRequest

type BatchQueryRequest struct {
	// REQUIRED; The Analytics query. Learn more about the Analytics query syntax [https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/]
	Body *Body `json:"body,omitempty"`

	// REQUIRED; Unique ID corresponding to each request in the batch
	CorrelationID *string `json:"id,omitempty"`

	// REQUIRED; Primary Workspace ID of the query
	WorkspaceID *string `json:"workspace,omitempty"`

	// Optional. Headers of the request. Can use prefer header to set server timeout, query statistics and visualization information.
	// For more information, see
	// https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/monitor/azquery#readme-increase-wait-time-include-statistics-include-render-visualization
	Headers map[string]*string `json:"headers,omitempty"`

	// The method of a single request in a batch, defaults to POST
	Method *BatchQueryRequestMethod `json:"method,omitempty"`

	// The query path of a single request in a batch, defaults to /query
	Path *BatchQueryRequestPath `json:"path,omitempty"`
}

BatchQueryRequest - An single request in a batch.

func NewBatchQueryRequest added in v0.4.0

func NewBatchQueryRequest(workspaceID string, query string, timespan TimeInterval, correlationID string, options LogsQueryOptions) BatchQueryRequest

NewBatchQueryRequest creates a new BatchQueryRequest.

func (BatchQueryRequest) MarshalJSON

func (b BatchQueryRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type BatchQueryRequest.

func (*BatchQueryRequest) UnmarshalJSON

func (b *BatchQueryRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type BatchQueryRequest.

type BatchQueryRequestMethod

type BatchQueryRequestMethod string

BatchQueryRequestMethod - The method of a single request in a batch, defaults to POST

const (
	BatchQueryRequestMethodPOST BatchQueryRequestMethod = "POST"
)

func PossibleBatchQueryRequestMethodValues

func PossibleBatchQueryRequestMethodValues() []BatchQueryRequestMethod

PossibleBatchQueryRequestMethodValues returns the possible values for the BatchQueryRequestMethod const type.

type BatchQueryRequestPath

type BatchQueryRequestPath string

BatchQueryRequestPath - The query path of a single request in a batch, defaults to /query

const (
	BatchQueryRequestPathQuery BatchQueryRequestPath = "/query"
)

func PossibleBatchQueryRequestPathValues

func PossibleBatchQueryRequestPathValues() []BatchQueryRequestPath

PossibleBatchQueryRequestPathValues returns the possible values for the BatchQueryRequestPath const type.

type BatchQueryResponse

type BatchQueryResponse struct {
	// Contains the tables, columns & rows resulting from a query.
	Body          *BatchQueryResults `json:"body,omitempty"`
	CorrelationID *string            `json:"id,omitempty"`

	// Dictionary of
	Headers map[string]*string `json:"headers,omitempty"`
	Status  *int32             `json:"status,omitempty"`
}

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

func (BatchQueryResponse) MarshalJSON

func (b BatchQueryResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type BatchQueryResponse.

func (*BatchQueryResponse) UnmarshalJSON

func (b *BatchQueryResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type BatchQueryResponse.

type BatchQueryResults

type BatchQueryResults struct {
	// The code and message for an error.
	Error *ErrorInfo `json:"error,omitempty"`

	// Statistics represented in JSON format.
	Statistics []byte `json:"statistics,omitempty"`

	// The list of tables, columns and rows.
	Tables []*Table `json:"tables,omitempty"`

	// Visualization data in JSON format.
	Visualization []byte `json:"render,omitempty"`
}

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

func (BatchQueryResults) MarshalJSON

func (b BatchQueryResults) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type BatchQueryResults.

func (*BatchQueryResults) UnmarshalJSON

func (b *BatchQueryResults) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type BatchQueryResults.

type BatchRequest

type BatchRequest struct {
	// REQUIRED; An single request in a batch.
	Requests []*BatchQueryRequest `json:"requests,omitempty"`
}

BatchRequest - An array of requests.

func (BatchRequest) MarshalJSON

func (b BatchRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type BatchRequest.

func (*BatchRequest) UnmarshalJSON

func (b *BatchRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type BatchRequest.

type BatchResponse

type BatchResponse struct {
	// An array of responses corresponding to each individual request in a batch.
	Responses []*BatchQueryResponse `json:"responses,omitempty"`
}

BatchResponse - Response to a batch query.

func (BatchResponse) MarshalJSON

func (b BatchResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type BatchResponse.

func (*BatchResponse) UnmarshalJSON

func (b *BatchResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type BatchResponse.

type Body

type Body struct {
	// REQUIRED; The query to execute.
	Query *string `json:"query,omitempty"`

	// A list of workspaces to query in addition to the primary workspace.
	AdditionalWorkspaces []*string `json:"workspaces,omitempty"`

	// Optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition
	// to any that are specified in the query expression.
	Timespan *TimeInterval `json:"timespan,omitempty"`
}

Body - The Analytics query. Learn more about the Analytics query syntax [https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/]

func (Body) MarshalJSON

func (b Body) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Body.

func (*Body) UnmarshalJSON

func (b *Body) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Body.

type Column

type Column struct {
	// The name of this column.
	Name *string `json:"name,omitempty"`

	// The data type of this column.
	Type *LogsColumnType `json:"type,omitempty"`
}

Column - A column in a table.

func (Column) MarshalJSON

func (c Column) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Column.

func (*Column) UnmarshalJSON

func (c *Column) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Column.

type ErrorInfo

type ErrorInfo struct {
	// REQUIRED; A machine readable error code.
	Code string
	// contains filtered or unexported fields
}

ErrorInfo - The code and message for an error.

func (*ErrorInfo) Error added in v0.2.0

func (e *ErrorInfo) Error() string

Error implements a custom error for type ErrorInfo.

func (*ErrorInfo) UnmarshalJSON

func (e *ErrorInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ErrorInfo.

type LocalizableString

type LocalizableString struct {
	// REQUIRED; the invariant value.
	Value *string `json:"value,omitempty"`

	// the locale specific value.
	LocalizedValue *string `json:"localizedValue,omitempty"`
}

LocalizableString - The localizable string class.

func (LocalizableString) MarshalJSON

func (l LocalizableString) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type LocalizableString.

func (*LocalizableString) UnmarshalJSON

func (l *LocalizableString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type LocalizableString.

type LogsClient

type LogsClient struct {
	// contains filtered or unexported fields
}

LogsClient contains the methods for the LogsClient group. Don't use this type directly, use NewLogsClient() instead.

func NewLogsClient

func NewLogsClient(credential azcore.TokenCredential, options *LogsClientOptions) (*LogsClient, error)

NewLogsClient creates a client that accesses Azure Monitor logs data.

Example
package main

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

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

	client, err := azquery.NewLogsClient(cred, nil)
	if err != nil {
		//TODO: handle error
	}
	_ = client
}
Output:

func (*LogsClient) QueryBatch added in v0.3.0

QueryBatch - Executes a batch of Analytics queries for data. Here [https://dev.loganalytics.io/documentation/Using-the-API] is an example for using POST with an Analytics query. If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2021-05-19_Preview body - The batch request body options - LogsClientQueryBatchOptions contains the optional parameters for the LogsClient.QueryBatch method.

Example
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/azquery"
)

var logsClient azquery.LogsClient

var kustoQuery1 string
var kustoQuery2 string
var kustoQuery3 string

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

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

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

	responses := res.BatchResponse.Responses
	fmt.Println("ID's of successful responses:")
	for _, response := range responses {
		if response.Body.Error == nil {
			fmt.Println(*response.CorrelationID)
		}
	}
}
Output:

func (*LogsClient) QueryWorkspace

func (client *LogsClient) QueryWorkspace(ctx context.Context, workspaceID string, body Body, options *LogsClientQueryWorkspaceOptions) (LogsClientQueryWorkspaceResponse, error)

QueryWorkspace - Executes an Analytics query for data. Here [https://dev.loganalytics.io/documentation/Using-the-API] is an example for using POST with an Analytics query. If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2021-05-19_Preview workspaceID - Primary Workspace ID of the query. This is Workspace ID from the Properties blade in the Azure portal body - The Analytics query. Learn more about the Analytics query syntax [https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/] options - LogsClientQueryWorkspaceOptions contains the optional parameters for the LogsClient.QueryWorkspace method.

Example
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/azquery"
)

var logsClient azquery.LogsClient

func main() {
	// Basic QueryWorkspace example

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

	res, err := logsClient.QueryWorkspace(
		context.TODO(),
		workspaceID,
		azquery.Body{
			Query:    to.Ptr("AzureActivity | top 10 by TimeGenerated"), // example Kusto query
			Timespan: to.Ptr(azquery.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)
		}
	}
}
Output:

Example (Second)
// Advanced QueryWorkspace Example

workspaceID1 := "g4d1e129-fb1e-4b0a-b234-250abc987ea65" // example Azure Log Analytics Workspace ID
workspaceID2 := "h4bc4471-2e8c-4b1c-8f47-12b9a4d5ac71"

res, err := logsClient.QueryWorkspace(
	context.TODO(),
	workspaceID1,
	azquery.Body{
		Query:                to.Ptr(query),
		Timespan:             to.Ptr(azquery.NewTimeInterval(time.Date(2022, 12, 25, 0, 0, 0, 0, time.UTC), time.Date(2022, 12, 25, 12, 0, 0, 0, time.UTC))),
		AdditionalWorkspaces: []*string{to.Ptr(workspaceID2)},
	},
	to.Ptr(azquery.LogsClientQueryWorkspaceOptions{
		Options: &azquery.LogsQueryOptions{
			Statistics:    to.Ptr(true),
			Visualization: to.Ptr(true),
			Wait:          to.Ptr(600),
		},
	}))
if err != nil {
	//TODO: handle error
}
if res.Error != nil {
	//TODO: handle partial error
}

// Example of converting table data into a slice of structs
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)
Output:

type LogsClientOptions

type LogsClientOptions struct {
	azcore.ClientOptions
}

LogsClientOptions contains optional settings for LogsClient.

type LogsClientQueryBatchOptions added in v0.3.0

type LogsClientQueryBatchOptions struct {
}

LogsClientQueryBatchOptions contains the optional parameters for the LogsClient.QueryBatch method.

type LogsClientQueryBatchResponse added in v0.3.0

type LogsClientQueryBatchResponse struct {
	BatchResponse
}

LogsClientQueryBatchResponse contains the response from method LogsClient.QueryBatch.

type LogsClientQueryWorkspaceOptions

type LogsClientQueryWorkspaceOptions struct {
	// Optional. The prefer header to set server timeout, query statistics and visualization information.
	Options *LogsQueryOptions
}

LogsClientQueryWorkspaceOptions contains the optional parameters for the LogsClient.QueryWorkspace method.

type LogsClientQueryWorkspaceResponse

type LogsClientQueryWorkspaceResponse struct {
	Results
}

LogsClientQueryWorkspaceResponse contains the response from method LogsClient.QueryWorkspace.

type LogsColumnType

type LogsColumnType string

LogsColumnType - The data type of this column.

const (
	LogsColumnTypeBool     LogsColumnType = "bool"
	LogsColumnTypeDatetime LogsColumnType = "datetime"
	LogsColumnTypeDecimal  LogsColumnType = "decimal"
	LogsColumnTypeDynamic  LogsColumnType = "dynamic"
	LogsColumnTypeGUID     LogsColumnType = "guid"
	LogsColumnTypeInt      LogsColumnType = "int"
	LogsColumnTypeLong     LogsColumnType = "long"
	LogsColumnTypeReal     LogsColumnType = "real"
	LogsColumnTypeString   LogsColumnType = "string"
	LogsColumnTypeTimespan LogsColumnType = "timespan"
)

func PossibleLogsColumnTypeValues

func PossibleLogsColumnTypeValues() []LogsColumnType

PossibleLogsColumnTypeValues returns the possible values for the LogsColumnType const type.

type LogsQueryOptions added in v0.4.0

type LogsQueryOptions struct {
	// Set Statistics to true to get logs query execution statistics,
	// such as CPU and memory consumption. Defaults to false.
	Statistics *bool

	// Set Visualization to true to get visualization
	// data for logs queries. Defaults to false.
	Visualization *bool

	// By default, the Azure Monitor Query service will run your
	// query for up to three minutes. To increase the default timeout,
	// set Wait to desired number of seconds.
	// Max wait time the service will allow is ten minutes (600 seconds).
	Wait *int
}

LogsQueryOptions sets server timeout, query statistics and visualization information

func (LogsQueryOptions) String added in v0.4.0

func (l LogsQueryOptions) String() string

String implements the fmt.Stringer interface for type LogsQueryOptions.

type MetadataValue

type MetadataValue struct {
	// the name of the metadata.
	Name *LocalizableString `json:"name,omitempty"`

	// the value of the metadata.
	Value *string `json:"value,omitempty"`
}

MetadataValue - Represents a metric metadata value.

func (MetadataValue) MarshalJSON

func (m MetadataValue) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type MetadataValue.

func (*MetadataValue) UnmarshalJSON

func (m *MetadataValue) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type MetadataValue.

type Metric

type Metric struct {
	// REQUIRED; the metric Id.
	ID *string `json:"id,omitempty"`

	// REQUIRED; the name and the display name of the metric, i.e. it is localizable string.
	Name *LocalizableString `json:"name,omitempty"`

	// REQUIRED; the time series returned when a data query is performed.
	Timeseries []*TimeSeriesElement `json:"timeseries,omitempty"`

	// REQUIRED; the resource type of the metric resource.
	Type *string `json:"type,omitempty"`

	// REQUIRED; The unit of the metric.
	Unit *MetricUnit `json:"unit,omitempty"`

	// Detailed description of this metric.
	DisplayDescription *string `json:"displayDescription,omitempty"`

	// 'Success' or the error details on query failures for this metric.
	ErrorCode *string `json:"errorCode,omitempty"`

	// Error message encountered querying this specific metric.
	ErrorMessage *string `json:"errorMessage,omitempty"`
}

Metric - The result data of a query.

func (Metric) MarshalJSON

func (m Metric) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Metric.

func (*Metric) UnmarshalJSON

func (m *Metric) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Metric.

type MetricAvailability

type MetricAvailability struct {
	// the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc.
	Retention *string `json:"retention,omitempty"`

	// the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc.
	TimeGrain *string `json:"timeGrain,omitempty"`
}

MetricAvailability - Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain.

func (MetricAvailability) MarshalJSON

func (m MetricAvailability) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type MetricAvailability.

func (*MetricAvailability) UnmarshalJSON

func (m *MetricAvailability) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type MetricAvailability.

type MetricClass

type MetricClass string

MetricClass - The class of the metric.

const (
	MetricClassAvailability MetricClass = "Availability"
	MetricClassErrors       MetricClass = "Errors"
	MetricClassLatency      MetricClass = "Latency"
	MetricClassSaturation   MetricClass = "Saturation"
	MetricClassTransactions MetricClass = "Transactions"
)

func PossibleMetricClassValues

func PossibleMetricClassValues() []MetricClass

PossibleMetricClassValues returns the possible values for the MetricClass const type.

type MetricDefinition

type MetricDefinition struct {
	// Custom category name for this metric.
	Category *string `json:"category,omitempty"`

	// the name and the display name of the dimension, i.e. it is a localizable string.
	Dimensions []*LocalizableString `json:"dimensions,omitempty"`

	// Detailed description of this metric.
	DisplayDescription *string `json:"displayDescription,omitempty"`

	// the resource identifier of the metric definition.
	ID *string `json:"id,omitempty"`

	// Flag to indicate whether the dimension is required.
	IsDimensionRequired *bool `json:"isDimensionRequired,omitempty"`

	// the collection of what aggregation intervals are available to be queried.
	MetricAvailabilities []*MetricAvailability `json:"metricAvailabilities,omitempty"`

	// The class of the metric.
	MetricClass *MetricClass `json:"metricClass,omitempty"`

	// the name and the display name of the metric, i.e. it is a localizable string.
	Name *LocalizableString `json:"name,omitempty"`

	// the namespace the metric belongs to.
	Namespace *string `json:"namespace,omitempty"`

	// the primary aggregation type value defining how to use the values for display.
	PrimaryAggregationType *AggregationType `json:"primaryAggregationType,omitempty"`

	// the resource identifier of the resource that emitted the metric.
	ResourceID *string `json:"resourceId,omitempty"`

	// the collection of what aggregation types are supported.
	SupportedAggregationTypes []*AggregationType `json:"supportedAggregationTypes,omitempty"`

	// The unit of the metric.
	Unit *MetricUnit `json:"unit,omitempty"`
}

MetricDefinition - Metric definition class specifies the metadata for a metric.

func (MetricDefinition) MarshalJSON

func (m MetricDefinition) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type MetricDefinition.

func (*MetricDefinition) UnmarshalJSON

func (m *MetricDefinition) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type MetricDefinition.

type MetricDefinitionCollection

type MetricDefinitionCollection struct {
	// REQUIRED; the values for the metric definitions.
	Value []*MetricDefinition `json:"value,omitempty"`
}

MetricDefinitionCollection - Represents collection of metric definitions.

func (MetricDefinitionCollection) MarshalJSON

func (m MetricDefinitionCollection) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type MetricDefinitionCollection.

func (*MetricDefinitionCollection) UnmarshalJSON

func (m *MetricDefinitionCollection) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type MetricDefinitionCollection.

type MetricNamespace

type MetricNamespace struct {
	// Kind of namespace
	Classification *NamespaceClassification `json:"classification,omitempty"`

	// The ID of the metric namespace.
	ID *string `json:"id,omitempty"`

	// The escaped name of the namespace.
	Name *string `json:"name,omitempty"`

	// Properties which include the fully qualified namespace name.
	Properties *MetricNamespaceName `json:"properties,omitempty"`

	// The type of the namespace.
	Type *string `json:"type,omitempty"`
}

MetricNamespace - Metric namespace class specifies the metadata for a metric namespace.

func (MetricNamespace) MarshalJSON

func (m MetricNamespace) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type MetricNamespace.

func (*MetricNamespace) UnmarshalJSON

func (m *MetricNamespace) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type MetricNamespace.

type MetricNamespaceCollection

type MetricNamespaceCollection struct {
	// REQUIRED; The values for the metric namespaces.
	Value []*MetricNamespace `json:"value,omitempty"`
}

MetricNamespaceCollection - Represents collection of metric namespaces.

func (MetricNamespaceCollection) MarshalJSON

func (m MetricNamespaceCollection) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type MetricNamespaceCollection.

func (*MetricNamespaceCollection) UnmarshalJSON

func (m *MetricNamespaceCollection) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type MetricNamespaceCollection.

type MetricNamespaceName

type MetricNamespaceName struct {
	// The metric namespace name.
	MetricNamespaceName *string `json:"metricNamespaceName,omitempty"`
}

MetricNamespaceName - The fully qualified metric namespace name.

func (MetricNamespaceName) MarshalJSON

func (m MetricNamespaceName) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type MetricNamespaceName.

func (*MetricNamespaceName) UnmarshalJSON

func (m *MetricNamespaceName) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type MetricNamespaceName.

type MetricUnit

type MetricUnit string

MetricUnit - The unit of the metric.

const (
	MetricUnitBitsPerSecond  MetricUnit = "BitsPerSecond"
	MetricUnitByteSeconds    MetricUnit = "ByteSeconds"
	MetricUnitBytes          MetricUnit = "Bytes"
	MetricUnitBytesPerSecond MetricUnit = "BytesPerSecond"
	MetricUnitCores          MetricUnit = "Cores"
	MetricUnitCount          MetricUnit = "Count"
	MetricUnitCountPerSecond MetricUnit = "CountPerSecond"
	MetricUnitMilliCores     MetricUnit = "MilliCores"
	MetricUnitMilliSeconds   MetricUnit = "MilliSeconds"
	MetricUnitNanoCores      MetricUnit = "NanoCores"
	MetricUnitPercent        MetricUnit = "Percent"
	MetricUnitSeconds        MetricUnit = "Seconds"
	MetricUnitUnspecified    MetricUnit = "Unspecified"
)

func PossibleMetricUnitValues

func PossibleMetricUnitValues() []MetricUnit

PossibleMetricUnitValues returns the possible values for the MetricUnit const type.

type MetricValue

type MetricValue struct {
	// REQUIRED; the timestamp for the metric value in ISO 8601 format.
	TimeStamp *time.Time `json:"timeStamp,omitempty"`

	// the average value in the time range.
	Average *float64 `json:"average,omitempty"`

	// the number of samples in the time range. Can be used to determine the number of values that contributed to the average
	// value.
	Count *float64 `json:"count,omitempty"`

	// the greatest value in the time range.
	Maximum *float64 `json:"maximum,omitempty"`

	// the least value in the time range.
	Minimum *float64 `json:"minimum,omitempty"`

	// the sum of all of the values in the time range.
	Total *float64 `json:"total,omitempty"`
}

MetricValue - Represents a metric value.

func (MetricValue) MarshalJSON

func (m MetricValue) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type MetricValue.

func (*MetricValue) UnmarshalJSON

func (m *MetricValue) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type MetricValue.

type MetricsClient

type MetricsClient struct {
	// contains filtered or unexported fields
}

MetricsClient contains the methods for the Metrics group. Don't use this type directly, use NewMetricsClient() instead.

func NewMetricsClient

func NewMetricsClient(credential azcore.TokenCredential, options *MetricsClientOptions) (*MetricsClient, error)

NewMetricsClient creates a client that accesses Azure Monitor metrics data.

Example
package main

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

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

	client, err := azquery.NewMetricsClient(cred, nil)
	if err != nil {
		//TODO: handle error
	}
	_ = client
}
Output:

func (*MetricsClient) NewListDefinitionsPager added in v0.3.0

func (client *MetricsClient) NewListDefinitionsPager(resourceURI string, options *MetricsClientListDefinitionsOptions) *runtime.Pager[MetricsClientListDefinitionsResponse]

NewListDefinitionsPager - Lists the metric definitions for the resource. Generated from API version 2018-01-01 resourceURI - The identifier of the resource. options - MetricsClientListDefinitionsOptions contains the optional parameters for the MetricsClient.ListDefinitions method.

Example
package main

import (
	"context"

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

var metricsClient azquery.MetricsClient

func main() {
	pager := metricsClient.NewListDefinitionsPager("subscriptions/182c901a-129a-4f5d-86e4-cc6b294590a2/resourceGroups/hyr-log/providers/microsoft.insights/components/f1-bill/providers/microsoft.insights/metricdefinitions", &azquery.MetricsClientListDefinitionsOptions{Metricnamespace: to.Ptr("microsoft.insights/components")})
	for pager.More() {
		nextResult, err := pager.NextPage(context.TODO())
		if err != nil {
			//TODO: handle error
		}
		for _, v := range nextResult.Value {
			// TODO: use page item
			_ = v
		}
	}
}
Output:

func (*MetricsClient) NewListNamespacesPager added in v0.3.0

func (client *MetricsClient) NewListNamespacesPager(resourceURI string, options *MetricsClientListNamespacesOptions) *runtime.Pager[MetricsClientListNamespacesResponse]

NewListNamespacesPager - Lists the metric namespaces for the resource. Generated from API version 2017-12-01-preview resourceURI - The identifier of the resource. options - MetricsClientListNamespacesOptions contains the optional parameters for the MetricsClient.ListNamespaces method.

Example
package main

import (
	"context"

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

var metricsClient azquery.MetricsClient

func main() {
	pager := metricsClient.NewListNamespacesPager("subscriptions/182c901a-129a-4f5d-86e4-cc6b294590a2/resourceGroups/hyr-log/providers/microsoft.insights/components/f1-bill", &azquery.MetricsClientListNamespacesOptions{StartTime: to.Ptr("2020-08-31T15:53:00Z")})
	for pager.More() {
		nextResult, err := pager.NextPage(context.TODO())
		if err != nil {
			//TODO: handle error
		}
		for _, v := range nextResult.Value {
			// TODO: use page item
			_ = v
		}
	}
}
Output:

func (*MetricsClient) QueryResource

QueryResource - Lists the metric values for a resource. If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2018-01-01 resourceURI - The identifier of the resource. options - MetricsClientQueryResourceOptions contains the optional parameters for the MetricsClient.QueryResource method.

Example
res, err := metricsClient.QueryResource(context.TODO(), resourceURI,
	&azquery.MetricsClientQueryResourceOptions{
		Timespan:        to.Ptr(azquery.NewTimeInterval(time.Date(2022, 12, 25, 0, 0, 0, 0, time.UTC), time.Date(2022, 12, 25, 12, 0, 0, 0, time.UTC))),
		Interval:        to.Ptr("PT1M"),
		Metricnames:     nil,
		Aggregation:     to.Ptr("Average,count"),
		Top:             to.Ptr[int32](3),
		Orderby:         to.Ptr("Average asc"),
		Filter:          to.Ptr("BlobType eq '*'"),
		ResultType:      nil,
		Metricnamespace: to.Ptr("Microsoft.Storage/storageAccounts/blobServices"),
	})
if err != nil {
	//TODO: handle error
}
_ = res
Output:

type MetricsClientListDefinitionsOptions added in v0.3.0

type MetricsClientListDefinitionsOptions struct {
	// Metric namespace to query metric definitions for.
	Metricnamespace *string
}

MetricsClientListDefinitionsOptions contains the optional parameters for the MetricsClient.ListDefinitions method.

type MetricsClientListDefinitionsResponse added in v0.3.0

type MetricsClientListDefinitionsResponse struct {
	MetricDefinitionCollection
}

MetricsClientListDefinitionsResponse contains the response from method MetricsClient.ListDefinitions.

type MetricsClientListNamespacesOptions added in v0.3.0

type MetricsClientListNamespacesOptions struct {
	// The ISO 8601 conform Date start time from which to query for metric namespaces.
	StartTime *string
}

MetricsClientListNamespacesOptions contains the optional parameters for the MetricsClient.ListNamespaces method.

type MetricsClientListNamespacesResponse added in v0.3.0

type MetricsClientListNamespacesResponse struct {
	MetricNamespaceCollection
}

MetricsClientListNamespacesResponse contains the response from method MetricsClient.ListNamespaces.

type MetricsClientOptions

type MetricsClientOptions struct {
	azcore.ClientOptions
}

MetricsClientOptions contains optional settings for MetricsClient.

type MetricsClientQueryResourceOptions

type MetricsClientQueryResourceOptions struct {
	// The list of aggregation types (comma separated) to retrieve.
	Aggregation *string
	// The $filter is used to reduce the set of metric data returned. Example: Metric contains metadata A, B and C. - Return all
	// time series of C where A = a1 and B = b1 or b2 $filter=A eq 'a1' and B eq 'b1'
	// or B eq 'b2' and C eq ” - Invalid variant: $filter=A eq 'a1' and B eq 'b1' and C eq ” or B = 'b2' This is invalid because
	// the logical or operator cannot separate two different metadata names. -
	// Return all time series where A = a1, B = b1 and C = c1: $filter=A eq 'a1' and B eq 'b1' and C eq 'c1' - Return all time
	// series where A = a1 $filter=A eq 'a1' and B eq ” and C eq ”. Special case:
	// When dimension name or dimension value uses round brackets. Eg: When dimension name is dim (test) 1 Instead of using $filter=
	// "dim (test) 1 eq ” " use $filter= "dim %2528test%2529 1 eq ” " When
	// dimension name is dim (test) 3 and dimension value is dim3 (test) val Instead of using $filter= "dim (test) 3 eq 'dim3
	// (test) val' " use $filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "
	Filter *string
	// The interval (i.e. timegrain) of the query.
	Interval *string
	// The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use
	// %2 to indicate it. Eg: 'Metric,Name1' should be 'Metric%2Name1'
	Metricnames *string
	// Metric namespace to query metric definitions for.
	Metricnamespace *string
	// The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. Examples: sum
	// asc.
	Orderby *string
	// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details.
	ResultType *ResultType
	// The timespan of the query. It is a string with the following format 'startDateTimeISO/endDateTimeISO'.
	Timespan *TimeInterval
	// The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10.
	Top *int32
}

MetricsClientQueryResourceOptions contains the optional parameters for the MetricsClient.QueryResource method.

type MetricsClientQueryResourceResponse

type MetricsClientQueryResourceResponse struct {
	Response
}

MetricsClientQueryResourceResponse contains the response from method MetricsClient.QueryResource.

type NamespaceClassification

type NamespaceClassification string

NamespaceClassification - Kind of namespace

const (
	NamespaceClassificationCustom   NamespaceClassification = "Custom"
	NamespaceClassificationPlatform NamespaceClassification = "Platform"
	NamespaceClassificationQos      NamespaceClassification = "Qos"
)

func PossibleNamespaceClassificationValues

func PossibleNamespaceClassificationValues() []NamespaceClassification

PossibleNamespaceClassificationValues returns the possible values for the NamespaceClassification const type.

type Response

type Response struct {
	// REQUIRED; The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by
	// '/'. This may be adjusted in the future and returned back from what was originally
	// requested.
	Timespan *TimeInterval `json:"timespan,omitempty"`

	// REQUIRED; the value of the collection.
	Value []*Metric `json:"value,omitempty"`

	// The integer value representing the relative cost of the query.
	Cost *int32 `json:"cost,omitempty"`

	// The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back
	// from what was originally requested. This is not present if a metadata request
	// was made.
	Interval *string `json:"interval,omitempty"`

	// The namespace of the metrics being queried
	Namespace *string `json:"namespace,omitempty"`

	// The region of the resource being queried for metrics.
	Resourceregion *string `json:"resourceregion,omitempty"`
}

Response - The response to a metrics query.

func (Response) MarshalJSON

func (r Response) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Response.

func (*Response) UnmarshalJSON

func (r *Response) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Response.

type ResultType

type ResultType string

ResultType - Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details.

const (
	ResultTypeData     ResultType = "Data"
	ResultTypeMetadata ResultType = "Metadata"
)

func PossibleResultTypeValues

func PossibleResultTypeValues() []ResultType

PossibleResultTypeValues returns the possible values for the ResultType const type.

type Results

type Results struct {
	// REQUIRED; The list of tables, columns and rows.
	Tables []*Table `json:"tables,omitempty"`

	// The code and message for an error.
	Error *ErrorInfo `json:"error,omitempty"`

	// Statistics represented in JSON format.
	Statistics []byte `json:"statistics,omitempty"`

	// Visualization data in JSON format.
	Visualization []byte `json:"render,omitempty"`
}

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

func (Results) MarshalJSON

func (r Results) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Results.

func (*Results) UnmarshalJSON

func (r *Results) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Results.

type Row added in v0.3.0

type Row []any

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

type Table

type Table struct {
	// REQUIRED; The list of columns in this table.
	Columns []*Column `json:"columns,omitempty"`

	// REQUIRED; The name of the table.
	Name *string `json:"name,omitempty"`

	// REQUIRED; The resulting rows from this query.
	Rows []Row `json:"rows,omitempty"`
}

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

func (Table) MarshalJSON

func (t Table) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Table.

func (*Table) UnmarshalJSON

func (t *Table) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Table.

type TimeInterval added in v0.4.0

type TimeInterval string

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.

func NewTimeInterval added in v0.4.0

func NewTimeInterval(start time.Time, end time.Time) TimeInterval

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

func (TimeInterval) Values added in v0.4.0

func (i TimeInterval) Values() (time.Time, time.Time, error)

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

type TimeSeriesElement

type TimeSeriesElement struct {
	// An array of data points representing the metric values. This is only returned if a result type of data is specified.
	Data []*MetricValue `json:"data,omitempty"`

	// the metadata values returned if $filter was specified in the call.
	Metadatavalues []*MetadataValue `json:"metadatavalues,omitempty"`
}

TimeSeriesElement - A time series result type. The discriminator value is always TimeSeries in this case.

func (TimeSeriesElement) MarshalJSON

func (t TimeSeriesElement) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type TimeSeriesElement.

func (*TimeSeriesElement) UnmarshalJSON

func (t *TimeSeriesElement) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type TimeSeriesElement.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL