Class: LogStash::Outputs::MicrosoftSentinelOutputInternal::LogAnalyticsClient
- Inherits:
-
Object
- Object
- LogStash::Outputs::MicrosoftSentinelOutputInternal::LogAnalyticsClient
- Defined in:
- lib/logstash/sentinel_la/logAnalyticsClient.rb
Class Method Summary collapse
-
.is_successfully_posted(response) ⇒ Object
Static function to return if the response is OK or else.
Instance Method Summary collapse
-
#initialize(logstashLoganalyticsConfiguration) ⇒ LogAnalyticsClient
constructor
A new instance of LogAnalyticsClient.
-
#post_data(body) ⇒ Object
Post the given json to Azure Loganalytics.
Constructor Details
#initialize(logstashLoganalyticsConfiguration) ⇒ LogAnalyticsClient
Returns a new instance of LogAnalyticsClient.
17 18 19 20 21 22 23 24 25 |
# File 'lib/logstash/sentinel_la/logAnalyticsClient.rb', line 17 def initialize (logstashLoganalyticsConfiguration) @logstashLoganalyticsConfiguration = logstashLoganalyticsConfiguration @logger = @logstashLoganalyticsConfiguration.logger la_api_version = "2023-01-01" @uri = sprintf("%s/dataCollectionRules/%s/streams/%s?api-version=%s",@logstashLoganalyticsConfiguration.data_collection_endpoint, @logstashLoganalyticsConfiguration.dcr_immutable_id, logstashLoganalyticsConfiguration.dcr_stream_name, la_api_version) @aadTokenProvider=LogAnalyticsAadTokenProvider::new(logstashLoganalyticsConfiguration) @userAgent = getUserAgent() end |
Class Method Details
.is_successfully_posted(response) ⇒ Object
Static function to return if the response is OK or else
41 42 43 |
# File 'lib/logstash/sentinel_la/logAnalyticsClient.rb', line 41 def self.is_successfully_posted(response) return (response.code >= 200 && response.code < 300 ) ? true : false end |
Instance Method Details
#post_data(body) ⇒ Object
Post the given json to Azure Loganalytics
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/logstash/sentinel_la/logAnalyticsClient.rb', line 28 def post_data(body) raise ConfigError, 'no json_records' if body.empty? # Create REST request header headers = get_header() # Post REST request return RestClient::Request.execute(method: :post, url: @uri, payload: body, headers: headers, proxy: @logstashLoganalyticsConfiguration.proxy_endpoint, timeout: 120) end |