logstash-output-kusto 2.0.0-java → 2.0.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/logstash/outputs/kusto/ingestor.rb +29 -5
- data/lib/logstash/outputs/kusto.rb +5 -3
- data/lib/logstash-output-kusto_jars.rb +1 -1
- data/spec/outputs/kusto/ingestor_spec.rb +15 -5
- data/vendor/jar-dependencies/org/logstash/outputs/logstash-output-kusto/2.0.1/logstash-output-kusto-2.0.1.jar +0 -0
- data/version +1 -1
- metadata +3 -3
- data/vendor/jar-dependencies/org/logstash/outputs/logstash-output-kusto/2.0.0/logstash-output-kusto-2.0.0.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50f048659e21af84175d7c219ad47e00413f06ca52e6119cd1f03ab6013bd9ac
|
4
|
+
data.tar.gz: e2a60dcd99612c62dc8ee6f0bb053492cf566edcca383d9fc7916707c369450f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92252209eb0b2d5f4ecff0a85a08534092f56017272530fd535c66de777f43888c28b039adf1b6e265b15af01135cd077aaa909f0938df583b1890219dde9ee0
|
7
|
+
data.tar.gz: 17a54f5792a3812eeb582d8fb847cfaa27cc7e97a9369888c3b4e4bd4acaa7c9969d98bd39d77fcb50b7a8745c22d1f87323d75300de51d21571f1e688c5bdb0
|
data/README.md
CHANGED
@@ -53,7 +53,8 @@ More information about configuring Logstash can be found in the [logstash config
|
|
53
53
|
| --- | --- | --- |
|
54
54
|
| **path** | The plugin writes events to temporary files before sending them to ADX. This parameter includes a path where files should be written and a time expression for file rotation to trigger an upload to the ADX service. The example above shows how to rotate the files every minute and check the Logstash docs for more information on time expressions. | Required
|
55
55
|
| **ingest_url** | The Kusto endpoint for ingestion-related communication. See it on the Azure Portal.| Required|
|
56
|
-
| **app_id, app_key, app_tenant**| Credentials required to connect to the ADX service. Be sure to use an application with 'ingest' privileges. |
|
56
|
+
| **app_id, app_key, app_tenant**| Credentials required to connect to the ADX service. Be sure to use an application with 'ingest' privileges. | Optional|
|
57
|
+
| **managed_identity**| Managed Identity to authenticate. For user-based managed ID, use the Client ID GUID. For system-based, use the value `system`. The ID needs to have 'ingest' privileges on the cluster. | Optional|
|
57
58
|
| **database**| Database name to place events | Required |
|
58
59
|
| **table** | Target table name to place events | Required
|
59
60
|
| **json_mapping** | Maps each attribute from incoming event JSON strings to the appropriate column in the table. Note that this must be in JSON format, as this is the interface between Logstash and Kusto | Required |
|
@@ -20,15 +20,34 @@ class LogStash::Outputs::Kusto < LogStash::Outputs::Base
|
|
20
20
|
LOW_QUEUE_LENGTH = 3
|
21
21
|
FIELD_REF = /%\{[^}]+\}/
|
22
22
|
|
23
|
-
def initialize(ingest_url, app_id, app_key, app_tenant, database, table, json_mapping, delete_local, proxy_host , proxy_port , proxy_protocol,logger, threadpool = DEFAULT_THREADPOOL)
|
23
|
+
def initialize(ingest_url, app_id, app_key, app_tenant, managed_identity_id, database, table, json_mapping, delete_local, proxy_host , proxy_port , proxy_protocol,logger, threadpool = DEFAULT_THREADPOOL)
|
24
24
|
@workers_pool = threadpool
|
25
25
|
@logger = logger
|
26
|
-
validate_config(database, table, json_mapping,proxy_protocol)
|
26
|
+
validate_config(database, table, json_mapping,proxy_protocol,app_id, app_key, managed_identity_id)
|
27
27
|
@logger.info('Preparing Kusto resources.')
|
28
28
|
|
29
29
|
kusto_java = Java::com.microsoft.azure.kusto
|
30
30
|
apache_http = Java::org.apache.http
|
31
|
-
kusto_connection_string = kusto_java.data.auth.ConnectionStringBuilder.createWithAadApplicationCredentials(ingest_url, app_id, app_key.value, app_tenant)
|
31
|
+
# kusto_connection_string = kusto_java.data.auth.ConnectionStringBuilder.createWithAadApplicationCredentials(ingest_url, app_id, app_key.value, app_tenant)
|
32
|
+
# If there is managed identity, use it. This means the AppId and AppKey are empty/nil
|
33
|
+
is_managed_identity = (app_id.nil? && app_key.empty?)
|
34
|
+
# If it is system managed identity, propagate the system identity
|
35
|
+
is_system_assigned_managed_identity = is_managed_identity && 0 == "system".casecmp(managed_identity_id)
|
36
|
+
# Is it direct connection
|
37
|
+
is_direct_conn = (proxy_host.nil? || proxy_host.empty?)
|
38
|
+
# Create a connection string
|
39
|
+
kusto_connection_string = if is_managed_identity
|
40
|
+
if is_system_assigned_managed_identity
|
41
|
+
@logger.info('Using system managed identity.')
|
42
|
+
kusto_java.data.auth.ConnectionStringBuilder.createWithAadManagedIdentity(ingest_url)
|
43
|
+
else
|
44
|
+
@logger.info('Using user managed identity.')
|
45
|
+
kusto_java.data.auth.ConnectionStringBuilder.createWithAadManagedIdentity(ingest_url, managed_identity_id)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
kusto_java.data.auth.ConnectionStringBuilder.createWithAadApplicationCredentials(ingest_url, app_id, app_key.value, app_tenant)
|
49
|
+
end
|
50
|
+
|
32
51
|
#
|
33
52
|
@logger.debug(Gem.loaded_specs.to_s)
|
34
53
|
# Unfortunately there's no way to avoid using the gem/plugin name directly...
|
@@ -41,7 +60,7 @@ class LogStash::Outputs::Kusto < LogStash::Outputs::Base
|
|
41
60
|
kusto_connection_string.setConnectorDetails("Logstash",version_for_tracing.to_s,"","",false,"", tuple_utils.Pair.emptyArray());
|
42
61
|
|
43
62
|
@kusto_client = begin
|
44
|
-
if
|
63
|
+
if is_direct_conn
|
45
64
|
kusto_java.ingest.IngestClientFactory.createClient(kusto_connection_string)
|
46
65
|
else
|
47
66
|
kusto_http_client_properties = kusto_java.data.HttpClientProperties.builder().proxy(apache_http.HttpHost.new(proxy_host,proxy_port,proxy_protocol)).build()
|
@@ -57,7 +76,12 @@ class LogStash::Outputs::Kusto < LogStash::Outputs::Base
|
|
57
76
|
@logger.debug('Kusto resources are ready.')
|
58
77
|
end
|
59
78
|
|
60
|
-
def validate_config(database, table, json_mapping,proxy_protocol)
|
79
|
+
def validate_config(database, table, json_mapping, proxy_protocol, app_id, app_key, managed_identity_id)
|
80
|
+
# Add an additional validation and fail this upfront
|
81
|
+
if app_id.nil? && app_key.empty? && managed_identity_id.empty?
|
82
|
+
@logger.error('managed_identity_id is not provided and app_id/app_key is empty.')
|
83
|
+
raise LogStash::ConfigurationError.new('managed_identity_id is not provided and app_id/app_key is empty.')
|
84
|
+
end
|
61
85
|
if database =~ FIELD_REF
|
62
86
|
@logger.error('database config value should not be dynamic.', database)
|
63
87
|
raise LogStash::ConfigurationError.new('database config value should not be dynamic.')
|
@@ -73,11 +73,13 @@ class LogStash::Outputs::Kusto < LogStash::Outputs::Base
|
|
73
73
|
|
74
74
|
# The following are the credentails used to connect to the Kusto service
|
75
75
|
# application id
|
76
|
-
config :app_id, validate: :string, required:
|
76
|
+
config :app_id, validate: :string, required: false
|
77
77
|
# application key (secret)
|
78
|
-
config :app_key, validate: :password, required:
|
78
|
+
config :app_key, validate: :password, required: false
|
79
79
|
# aad tenant id
|
80
80
|
config :app_tenant, validate: :string, default: nil
|
81
|
+
# managed identity id
|
82
|
+
config :managed_identity, validate: :string, default: nil
|
81
83
|
|
82
84
|
# The following are the data settings that impact where events are written to
|
83
85
|
# Database name
|
@@ -150,7 +152,7 @@ class LogStash::Outputs::Kusto < LogStash::Outputs::Base
|
|
150
152
|
max_queue: upload_queue_size,
|
151
153
|
fallback_policy: :caller_runs)
|
152
154
|
|
153
|
-
@ingestor = Ingestor.new(ingest_url, app_id, app_key, app_tenant, database, table, final_mapping, delete_temp_files, proxy_host, proxy_port,proxy_protocol, @logger, executor)
|
155
|
+
@ingestor = Ingestor.new(ingest_url, app_id, app_key, app_tenant, managed_identity, database, table, final_mapping, delete_temp_files, proxy_host, proxy_port,proxy_protocol, @logger, executor)
|
154
156
|
|
155
157
|
# send existing files
|
156
158
|
recover_past_files if recovery
|
@@ -70,4 +70,4 @@ require_jar('org.ow2.asm', 'asm', '9.3')
|
|
70
70
|
require_jar('org.reactivestreams', 'reactive-streams', '1.0.4')
|
71
71
|
require_jar('org.slf4j', 'slf4j-api', '1.8.0-beta4')
|
72
72
|
require_jar('org.slf4j', 'slf4j-simple', '1.8.0-beta4')
|
73
|
-
require_jar('org.logstash.outputs', 'logstash-output-kusto', '2.0.
|
73
|
+
require_jar('org.logstash.outputs', 'logstash-output-kusto', '2.0.1')
|
@@ -9,6 +9,7 @@ describe LogStash::Outputs::Kusto::Ingestor do
|
|
9
9
|
let(:app_id) { "myid" }
|
10
10
|
let(:app_key) { LogStash::Util::Password.new("mykey") }
|
11
11
|
let(:app_tenant) { "mytenant" }
|
12
|
+
let(:managed_identity) { "managed_identity" }
|
12
13
|
let(:database) { "mydatabase" }
|
13
14
|
let(:table) { "mytable" }
|
14
15
|
let(:proxy_host) { "localhost" }
|
@@ -24,7 +25,7 @@ describe LogStash::Outputs::Kusto::Ingestor do
|
|
24
25
|
# note that this will cause an internal error since connection is being tried.
|
25
26
|
# however we still want to test that all the java stuff is working as expected
|
26
27
|
expect {
|
27
|
-
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, database, table, json_mapping, delete_local, proxy_host, proxy_port,proxy_protocol, logger)
|
28
|
+
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, managed_identity, database, table, json_mapping, delete_local, proxy_host, proxy_port,proxy_protocol, logger)
|
28
29
|
ingestor.stop
|
29
30
|
}.not_to raise_error
|
30
31
|
end
|
@@ -35,7 +36,7 @@ describe LogStash::Outputs::Kusto::Ingestor do
|
|
35
36
|
dynamic_name_array.each do |test_database|
|
36
37
|
it "with database: #{test_database}" do
|
37
38
|
expect {
|
38
|
-
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, test_database, table, json_mapping, delete_local, proxy_host, proxy_port,proxy_protocol,logger)
|
39
|
+
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, managed_identity, test_database, table, json_mapping, delete_local, proxy_host, proxy_port,proxy_protocol,logger)
|
39
40
|
ingestor.stop
|
40
41
|
}.to raise_error(LogStash::ConfigurationError)
|
41
42
|
end
|
@@ -46,7 +47,7 @@ describe LogStash::Outputs::Kusto::Ingestor do
|
|
46
47
|
dynamic_name_array.each do |test_table|
|
47
48
|
it "with database: #{test_table}" do
|
48
49
|
expect {
|
49
|
-
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, database, test_table, json_mapping, delete_local, proxy_host, proxy_port,proxy_protocol,logger)
|
50
|
+
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, managed_identity,database, test_table, json_mapping, delete_local, proxy_host, proxy_port,proxy_protocol,logger)
|
50
51
|
ingestor.stop
|
51
52
|
}.to raise_error(LogStash::ConfigurationError)
|
52
53
|
end
|
@@ -57,7 +58,7 @@ describe LogStash::Outputs::Kusto::Ingestor do
|
|
57
58
|
dynamic_name_array.each do |json_mapping|
|
58
59
|
it "with database: #{json_mapping}" do
|
59
60
|
expect {
|
60
|
-
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, database, table, json_mapping, delete_local, proxy_host, proxy_port,proxy_protocol,logger)
|
61
|
+
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, managed_identity,database, table, json_mapping, delete_local, proxy_host, proxy_port,proxy_protocol,logger)
|
61
62
|
ingestor.stop
|
62
63
|
}.to raise_error(LogStash::ConfigurationError)
|
63
64
|
end
|
@@ -67,7 +68,16 @@ describe LogStash::Outputs::Kusto::Ingestor do
|
|
67
68
|
context 'proxy protocol has to be http or https' do
|
68
69
|
it "with proxy protocol: socks" do
|
69
70
|
expect {
|
70
|
-
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, database, table, json_mapping, delete_local, proxy_host, proxy_port,'socks',logger)
|
71
|
+
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, managed_identity,database, table, json_mapping, delete_local, proxy_host, proxy_port,'socks',logger)
|
72
|
+
ingestor.stop
|
73
|
+
}.to raise_error(LogStash::ConfigurationError)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'one of appid or managedid has to be provided' do
|
78
|
+
it "with empty managed identity and appid" do
|
79
|
+
expect {
|
80
|
+
ingestor = described_class.new(ingest_url, "", app_key, app_tenant, "",database, table, json_mapping, delete_local, proxy_host, proxy_port,'socks',logger)
|
71
81
|
ingestor.stop
|
72
82
|
}.to raise_error(LogStash::ConfigurationError)
|
73
83
|
end
|
Binary file
|
data/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-kusto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Tamir Kamara
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,7 +229,7 @@ files:
|
|
229
229
|
- vendor/jar-dependencies/org/apache/httpcomponents/httpcore/4.4.16/httpcore-4.4.16.jar
|
230
230
|
- vendor/jar-dependencies/org/codehaus/woodstox/stax2-api/4.2.1/stax2-api-4.2.1.jar
|
231
231
|
- vendor/jar-dependencies/org/jetbrains/annotations/22.0.0/annotations-22.0.0.jar
|
232
|
-
- vendor/jar-dependencies/org/logstash/outputs/logstash-output-kusto/2.0.
|
232
|
+
- vendor/jar-dependencies/org/logstash/outputs/logstash-output-kusto/2.0.1/logstash-output-kusto-2.0.1.jar
|
233
233
|
- vendor/jar-dependencies/org/ow2/asm/asm/9.3/asm-9.3.jar
|
234
234
|
- vendor/jar-dependencies/org/reactivestreams/reactive-streams/1.0.4/reactive-streams-1.0.4.jar
|
235
235
|
- vendor/jar-dependencies/org/slf4j/slf4j-api/1.8.0-beta4/slf4j-api-1.8.0-beta4.jar
|