Skip to content

Commit

Permalink
Support for time-generated-field in output configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoichi Kawasaki committed Apr 22, 2017
1 parent fcfcde7 commit e839d81
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.2.0
* Support for time-generated-field in output configuration

## 0.1.1
* Changed required minimum version of azure-loganalytics-datacollector-api to >= 0.1.2
* modified log_type param: removed default val and made it required param
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Once you have the workspace, get Workspace ID and Shared Key (either Primary Key
* **customer\_id (required)** - Your Operations Management Suite workspace ID
* **shared\_key (required)** - The primary or the secondary Connected Sources client authentication key
* **log\_type (required)** - The name of the event type that is being submitted to Log Analytics
* **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
* **add\_time\_field (optional)** - Default:true. This option allows to insert a time field to record
* **time\_field\_name (optional)** - Default:time. This is required only when add_time_field is true
* **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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
0.2.0
4 changes: 3 additions & 1 deletion lib/fluent/plugin/out_azure-loganalytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def initialize
:desc => "The primary or the secondary Connected Sources client authentication key"
config_param :log_type, :string,
:desc => "The name of the event type that is being submitted to Log Analytics"
config_param :time_generated_field, :string, :default => '',
: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)"
config_param :add_time_field, :bool, :default => true,
:desc => "This option allows to insert a time field to record"
config_param :time_field_name, :string, :default => "time",
Expand Down Expand Up @@ -71,7 +73,7 @@ def write(chunk)
records.push(record)
}
begin
res = @client.post_data(@log_type, records)
res = @client.post_data(@log_type, records, @time_generated_field)
if not Azure::Loganalytics::Datacollectorapi::Client.is_success(res)
$log.fatal "DataCollector API request failure: error code: "
+ "#{res.code}, data=>" + records.to_json
Expand Down
7 changes: 5 additions & 2 deletions test/plugin/test_azure_loganalytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def setup
customer_id <Customer ID aka WorkspaceID String>
shared_key <Primary Key String>
log_type ApacheAccessLog
time_generated_field eventtime
add_time_field true
localtime true
add_tag_field true
Expand Down Expand Up @@ -57,7 +58,8 @@ def test_write
:status => "304",
:size => "-",
:referer => "-",
:agent => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:27.0) Gecko/20100101 Firefox/27.0"
:agent => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:27.0) Gecko/20100101 Firefox/27.0",
:eventtime => "2016-12-10T09:44:32Z"
}, time)

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

data = d.run
Expand Down

0 comments on commit e839d81

Please sign in to comment.