azure-loganalytics-datacollector-api 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ff34cda0c8aa57ecc7b124abb610d846e1d7f123
4
- data.tar.gz: 9d52dd208fa123e83cfd0b6b60c2c8c60df3022a
2
+ SHA256:
3
+ metadata.gz: f69486484bc9d5e52f6ecaf48c049ff178f85594a1ff83a9c1922db1a30666bc
4
+ data.tar.gz: c4b1c23ccc77e0273b1447ae5464279270f05ca3f96d2f0e8d2d9e516d198758
5
5
  SHA512:
6
- metadata.gz: a495b5e29998532540f558c9d9b98a3e503dd68d70e6ceda81072cec7e71f3fcbfb479c138f1d86a266809e0b7167ab6906ec0e2dfdaaf1939c716ce7b84be2f
7
- data.tar.gz: ca45575e8a867e9d00b5eab40ead381b20a4009c93aff12d9b000c0f50ddbd85103233b4033d29d8564d37aca70e35832e7301ef32d8ab61513c866b25091d91
6
+ metadata.gz: 1e5dd0c8db1d44a861d2506200d7f93b668ac3d8d8a444bea73bed0e464166aa4c194f123a7482e007ed4a67da01ce5aea60933aa95cd667b04a32bdcba3591e
7
+ data.tar.gz: 72d70760c358307f6b1fb8520bdb30d42e30217174c35875d236dad9799245b9aff7f4b5708a6d329a5c49adc8c73063aeec989a27afa44104c0de8986c2147e
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ # Personal test dir
11
+ /t/*
@@ -1,3 +1,6 @@
1
+ ## 0.1.4
2
+ * Add `set_proxy` method to client - [issue#2](https://github.com/yokawasa/azure-log-analytics-data-collector/issues/2)
3
+
1
4
  ## 0.1.2
2
5
  * fixedup bug - [issue #1](https://github.com/yokawasa/azure-log-analytics-data-collector/issues/1)
3
6
 
data/README.md CHANGED
@@ -2,10 +2,96 @@
2
2
  Azure Log Analytics Data Collector API Ruby Client
3
3
 
4
4
  ## Installation
5
- ```
5
+ ```bash
6
6
  gem install azure-loganalytics-datacollector-api
7
7
  ```
8
8
 
9
+ ## Sample code (Ruby Client)
10
+ ### Sample1 - No time_generated_field option
11
+ ```ruby
12
+ require "azure/loganalytics/datacollectorapi/client"
13
+
14
+ customer_id = '<Customer ID aka WorkspaceID String>'
15
+ shared_key = '<The primary or the secondary Connected Sources client authentication key>'
16
+ log_type = "MyCustomLog"
17
+
18
+ posting_records = []
19
+ record1= {
20
+ :string => "MyText1",
21
+ :boolean => true,
22
+ :number => 100
23
+ }
24
+ record2= {
25
+ :string => "MyText2",
26
+ :boolean => false,
27
+ :number => 200
28
+ }
29
+ posting_records.push(record1)
30
+ posting_records.push(record2)
31
+
32
+ client=Azure::Loganalytics::Datacollectorapi::Client::new( customer_id, shared_key)
33
+ res = client.post_data(log_type, posting_records)
34
+ puts res
35
+ puts "res code=#{res.code}"
36
+
37
+ if Azure::Loganalytics::Datacollectorapi::Client.is_success(res)
38
+ puts "operation was succeeded!"
39
+ else
40
+ puts "operation was failured!"
41
+ end
42
+ ```
43
+
44
+ ### Sample2 - With time_generated_field option
45
+ ```ruby
46
+ require "azure/loganalytics/datacollectorapi/client"
47
+
48
+ customer_id = '<Customer ID aka WorkspaceID String>'
49
+ shared_key = '<The primary or the secondary Connected Sources client authentication key>'
50
+ log_type = "MyCustomLog"
51
+
52
+ posting_records = []
53
+ record1= {
54
+ :string => "MyText1",
55
+ :boolean => true,
56
+ :number => 100,
57
+ :timegen => "2017-11-23T11:13:35.576Z" # YYYY-MM-DDThh:mm:ssZ
58
+ }
59
+ record2= {
60
+ :string => "MyText2",
61
+ :boolean => false,
62
+ :number => 200,
63
+ :timegen => "2017-11-23T12:13:35.576Z" # YYYY-MM-DDThh:mm:ssZ
64
+ }
65
+ posting_records.push(record1)
66
+ posting_records.push(record2)
67
+
68
+ time_generated_field = "timegen"
69
+ client=Azure::Loganalytics::Datacollectorapi::Client::new( customer_id, shared_key)
70
+ res = client.post_data(log_type, posting_records, time_generated_field)
71
+ puts res
72
+ puts "res code=#{res.code}"
73
+
74
+ if Azure::Loganalytics::Datacollectorapi::Client.is_success(res)
75
+ puts "operation was succeeded!"
76
+ else
77
+ puts "operation was failured!"
78
+ end
79
+ ```
80
+
81
+ ### Sample3 - use proxy to access the API
82
+ ```ruby
83
+ require "azure/loganalytics/datacollectorapi/client"
84
+
85
+ ...
86
+ client=Azure::Loganalytics::Datacollectorapi::Client::new( customer_id, shared_key)
87
+ # client.set_proxy() # ENV['http_proxy'] is set by default
88
+ client.set_proxy(your_proxy)
89
+ res = client.post_data(log_type, posting_records, time_generated_field)
90
+ puts res
91
+ ...
92
+ ```
93
+
94
+
9
95
  ## Change log
10
96
 
11
97
  * [Changelog](ChangeLog.md)
@@ -41,6 +41,10 @@ module Azure
41
41
  res
42
42
  end
43
43
 
44
+ def set_proxy(proxy='')
45
+ RestClient.proxy = proxy.empty? ? ENV['http_proxy'] : proxy
46
+ end
47
+
44
48
  def self.is_success(res)
45
49
  return (res.code == 200) ? true : false
46
50
  end
@@ -1,7 +1,7 @@
1
1
  module Azure
2
2
  module Loganalytics
3
3
  module Datacollectorapi
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
6
6
  end
7
7
  end
@@ -12,32 +12,18 @@ describe Azure::Loganalytics::Datacollectorapi::Client do
12
12
  it "posting data to datacollector api" do
13
13
  customer_id = '<Customer ID aka WorkspaceID String>'
14
14
  shared_key = '<Primary Key String>'
15
- log_type = "ApacheAccessLog"
15
+ log_type = "MyCustomLog"
16
16
 
17
17
  json_records = []
18
18
  record1= {
19
- :Log_ID => "5cdad72f-c848-4df0-8aaa-ffe033e75d57",
20
- :date => "2016-12-03 09:44:32 JST",
21
- :processing_time => "372",
22
- :remote => "101.202.74.59",
23
- :user => "-",
24
- :method => "GET / HTTP/1.1",
25
- :status => "304",
26
- :size => "-",
27
- :referer => "-",
28
- :agent => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:27.0) Gecko/20100101 Firefox/27.0"
19
+ :string => "MyText1",
20
+ :boolean => true,
21
+ :number => 100
29
22
  }
30
- record2 ={
31
- :Log_ID => "7260iswx-8034-4cc3-uirtx-f068dd4cd659",
32
- :date => "2016-12-03 09:45:14 JST",
33
- :processing_time => "105",
34
- :remote => "201.78.74.59",
35
- :user => "-",
36
- :method => "GET /manager/html HTTP/1.1",
37
- :status =>"200",
38
- :size => "-",
39
- :referer => "-",
40
- :agent => "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"
23
+ record2= {
24
+ :string => "MyText2",
25
+ :boolean => false,
26
+ :number => 200
41
27
  }
42
28
  json_records.push(record1)
43
29
  json_records.push(record2)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azure-loganalytics-datacollector-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichi Kawasaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-29 00:00:00.000000000 Z
11
+ date: 2019-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -108,8 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.6.2
111
+ rubygems_version: 3.0.3
113
112
  signing_key:
114
113
  specification_version: 4
115
114
  summary: Azure Log Analytics Data Collector API Ruby Client