Class: Azure::Armrest::Insights::EventService

Inherits:
ArmrestService show all
Defined in:
lib/azure/armrest/insights/event_service.rb

Overview

Base class for managing events.

Instance Attribute Summary

Attributes inherited from ArmrestService

#api_version, #armrest_configuration, #base_url, #provider, #service_name

Instance Method Summary collapse

Methods inherited from ArmrestService

configure, #get_provider, #get_subscription, #list_locations, #list_resource_groups, #list_resources, #list_subscriptions, #locations, #poll, #tags, #tenants, #wait

Constructor Details

#initialize(armrest_configuration, options = {}) ⇒ EventService

Create and return a new EventService instance.



12
13
14
# File 'lib/azure/armrest/insights/event_service.rb', line 12

def initialize(armrest_configuration, options = {})
  super(armrest_configuration, 'eventTypes', 'Microsoft.Insights', options)
end

Instance Method Details

#list(options = {}) ⇒ Object

Returns a list of management events for the current subscription.

The filter option can be used to filter the result set. Additionally, you may restrict the results to only return certain fields using the select option. The possible fields for both filtering and selection are:

authorization, channels, claims, correlationId, description, eventDataId, eventName, eventSource, eventTimestamp, httpRequest, level, operationId, operationName, properties, resourceGroupName, resourceProviderName, resourceUri, status, submissionTimestamp, subStatus and subscriptionId.

The skip_token option can be used to grab the next batch of events when the first call reaches the maximum number of events that the API can return in one batch (API default 200). You may also set the :all option to true, in which case all batches will automatically be collected for you.

In practice you should always set a filter for eventTimestamp because you are restricted to 90 days worth of events. If you do not set the filter and/or you try to retrieve more than 90 days worth of events then you will get an error. This is a limitation of the Azure API.

Example:

ies = Azure::Armrest::Insights::EventService.new(conf)

date   = (Time.now - 86400).httpdate
filter = "eventTimestamp ge #{date} and eventChannels eq 'Admin, Operation'"
select = "resourceGroupName, operationName"

ies.list(:filter => filter, :select => select, :all => true).each{ |event|
  p event
}


51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/azure/armrest/insights/event_service.rb', line 51

def list(options = {})
  url = build_url(options)
  response = rest_get(url)

  klass  = Azure::Armrest::Insights::Event
  events = Azure::Armrest::ArmrestCollection.create_from_response(response, klass)

  if options[:all] && events.continuation_token
    events.push(*list(options.merge(:skip_token => events.continuation_token)))
    events.continuation_token = nil # Clear when finished
  end

  events
end