Skip to content

Commit e839d81

Browse files
author
Yoichi Kawasaki
committed
Support for time-generated-field in output configuration
1 parent fcfcde7 commit e839d81

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.2.0
2+
* Support for time-generated-field in output configuration
3+
14
## 0.1.1
25
* Changed required minimum version of azure-loganalytics-datacollector-api to >= 0.1.2
36
* modified log_type param: removed default val and made it required param

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Once you have the workspace, get Workspace ID and Shared Key (either Primary Key
3838
* **customer\_id (required)** - Your Operations Management Suite workspace ID
3939
* **shared\_key (required)** - The primary or the secondary Connected Sources client authentication key
4040
* **log\_type (required)** - The name of the event type that is being submitted to Log Analytics
41+
* **time\_generated\_field (optional)** - Default:''(empty string) The name of the time generated field. Be carefule that the value of field should strictly follow the ISO 8601 format (YYYY-MM-DDThh:mm:ssZ). See also [this](https://docs.microsoft.com/en-us/azure/log-analytics/log-analytics-data-collector-api#create-a-request) for more details
4142
* **add\_time\_field (optional)** - Default:true. This option allows to insert a time field to record
4243
* **time\_field\_name (optional)** - Default:time. This is required only when add_time_field is true
4344
* **localtime (optional)** - Default:false. Time record is inserted with UTC (Coordinated Universal Time) by default. This option allows to use local time if you set localtime true. This is valid only when add_time_field is true

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.1
1+
0.2.0

lib/fluent/plugin/out_azure-loganalytics.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def initialize
1717
:desc => "The primary or the secondary Connected Sources client authentication key"
1818
config_param :log_type, :string,
1919
:desc => "The name of the event type that is being submitted to Log Analytics"
20+
config_param :time_generated_field, :string, :default => '',
21+
:desc => "The name of the time generated field. Be carefule that the value of field should strictly follow the ISO 8601 format (YYYY-MM-DDThh:mm:ssZ)"
2022
config_param :add_time_field, :bool, :default => true,
2123
:desc => "This option allows to insert a time field to record"
2224
config_param :time_field_name, :string, :default => "time",
@@ -71,7 +73,7 @@ def write(chunk)
7173
records.push(record)
7274
}
7375
begin
74-
res = @client.post_data(@log_type, records)
76+
res = @client.post_data(@log_type, records, @time_generated_field)
7577
if not Azure::Loganalytics::Datacollectorapi::Client.is_success(res)
7678
$log.fatal "DataCollector API request failure: error code: "
7779
+ "#{res.code}, data=>" + records.to_json

test/plugin/test_azure_loganalytics.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def setup
99
customer_id <Customer ID aka WorkspaceID String>
1010
shared_key <Primary Key String>
1111
log_type ApacheAccessLog
12+
time_generated_field eventtime
1213
add_time_field true
1314
localtime true
1415
add_tag_field true
@@ -57,7 +58,8 @@ def test_write
5758
:status => "304",
5859
:size => "-",
5960
:referer => "-",
60-
:agent => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:27.0) Gecko/20100101 Firefox/27.0"
61+
:agent => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:27.0) Gecko/20100101 Firefox/27.0",
62+
:eventtime => "2016-12-10T09:44:32Z"
6163
}, time)
6264

6365
d.emit(
@@ -71,7 +73,8 @@ def test_write
7173
:status =>"200",
7274
:size => "-",
7375
:referer => "-",
74-
:agent => "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"
76+
:agent => "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0",
77+
:eventtime => "2016-12-10T09:45:14Z"
7578
}, time)
7679

7780
data = d.run

0 commit comments

Comments
 (0)