README
¶
Azure Workload Monitor Module for Go
The armworkloadmonitor
module provides operations for working with Azure Workload Monitor.
Getting started
Prerequisites
- an Azure subscription
- Go 1.18 or above (You could download and install the latest version of Go from here. It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this doc.)
Install the package
This project uses Go modules for versioning and dependency management.
Install the Azure Workload Monitor module:
go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/workloadmonitor/armworkloadmonitor
Authorization
When creating a client, you will need to provide a credential for authenticating with Azure Workload Monitor. The azidentity
module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more.
cred, err := azidentity.NewDefaultAzureCredential(nil)
For more information on authentication, please see the documentation for azidentity
at pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity.
Clients
Azure Workload Monitor modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential.
client, err := armworkloadmonitor.NewHealthMonitorsClient(<subscription ID>, cred, nil)
You can use ClientOptions
in package github.com/Azure/azure-sdk-for-go/sdk/azcore/arm
to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for azcore
at pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore.
options := arm.ClientOptions {
ClientOptions: azcore.ClientOptions {
Cloud: cloud.AzureChina,
},
}
client, err := armworkloadmonitor.NewHealthMonitorsClient(<subscription ID>, cred, &options)
Provide Feedback
If you encounter bugs or have suggestions, please
open an issue and assign the Workload Monitor
label.
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. For details, visit https://cla.microsoft.com.
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 ¶
- type ErrorDetails
- type ErrorResponse
- type ErrorResponseError
- type HealthMonitor
- type HealthMonitorList
- type HealthMonitorProperties
- type HealthMonitorStateChange
- type HealthMonitorStateChangeList
- type HealthMonitorStateChangeProperties
- type HealthMonitorsClient
- func (client *HealthMonitorsClient) Get(ctx context.Context, subscriptionID string, resourceGroupName string, ...) (HealthMonitorsClientGetResponse, error)
- func (client *HealthMonitorsClient) GetStateChange(ctx context.Context, subscriptionID string, resourceGroupName string, ...) (HealthMonitorsClientGetStateChangeResponse, error)
- func (client *HealthMonitorsClient) NewListPager(subscriptionID string, resourceGroupName string, providerName string, ...) *runtime.Pager[HealthMonitorsClientListResponse]
- func (client *HealthMonitorsClient) NewListStateChangesPager(subscriptionID string, resourceGroupName string, providerName string, ...) *runtime.Pager[HealthMonitorsClientListStateChangesResponse]
- type HealthMonitorsClientGetOptions
- type HealthMonitorsClientGetResponse
- type HealthMonitorsClientGetStateChangeOptions
- type HealthMonitorsClientGetStateChangeResponse
- type HealthMonitorsClientListOptions
- type HealthMonitorsClientListResponse
- type HealthMonitorsClientListStateChangesOptions
- type HealthMonitorsClientListStateChangesResponse
- type HealthState
- type Operation
- type OperationDisplay
- type OperationList
- type OperationsClient
- type OperationsClientListOptions
- type OperationsClientListResponse
- type Resource
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorDetails ¶
type ErrorDetails struct { // Error code identifying the specific error. Code *string `json:"code,omitempty"` // A human-readable error message. Message *string `json:"message,omitempty"` }
ErrorDetails - Error details
type ErrorResponse ¶
type ErrorResponse struct { // Error info. Error *ErrorResponseError `json:"error,omitempty"` }
ErrorResponse - Error response
type ErrorResponseError ¶
type ErrorResponseError struct { // Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. Code *string `json:"code,omitempty"` // Error details. Details []*ErrorDetails `json:"details,omitempty"` // Human-readable representation of the error. Message *string `json:"message,omitempty"` }
ErrorResponseError - Error info.
type HealthMonitor ¶
type HealthMonitor struct { // Properties of the monitor's health status. Properties *HealthMonitorProperties `json:"properties,omitempty"` // READ-ONLY; The resource Id. ID *string `json:"id,omitempty" azure:"ro"` // READ-ONLY; The resource name. Name *string `json:"name,omitempty" azure:"ro"` // READ-ONLY; The resource type. Type *string `json:"type,omitempty" azure:"ro"` }
HealthMonitor - Information about the monitor’s current health status.
type HealthMonitorList ¶
type HealthMonitorList struct { // Link to next page if the list is too long. NextLink *string `json:"nextLink,omitempty"` // Array of health monitors of the virtual machine. Value []*HealthMonitor `json:"value,omitempty"` }
HealthMonitorList - Information about the current health statuses of the monitors.
type HealthMonitorProperties ¶
type HealthMonitorProperties struct { // Timestamp of the monitor's last health state change. CurrentStateFirstObservedTimestamp *string `json:"currentStateFirstObservedTimestamp,omitempty"` // Timestamp of the monitor's last health evaluation. EvaluationTimestamp *string `json:"evaluationTimestamp,omitempty"` // Evidence validating the monitor's current health state. Evidence interface{} `json:"evidence,omitempty"` // Timestamp of the monitor's last reported health state. LastReportedTimestamp *string `json:"lastReportedTimestamp,omitempty"` // The configuration settings at the time of the monitor's health evaluation. MonitorConfiguration interface{} `json:"monitorConfiguration,omitempty"` // Human-readable name of the monitor. MonitorName *string `json:"monitorName,omitempty"` // Type of the monitor. MonitorType *string `json:"monitorType,omitempty"` // Dynamic monitored object of the monitor. MonitoredObject *string `json:"monitoredObject,omitempty"` // Name of the parent monitor. ParentMonitorName *string `json:"parentMonitorName,omitempty"` // READ-ONLY; Current health state of the monitor. CurrentMonitorState *HealthState `json:"currentMonitorState,omitempty" azure:"ro"` // READ-ONLY; Previous health state of the monitor. PreviousMonitorState *HealthState `json:"previousMonitorState,omitempty" azure:"ro"` }
HealthMonitorProperties - Properties of the monitor.
type HealthMonitorStateChange ¶
type HealthMonitorStateChange struct { // Properties of the monitor's state change. Properties *HealthMonitorStateChangeProperties `json:"properties,omitempty"` // READ-ONLY; The resource Id. ID *string `json:"id,omitempty" azure:"ro"` // READ-ONLY; The resource name. Name *string `json:"name,omitempty" azure:"ro"` // READ-ONLY; The resource type. Type *string `json:"type,omitempty" azure:"ro"` }
HealthMonitorStateChange - Information about the monitor’s health state change at the provided timestamp.
type HealthMonitorStateChangeList ¶
type HealthMonitorStateChangeList struct { // Link to next page if the list is too long. NextLink *string `json:"nextLink,omitempty"` // Array of health state changes within the specified time window. Value []*HealthMonitorStateChange `json:"value,omitempty"` }
HealthMonitorStateChangeList - Information about the health state changes of the monitor within the provided time window.
type HealthMonitorStateChangeProperties ¶
type HealthMonitorStateChangeProperties struct { // Timestamp of the monitor's last health state change. CurrentStateFirstObservedTimestamp *string `json:"currentStateFirstObservedTimestamp,omitempty"` // Timestamp of the monitor's last health evaluation. EvaluationTimestamp *string `json:"evaluationTimestamp,omitempty"` // Evidence validating the monitor's current health state. Evidence interface{} `json:"evidence,omitempty"` // The configuration settings at the time of the monitor's health evaluation. MonitorConfiguration interface{} `json:"monitorConfiguration,omitempty"` // Human-readable name of the monitor. MonitorName *string `json:"monitorName,omitempty"` // Type of the monitor. MonitorType *string `json:"monitorType,omitempty"` // Dynamic monitored object of the monitor. MonitoredObject *string `json:"monitoredObject,omitempty"` // READ-ONLY; Current health state of the monitor. CurrentMonitorState *HealthState `json:"currentMonitorState,omitempty" azure:"ro"` // READ-ONLY; Previous health state of the monitor. PreviousMonitorState *HealthState `json:"previousMonitorState,omitempty" azure:"ro"` }
HealthMonitorStateChangeProperties - Properties of the monitor.
type HealthMonitorsClient ¶
type HealthMonitorsClient struct {
// contains filtered or unexported fields
}
HealthMonitorsClient contains the methods for the HealthMonitors group. Don't use this type directly, use NewHealthMonitorsClient() instead.
func NewHealthMonitorsClient ¶
func NewHealthMonitorsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*HealthMonitorsClient, error)
NewHealthMonitorsClient creates a new instance of HealthMonitorsClient with the specified values. credential - used to authorize requests. Usually a credential from azidentity. options - pass nil to accept the default values.
func (*HealthMonitorsClient) Get ¶
func (client *HealthMonitorsClient) Get(ctx context.Context, subscriptionID string, resourceGroupName string, providerName string, resourceCollectionName string, resourceName string, monitorID string, options *HealthMonitorsClientGetOptions) (HealthMonitorsClientGetResponse, error)
Get - Get the current health status of a monitor of a virtual machine. Optional parameter: $expand (retrieve the monitor's evidence and configuration). If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2020-01-13-preview subscriptionID - The subscription Id of the virtual machine. resourceGroupName - The resource group of the virtual machine. providerName - The provider name (ex: Microsoft.Compute for virtual machines). resourceCollectionName - The resource collection name (ex: virtualMachines for virtual machines). resourceName - The name of the virtual machine. monitorID - The monitor Id of the virtual machine. options - HealthMonitorsClientGetOptions contains the optional parameters for the HealthMonitorsClient.Get method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/Monitor_GetDefault.json
Output:
func (*HealthMonitorsClient) GetStateChange ¶
func (client *HealthMonitorsClient) GetStateChange(ctx context.Context, subscriptionID string, resourceGroupName string, providerName string, resourceCollectionName string, resourceName string, monitorID string, timestampUnix string, options *HealthMonitorsClientGetStateChangeOptions) (HealthMonitorsClientGetStateChangeResponse, error)
GetStateChange - Get the health state change of a monitor of a virtual machine at the provided timestamp. Optional parameter: $expand (retrieve the monitor's evidence and configuration). If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2020-01-13-preview subscriptionID - The subscription Id of the virtual machine. resourceGroupName - The resource group of the virtual machine. providerName - The provider name (ex: Microsoft.Compute for virtual machines). resourceCollectionName - The resource collection name (ex: virtualMachines for virtual machines). resourceName - The name of the virtual machine. monitorID - The monitor Id of the virtual machine. timestampUnix - The timestamp of the state change (unix format). options - HealthMonitorsClientGetStateChangeOptions contains the optional parameters for the HealthMonitorsClient.GetStateChange method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorStateChange_GetDefault.json
Output:
func (*HealthMonitorsClient) NewListPager ¶ added in v0.4.0
func (client *HealthMonitorsClient) NewListPager(subscriptionID string, resourceGroupName string, providerName string, resourceCollectionName string, resourceName string, options *HealthMonitorsClientListOptions) *runtime.Pager[HealthMonitorsClientListResponse]
NewListPager - Get the current health status of all monitors of a virtual machine. Optional parameters: $expand (retrieve the monitor's evidence and configuration) and $filter (filter by monitor name). If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2020-01-13-preview subscriptionID - The subscription Id of the virtual machine. resourceGroupName - The resource group of the virtual machine. providerName - The provider name (ex: Microsoft.Compute for virtual machines). resourceCollectionName - The resource collection name (ex: virtualMachines for virtual machines). resourceName - The name of the virtual machine. options - HealthMonitorsClientListOptions contains the optional parameters for the HealthMonitorsClient.List method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorList_GetDefault.json
Output:
func (*HealthMonitorsClient) NewListStateChangesPager ¶ added in v0.4.0
func (client *HealthMonitorsClient) NewListStateChangesPager(subscriptionID string, resourceGroupName string, providerName string, resourceCollectionName string, resourceName string, monitorID string, options *HealthMonitorsClientListStateChangesOptions) *runtime.Pager[HealthMonitorsClientListStateChangesResponse]
NewListStateChangesPager - Get the health state changes of a monitor of a virtual machine within the provided time window (default is the last 24 hours). Optional parameters: $expand (retrieve the monitor's evidence and configuration) and $filter (filter by heartbeat condition). If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2020-01-13-preview subscriptionID - The subscription Id of the virtual machine. resourceGroupName - The resource group of the virtual machine. providerName - The provider name (ex: Microsoft.Compute for virtual machines). resourceCollectionName - The resource collection name (ex: virtualMachines for virtual machines). resourceName - The name of the virtual machine. monitorID - The monitor Id of the virtual machine. options - HealthMonitorsClientListStateChangesOptions contains the optional parameters for the HealthMonitorsClient.ListStateChanges method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorHistory_GetDefault.json
Output:
type HealthMonitorsClientGetOptions ¶ added in v0.2.0
type HealthMonitorsClientGetOptions struct { // Optionally expand the monitor’s evidence and/or configuration. Example: $expand=evidence,configuration. Expand *string }
HealthMonitorsClientGetOptions contains the optional parameters for the HealthMonitorsClient.Get method.
type HealthMonitorsClientGetResponse ¶ added in v0.2.0
type HealthMonitorsClientGetResponse struct {
HealthMonitor
}
HealthMonitorsClientGetResponse contains the response from method HealthMonitorsClient.Get.
type HealthMonitorsClientGetStateChangeOptions ¶ added in v0.2.0
type HealthMonitorsClientGetStateChangeOptions struct { // Optionally expand the monitor’s evidence and/or configuration. Example: $expand=evidence,configuration. Expand *string }
HealthMonitorsClientGetStateChangeOptions contains the optional parameters for the HealthMonitorsClient.GetStateChange method.
type HealthMonitorsClientGetStateChangeResponse ¶ added in v0.2.0
type HealthMonitorsClientGetStateChangeResponse struct {
HealthMonitorStateChange
}
HealthMonitorsClientGetStateChangeResponse contains the response from method HealthMonitorsClient.GetStateChange.
type HealthMonitorsClientListOptions ¶ added in v0.2.0
type HealthMonitorsClientListOptions struct { // Optionally expand the monitor’s evidence and/or configuration. Example: $expand=evidence,configuration. Expand *string // Optionally filter by monitor name. Example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb.' Filter *string }
HealthMonitorsClientListOptions contains the optional parameters for the HealthMonitorsClient.List method.
type HealthMonitorsClientListResponse ¶ added in v0.2.0
type HealthMonitorsClientListResponse struct {
HealthMonitorList
}
HealthMonitorsClientListResponse contains the response from method HealthMonitorsClient.List.
type HealthMonitorsClientListStateChangesOptions ¶ added in v0.2.0
type HealthMonitorsClientListStateChangesOptions struct { // The end of the time window. EndTimestampUTC *time.Time // Optionally expand the monitor’s evidence and/or configuration. Example: $expand=evidence,configuration. Expand *string // Optionally filter by heartbeat condition. Example: $filter=isHeartbeat eq false. Filter *string // The start of the time window. StartTimestampUTC *time.Time }
HealthMonitorsClientListStateChangesOptions contains the optional parameters for the HealthMonitorsClient.ListStateChanges method.
type HealthMonitorsClientListStateChangesResponse ¶ added in v0.2.0
type HealthMonitorsClientListStateChangesResponse struct {
HealthMonitorStateChangeList
}
HealthMonitorsClientListStateChangesResponse contains the response from method HealthMonitorsClient.ListStateChanges.
type HealthState ¶
type HealthState string
HealthState - One of health states - healthy, critical, warning, unknown, none, disabled.
const ( HealthStateCritical HealthState = "Critical" HealthStateDisabled HealthState = "Disabled" HealthStateHealthy HealthState = "Healthy" HealthStateNone HealthState = "None" HealthStateUnknown HealthState = "Unknown" HealthStateWarning HealthState = "Warning" )
func PossibleHealthStateValues ¶
func PossibleHealthStateValues() []HealthState
PossibleHealthStateValues returns the possible values for the HealthState const type.
type Operation ¶
type Operation struct { // REQUIRED; The localized display information for this particular operation or action. Display *OperationDisplay `json:"display,omitempty"` // REQUIRED; The name of the operation being performed on this particular object. Name *string `json:"name,omitempty"` // REQUIRED; The intended executor of the operation. Origin *string `json:"origin,omitempty"` }
Operation supported by the resource provider.
type OperationDisplay ¶
type OperationDisplay struct { // REQUIRED; Operation description. Description *string `json:"description,omitempty"` // REQUIRED; Human-readable, friendly name for the operation. Operation *string `json:"operation,omitempty"` // REQUIRED; Operation resource provider name. Provider *string `json:"provider,omitempty"` // REQUIRED; Resource on which the operation is performed. Resource *string `json:"resource,omitempty"` }
OperationDisplay - The localized display information for this particular operation or action.
type OperationList ¶
type OperationList struct { // Link to next page if the list is too long. NextLink *string `json:"nextLink,omitempty"` // Array of available REST API operations. Value []*Operation `json:"value,omitempty"` }
OperationList - List of available REST API operations
type OperationsClient ¶
type OperationsClient struct {
// contains filtered or unexported fields
}
OperationsClient contains the methods for the Operations group. Don't use this type directly, use NewOperationsClient() instead.
func NewOperationsClient ¶
func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error)
NewOperationsClient creates a new instance of OperationsClient with the specified values. credential - used to authorize requests. Usually a credential from azidentity. options - pass nil to accept the default values.
func (*OperationsClient) NewListPager ¶ added in v0.4.0
func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse]
NewListPager - Get a list of all available REST API operations. If the operation fails it returns an *azcore.ResponseError type. Generated from API version 2020-01-13-preview options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method.
Example ¶
Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/OperationList_Get.json
Output:
type OperationsClientListOptions ¶ added in v0.2.0
type OperationsClientListOptions struct { }
OperationsClientListOptions contains the optional parameters for the OperationsClient.List method.
type OperationsClientListResponse ¶ added in v0.2.0
type OperationsClientListResponse struct {
OperationList
}
OperationsClientListResponse contains the response from method OperationsClient.List.
type Resource ¶
type Resource struct { // READ-ONLY; The resource Id. ID *string `json:"id,omitempty" azure:"ro"` // READ-ONLY; The resource name. Name *string `json:"name,omitempty" azure:"ro"` // READ-ONLY; The resource type. Type *string `json:"type,omitempty" azure:"ro"` }
Resource - The resource model definition for the ARM proxy resource, 'microsoft.workloadmonitor/monitors'.