logstash-output-kusto 1.0.6-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/CHANGELOG.md +42 -37
- data/CONTRIBUTORS +10 -10
- data/Gemfile +11 -22
- data/LICENSE +201 -201
- data/README.md +103 -94
- data/SECURITY.md +41 -41
- data/lib/logstash/outputs/kusto/ingestor.rb +166 -138
- data/lib/logstash/outputs/kusto/interval.rb +81 -81
- data/lib/logstash/outputs/kusto.rb +424 -422
- data/lib/logstash-output-kusto_jars.rb +72 -149
- data/logstash-output-kusto.gemspec +35 -36
- data/spec/outputs/kusto/ingestor_spec.rb +131 -121
- data/spec/outputs/kusto_spec.rb +56 -56
- data/spec/spec_helpers.rb +21 -21
- data/vendor/jar-dependencies/com/azure/azure-core/1.41.0/azure-core-1.41.0.jar +0 -0
- data/vendor/jar-dependencies/com/azure/azure-core-http-netty/1.13.5/azure-core-http-netty-1.13.5.jar +0 -0
- data/vendor/jar-dependencies/com/azure/azure-data-tables/12.3.13/azure-data-tables-12.3.13.jar +0 -0
- data/vendor/jar-dependencies/com/azure/azure-identity/1.9.2/azure-identity-1.9.2.jar +0 -0
- data/vendor/jar-dependencies/com/azure/azure-json/1.0.1/azure-json-1.0.1.jar +0 -0
- data/vendor/jar-dependencies/com/azure/azure-storage-blob/12.23.0/azure-storage-blob-12.23.0.jar +0 -0
- data/vendor/jar-dependencies/com/azure/azure-storage-common/12.22.0/azure-storage-common-12.22.0.jar +0 -0
- data/vendor/jar-dependencies/com/azure/azure-storage-internal-avro/12.8.0/azure-storage-internal-avro-12.8.0.jar +0 -0
- data/vendor/jar-dependencies/com/azure/azure-storage-queue/12.18.0/azure-storage-queue-12.18.0.jar +0 -0
- data/{lib/com/fasterxml/jackson/core/jackson-annotations/2.12.5/jackson-annotations-2.12.5.jar → vendor/jar-dependencies/com/fasterxml/jackson/core/jackson-annotations/2.14.2/jackson-annotations-2.14.2.jar} +0 -0
- data/vendor/jar-dependencies/com/fasterxml/jackson/core/jackson-core/2.14.2/jackson-core-2.14.2.jar +0 -0
- data/{lib/com/fasterxml/jackson/core/jackson-databind/2.13.0/jackson-databind-2.13.0.jar → vendor/jar-dependencies/com/fasterxml/jackson/core/jackson-databind/2.14.2/jackson-databind-2.14.2.jar} +0 -0
- data/vendor/jar-dependencies/com/fasterxml/jackson/dataformat/jackson-dataformat-xml/2.14.2/jackson-dataformat-xml-2.14.2.jar +0 -0
- data/vendor/jar-dependencies/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.14.2/jackson-datatype-jsr310-2.14.2.jar +0 -0
- data/{lib/com/fasterxml/woodstox/woodstox-core/6.2.4/woodstox-core-6.2.4.jar → vendor/jar-dependencies/com/fasterxml/woodstox/woodstox-core/6.5.0/woodstox-core-6.5.0.jar} +0 -0
- data/vendor/jar-dependencies/com/microsoft/azure/kusto/kusto-data/5.0.2/kusto-data-5.0.2.jar +0 -0
- data/vendor/jar-dependencies/com/microsoft/azure/kusto/kusto-ingest/5.0.2/kusto-ingest-5.0.2.jar +0 -0
- data/vendor/jar-dependencies/com/microsoft/azure/msal4j/1.13.8/msal4j-1.13.8.jar +0 -0
- data/{lib/com/microsoft/azure/msal4j-persistence-extension/1.1.0/msal4j-persistence-extension-1.1.0.jar → vendor/jar-dependencies/com/microsoft/azure/msal4j-persistence-extension/1.2.0/msal4j-persistence-extension-1.2.0.jar} +0 -0
- data/vendor/jar-dependencies/com/nimbusds/content-type/2.2/content-type-2.2.jar +0 -0
- data/vendor/jar-dependencies/com/nimbusds/lang-tag/1.7/lang-tag-1.7.jar +0 -0
- data/vendor/jar-dependencies/com/nimbusds/nimbus-jose-jwt/9.30.2/nimbus-jose-jwt-9.30.2.jar +0 -0
- data/vendor/jar-dependencies/com/nimbusds/oauth2-oidc-sdk/10.7.1/oauth2-oidc-sdk-10.7.1.jar +0 -0
- data/vendor/jar-dependencies/commons-codec/commons-codec/1.13/commons-codec-1.13.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-buffer/4.1.94.Final/netty-buffer-4.1.94.Final.jar +0 -0
- data/{lib/io/netty/netty-codec/4.1.68.Final/netty-codec-4.1.68.Final.jar → vendor/jar-dependencies/io/netty/netty-codec/4.1.94.Final/netty-codec-4.1.94.Final.jar} +0 -0
- data/{lib/io/netty/netty-codec-dns/4.1.68.Final/netty-codec-dns-4.1.68.Final.jar → vendor/jar-dependencies/io/netty/netty-codec-dns/4.1.94.Final/netty-codec-dns-4.1.94.Final.jar} +0 -0
- data/{lib/io/netty/netty-codec-http/4.1.68.Final/netty-codec-http-4.1.68.Final.jar → vendor/jar-dependencies/io/netty/netty-codec-http/4.1.94.Final/netty-codec-http-4.1.94.Final.jar} +0 -0
- data/{lib/io/netty/netty-codec-http2/4.1.68.Final/netty-codec-http2-4.1.68.Final.jar → vendor/jar-dependencies/io/netty/netty-codec-http2/4.1.94.Final/netty-codec-http2-4.1.94.Final.jar} +0 -0
- data/vendor/jar-dependencies/io/netty/netty-codec-socks/4.1.94.Final/netty-codec-socks-4.1.94.Final.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-common/4.1.94.Final/netty-common-4.1.94.Final.jar +0 -0
- data/{lib/io/netty/netty-handler/4.1.68.Final/netty-handler-4.1.68.Final.jar → vendor/jar-dependencies/io/netty/netty-handler/4.1.94.Final/netty-handler-4.1.94.Final.jar} +0 -0
- data/{lib/io/netty/netty-handler-proxy/4.1.68.Final/netty-handler-proxy-4.1.68.Final.jar → vendor/jar-dependencies/io/netty/netty-handler-proxy/4.1.94.Final/netty-handler-proxy-4.1.94.Final.jar} +0 -0
- data/{lib/io/netty/netty-resolver/4.1.68.Final/netty-resolver-4.1.68.Final.jar → vendor/jar-dependencies/io/netty/netty-resolver/4.1.94.Final/netty-resolver-4.1.94.Final.jar} +0 -0
- data/vendor/jar-dependencies/io/netty/netty-resolver-dns/4.1.94.Final/netty-resolver-dns-4.1.94.Final.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-resolver-dns-classes-macos/4.1.94.Final/netty-resolver-dns-classes-macos-4.1.94.Final.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-resolver-dns-native-macos/4.1.94.Final/netty-resolver-dns-native-macos-4.1.94.Final.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-tcnative-boringssl-static/2.0.61.Final/netty-tcnative-boringssl-static-2.0.61.Final.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-tcnative-classes/2.0.61.Final/netty-tcnative-classes-2.0.61.Final.jar +0 -0
- data/{lib/io/netty/netty-transport/4.1.68.Final/netty-transport-4.1.68.Final.jar → vendor/jar-dependencies/io/netty/netty-transport/4.1.94.Final/netty-transport-4.1.94.Final.jar} +0 -0
- data/vendor/jar-dependencies/io/netty/netty-transport-classes-epoll/4.1.94.Final/netty-transport-classes-epoll-4.1.94.Final.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-transport-classes-kqueue/4.1.94.Final/netty-transport-classes-kqueue-4.1.94.Final.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-transport-native-epoll/4.1.94.Final/netty-transport-native-epoll-4.1.94.Final.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-transport-native-kqueue/4.1.94.Final/netty-transport-native-kqueue-4.1.94.Final.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-transport-native-unix-common/4.1.94.Final/netty-transport-native-unix-common-4.1.94.Final.jar +0 -0
- data/vendor/jar-dependencies/io/projectreactor/netty/reactor-netty-core/1.0.33/reactor-netty-core-1.0.33.jar +0 -0
- data/vendor/jar-dependencies/io/projectreactor/netty/reactor-netty-http/1.0.33/reactor-netty-http-1.0.33.jar +0 -0
- data/{lib/io/projectreactor/reactor-core/3.4.10/reactor-core-3.4.10.jar → vendor/jar-dependencies/io/projectreactor/reactor-core/3.4.32/reactor-core-3.4.32.jar} +0 -0
- data/vendor/jar-dependencies/net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar +0 -0
- data/vendor/jar-dependencies/net/java/dev/jna/jna-platform/5.13.0/jna-platform-5.13.0.jar +0 -0
- data/{lib/net/minidev/accessors-smart/2.4.7/accessors-smart-2.4.7.jar → vendor/jar-dependencies/net/minidev/accessors-smart/2.4.9/accessors-smart-2.4.9.jar} +0 -0
- data/{lib/net/minidev/json-smart/2.4.7/json-smart-2.4.7.jar → vendor/jar-dependencies/net/minidev/json-smart/2.4.10/json-smart-2.4.10.jar} +0 -0
- data/vendor/jar-dependencies/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar +0 -0
- data/vendor/jar-dependencies/org/apache/httpcomponents/httpclient/4.5.14/httpclient-4.5.14.jar +0 -0
- data/vendor/jar-dependencies/org/apache/httpcomponents/httpcore/4.4.16/httpcore-4.4.16.jar +0 -0
- data/vendor/jar-dependencies/org/logstash/outputs/logstash-output-kusto/2.0.1/logstash-output-kusto-2.0.1.jar +0 -0
- data/vendor/jar-dependencies/org/ow2/asm/asm/9.3/asm-9.3.jar +0 -0
- data/vendor/jar-dependencies/org/reactivestreams/reactive-streams/1.0.4/reactive-streams-1.0.4.jar +0 -0
- data/version +1 -0
- metadata +111 -113
- data/lib/com/azure/azure-core/1.21.0/azure-core-1.21.0.jar +0 -0
- data/lib/com/azure/azure-core-http-netty/1.11.1/azure-core-http-netty-1.11.1.jar +0 -0
- data/lib/com/azure/azure-identity/1.3.7/azure-identity-1.3.7.jar +0 -0
- data/lib/com/fasterxml/jackson/core/jackson-annotations/2.13.0/jackson-annotations-2.13.0.jar +0 -0
- data/lib/com/fasterxml/jackson/core/jackson-core/2.12.5/jackson-core-2.12.5.jar +0 -0
- data/lib/com/fasterxml/jackson/core/jackson-core/2.13.0/jackson-core-2.13.0.jar +0 -0
- data/lib/com/fasterxml/jackson/core/jackson-databind/2.12.5/jackson-databind-2.12.5.jar +0 -0
- data/lib/com/fasterxml/jackson/dataformat/jackson-dataformat-xml/2.12.5/jackson-dataformat-xml-2.12.5.jar +0 -0
- data/lib/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.12.5/jackson-datatype-jsr310-2.12.5.jar +0 -0
- data/lib/com/fasterxml/jackson/module/jackson-module-jaxb-annotations/2.12.5/jackson-module-jaxb-annotations-2.12.5.jar +0 -0
- data/lib/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar +0 -0
- data/lib/com/google/errorprone/error_prone_annotations/2.1.3/error_prone_annotations-2.1.3.jar +0 -0
- data/lib/com/google/guava/guava/24.1.1-jre/guava-24.1.1-jre.jar +0 -0
- data/lib/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar +0 -0
- data/lib/com/microsoft/azure/azure-keyvault-core/1.2.4/azure-keyvault-core-1.2.4.jar +0 -0
- data/lib/com/microsoft/azure/azure-storage/8.6.6/azure-storage-8.6.6.jar +0 -0
- data/lib/com/microsoft/azure/kusto/kusto-data/3.1.1/kusto-data-3.1.1.jar +0 -0
- data/lib/com/microsoft/azure/kusto/kusto-data/3.1.3/kusto-data-3.1.3.jar +0 -0
- data/lib/com/microsoft/azure/kusto/kusto-data/3.2.1/kusto-data-3.2.1.jar +0 -0
- data/lib/com/microsoft/azure/kusto/kusto-ingest/3.1.1/kusto-ingest-3.1.1.jar +0 -0
- data/lib/com/microsoft/azure/kusto/kusto-ingest/3.1.3/kusto-ingest-3.1.3.jar +0 -0
- data/lib/com/microsoft/azure/kusto/kusto-ingest/3.2.1/kusto-ingest-3.2.1.jar +0 -0
- data/lib/com/microsoft/azure/msal4j/1.11.0/msal4j-1.11.0.jar +0 -0
- data/lib/com/nimbusds/content-type/2.1/content-type-2.1.jar +0 -0
- data/lib/com/nimbusds/lang-tag/1.5/lang-tag-1.5.jar +0 -0
- data/lib/com/nimbusds/nimbus-jose-jwt/9.9.3/nimbus-jose-jwt-9.9.3.jar +0 -0
- data/lib/com/nimbusds/oauth2-oidc-sdk/9.7/oauth2-oidc-sdk-9.7.jar +0 -0
- data/lib/commons-codec/commons-codec/1.11/commons-codec-1.11.jar +0 -0
- data/lib/io/netty/netty-buffer/4.1.68.Final/netty-buffer-4.1.68.Final.jar +0 -0
- data/lib/io/netty/netty-codec-socks/4.1.68.Final/netty-codec-socks-4.1.68.Final.jar +0 -0
- data/lib/io/netty/netty-common/4.1.68.Final/netty-common-4.1.68.Final.jar +0 -0
- data/lib/io/netty/netty-resolver-dns/4.1.68.Final/netty-resolver-dns-4.1.68.Final.jar +0 -0
- data/lib/io/netty/netty-resolver-dns-native-macos/4.1.68.Final/netty-resolver-dns-native-macos-4.1.68.Final-osx-x86_64.jar +0 -0
- data/lib/io/netty/netty-tcnative-boringssl-static/2.0.43.Final/netty-tcnative-boringssl-static-2.0.43.Final.jar +0 -0
- data/lib/io/netty/netty-transport-native-epoll/4.1.68.Final/netty-transport-native-epoll-4.1.68.Final-linux-x86_64.jar +0 -0
- data/lib/io/netty/netty-transport-native-kqueue/4.1.68.Final/netty-transport-native-kqueue-4.1.68.Final-osx-x86_64.jar +0 -0
- data/lib/io/netty/netty-transport-native-unix-common/4.1.68.Final/netty-transport-native-unix-common-4.1.68.Final.jar +0 -0
- data/lib/io/projectreactor/netty/reactor-netty-core/1.0.11/reactor-netty-core-1.0.11.jar +0 -0
- data/lib/io/projectreactor/netty/reactor-netty-http/1.0.11/reactor-netty-http-1.0.11.jar +0 -0
- data/lib/jakarta/activation/jakarta.activation-api/1.2.1/jakarta.activation-api-1.2.1.jar +0 -0
- data/lib/jakarta/xml/bind/jakarta.xml.bind-api/2.3.2/jakarta.xml.bind-api-2.3.2.jar +0 -0
- data/lib/net/java/dev/jna/jna/5.5.0/jna-5.5.0.jar +0 -0
- data/lib/net/java/dev/jna/jna-platform/5.6.0/jna-platform-5.6.0.jar +0 -0
- data/lib/org/apache/commons/commons-lang3/3.11/commons-lang3-3.11.jar +0 -0
- data/lib/org/apache/commons/commons-text/1.9/commons-text-1.9.jar +0 -0
- data/lib/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar +0 -0
- data/lib/org/apache/httpcomponents/httpcore/4.4.15/httpcore-4.4.15.jar +0 -0
- data/lib/org/checkerframework/checker-compat-qual/2.0.0/checker-compat-qual-2.0.0.jar +0 -0
- data/lib/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar +0 -0
- data/lib/org/json/json/20201115/json-20201115.jar +0 -0
- data/lib/org/ow2/asm/asm/9.1/asm-9.1.jar +0 -0
- data/lib/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/com/github/stephenc/jcip/jcip-annotations/1.0-1/jcip-annotations-1.0-1.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/com/univocity/univocity-parsers/2.9.1/univocity-parsers-2.9.1.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/commons-logging/commons-logging/1.2/commons-logging-1.2.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/io/github/resilience4j/resilience4j-core/1.7.1/resilience4j-core-1.7.1.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/io/github/resilience4j/resilience4j-retry/1.7.1/resilience4j-retry-1.7.1.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/io/vavr/vavr/0.10.2/vavr-0.10.2.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/io/vavr/vavr-match/0.10.2/vavr-match-0.10.2.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/org/apache/commons/commons-text/1.10.0/commons-text-1.10.0.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/org/codehaus/woodstox/stax2-api/4.2.1/stax2-api-4.2.1.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/org/jetbrains/annotations/22.0.0/annotations-22.0.0.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/org/slf4j/slf4j-api/1.8.0-beta4/slf4j-api-1.8.0-beta4.jar +0 -0
- /data/{lib → vendor/jar-dependencies}/org/slf4j/slf4j-simple/1.8.0-beta4/slf4j-simple-1.8.0-beta4.jar +0 -0
data/README.md
CHANGED
@@ -1,94 +1,103 @@
|
|
1
|
-
# Logstash Output Plugin for Azure Data Explorer (Kusto)
|
2
|
-
|
3
|
-
![build](https://github.com/Azure/logstash-output-kusto/workflows/build/badge.svg)
|
4
|
-
![build](https://github.com/Azure/logstash-output-kusto/workflows/build/badge.svg?branch=master)
|
5
|
-
[![Gem](https://img.shields.io/gem/v/logstash-output-kusto.svg)](https://rubygems.org/gems/logstash-output-kusto)
|
6
|
-
[![Gem](https://img.shields.io/gem/dt/logstash-output-kusto.svg)](https://rubygems.org/gems/logstash-output-kusto)
|
7
|
-
|
8
|
-
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
9
|
-
|
10
|
-
It is fully free and open source. The license is Apache 2.0.
|
11
|
-
|
12
|
-
This Azure Data Explorer (ADX) Logstash plugin enables you to process events from Logstash into an **Azure Data Explorer** database for later analysis.
|
13
|
-
|
14
|
-
## Requirements
|
15
|
-
|
16
|
-
- Logstash version 6+. [Installation instructions](https://www.elastic.co/guide/en/logstash/current/installing-logstash.html)
|
17
|
-
- Azure Data Explorer cluster with a database. Read [Create a cluster and database](https://docs.microsoft.com/en-us/azure/data-explorer/create-cluster-database-portal) for more information.
|
18
|
-
- AAD Application credentials with permission to ingest data into Azure Data Explorer. Read [Creating an AAD Application](https://docs.microsoft.com/en-us/azure/kusto/management/access-control/how-to-provision-aad-app) for more information.
|
19
|
-
|
20
|
-
## Installation
|
21
|
-
|
22
|
-
To make the Azure Data Explorer plugin available in your Logstash environment, run the following command:
|
23
|
-
```sh
|
24
|
-
bin/logstash-plugin install logstash-output-kusto
|
25
|
-
```
|
26
|
-
|
27
|
-
## Configuration
|
28
|
-
|
29
|
-
Perform configuration before sending events from Logstash to Azure Data Explorer. The following example shows the minimum you need to provide. It should be enough for most use-cases:
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
output {
|
33
|
-
kusto {
|
34
|
-
path => "/tmp/kusto/%{+YYYY-MM-dd-HH-mm}.txt"
|
35
|
-
ingest_url => "https://ingest-<cluster-name>.kusto.windows.net/"
|
36
|
-
app_id => "<application id>"
|
37
|
-
app_key => "<application key/secret>"
|
38
|
-
app_tenant => "<tenant id>"
|
39
|
-
database => "<database name>"
|
40
|
-
table => "<target table>"
|
41
|
-
json_mapping => "<mapping name>"
|
42
|
-
proxy_host => "<proxy host>"
|
43
|
-
proxy_port => <proxy port>
|
44
|
-
proxy_protocol => <"http"|"https">
|
45
|
-
}
|
46
|
-
}
|
47
|
-
```
|
48
|
-
More information about configuring Logstash can be found in the [logstash configuration guide](https://www.elastic.co/guide/en/logstash/current/configuration.html)
|
49
|
-
|
50
|
-
### Available Configuration Keys
|
51
|
-
|
52
|
-
| Parameter Name | Description | Notes |
|
53
|
-
| --- | --- | --- |
|
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
|
-
| **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. |
|
57
|
-
| **
|
58
|
-
| **
|
59
|
-
| **
|
60
|
-
| **
|
61
|
-
| **
|
62
|
-
| **
|
63
|
-
| **
|
64
|
-
| **
|
65
|
-
| **
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
1
|
+
# Logstash Output Plugin for Azure Data Explorer (Kusto)
|
2
|
+
|
3
|
+
![build](https://github.com/Azure/logstash-output-kusto/workflows/build/badge.svg)
|
4
|
+
![build](https://github.com/Azure/logstash-output-kusto/workflows/build/badge.svg?branch=master)
|
5
|
+
[![Gem](https://img.shields.io/gem/v/logstash-output-kusto.svg)](https://rubygems.org/gems/logstash-output-kusto)
|
6
|
+
[![Gem](https://img.shields.io/gem/dt/logstash-output-kusto.svg)](https://rubygems.org/gems/logstash-output-kusto)
|
7
|
+
|
8
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
9
|
+
|
10
|
+
It is fully free and open source. The license is Apache 2.0.
|
11
|
+
|
12
|
+
This Azure Data Explorer (ADX) Logstash plugin enables you to process events from Logstash into an **Azure Data Explorer** database for later analysis.
|
13
|
+
|
14
|
+
## Requirements
|
15
|
+
|
16
|
+
- Logstash version 6+. [Installation instructions](https://www.elastic.co/guide/en/logstash/current/installing-logstash.html)
|
17
|
+
- Azure Data Explorer cluster with a database. Read [Create a cluster and database](https://docs.microsoft.com/en-us/azure/data-explorer/create-cluster-database-portal) for more information.
|
18
|
+
- AAD Application credentials with permission to ingest data into Azure Data Explorer. Read [Creating an AAD Application](https://docs.microsoft.com/en-us/azure/kusto/management/access-control/how-to-provision-aad-app) for more information.
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
To make the Azure Data Explorer plugin available in your Logstash environment, run the following command:
|
23
|
+
```sh
|
24
|
+
bin/logstash-plugin install logstash-output-kusto
|
25
|
+
```
|
26
|
+
|
27
|
+
## Configuration
|
28
|
+
|
29
|
+
Perform configuration before sending events from Logstash to Azure Data Explorer. The following example shows the minimum you need to provide. It should be enough for most use-cases:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
output {
|
33
|
+
kusto {
|
34
|
+
path => "/tmp/kusto/%{+YYYY-MM-dd-HH-mm}.txt"
|
35
|
+
ingest_url => "https://ingest-<cluster-name>.kusto.windows.net/"
|
36
|
+
app_id => "<application id>"
|
37
|
+
app_key => "<application key/secret>"
|
38
|
+
app_tenant => "<tenant id>"
|
39
|
+
database => "<database name>"
|
40
|
+
table => "<target table>"
|
41
|
+
json_mapping => "<mapping name>"
|
42
|
+
proxy_host => "<proxy host>"
|
43
|
+
proxy_port => <proxy port>
|
44
|
+
proxy_protocol => <"http"|"https">
|
45
|
+
}
|
46
|
+
}
|
47
|
+
```
|
48
|
+
More information about configuring Logstash can be found in the [logstash configuration guide](https://www.elastic.co/guide/en/logstash/current/configuration.html)
|
49
|
+
|
50
|
+
### Available Configuration Keys
|
51
|
+
|
52
|
+
| Parameter Name | Description | Notes |
|
53
|
+
| --- | --- | --- |
|
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
|
+
| **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. | 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|
|
58
|
+
| **database**| Database name to place events | Required |
|
59
|
+
| **table** | Target table name to place events | Required
|
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 |
|
61
|
+
| **recovery** | If set to true (default), plugin will attempt to resend pre-existing temp files found in the path upon startup | |
|
62
|
+
| **delete_temp_files** | Determines if temp files will be deleted after a successful upload (true is default; set false for debug purposes only)| |
|
63
|
+
| **flush_interval** | The time (in seconds) for flushing writes to temporary files. Default is 2 seconds, 0 will flush on every event. Increase this value to reduce IO calls but keep in mind that events in the buffer will be lost in case of abrupt failure.| |
|
64
|
+
| **proxy_host** | The proxy hostname for redirecting traffic to Kusto.| |
|
65
|
+
| **proxy_port** | The proxy port for the proxy. Defaults to 80.| |
|
66
|
+
| **proxy_protocol** | The proxy server protocol , is one of http or https.| |
|
67
|
+
|
68
|
+
> Note : LS_JAVA_OPTS can be used to set proxy parameters as well (using export or SET options)
|
69
|
+
|
70
|
+
```bash
|
71
|
+
export LS_JAVA_OPTS="-Dhttp.proxyHost=1.2.34 -Dhttp.proxyPort=8989 -Dhttps.proxyHost=1.2.3.4 -Dhttps.proxyPort=8989"
|
72
|
+
```
|
73
|
+
|
74
|
+
|
75
|
+
### Release Notes and versions
|
76
|
+
|
77
|
+
| Version | Release Date | Notes |
|
78
|
+
| --- | --- | --- |
|
79
|
+
| 2.0.0 | 2023-09-19 | - Upgrade to the latest Java SDK version [5.0.2](https://github.com/Azure/azure-kusto-java/releases/tag/v5.0.2). Tests have been performed on **__Logstash 8.5__** and up (Does not work with 6.x or 7.x versions of Logstash - For these versions use 1.x.x versions of logstash-output-kusto gem) - Fixes CVE's in common-text & outdated Jackson libraries |
|
80
|
+
| 1.0.6 | 2022-11-29 | - Upgrade to the latest Java SDK [3.2.1](https://github.com/Azure/azure-kusto-java/releases/tag/v3.2.1) version. Tests have been performed on Logstash 6.x and up.|
|
81
|
+
|
82
|
+
|
83
|
+
## Development Requirements
|
84
|
+
|
85
|
+
- Openjdk **8 64bit** (https://www.openlogic.com/openjdk-downloads)
|
86
|
+
- JRuby 9.2 or higher, defined with openjdk 8 64bit
|
87
|
+
- Logstash, defined with openjdk 8 64bit
|
88
|
+
|
89
|
+
*It is reccomened to use the bundled jdk and jruby with logstash to avoid compatibility issues.*
|
90
|
+
|
91
|
+
To fully build the gem, run:
|
92
|
+
|
93
|
+
```shell
|
94
|
+
bundle install
|
95
|
+
lock_jars
|
96
|
+
gem build
|
97
|
+
```
|
98
|
+
|
99
|
+
## Contributing
|
100
|
+
|
101
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, and complaints.
|
102
|
+
Programming is not a required skill. It is more important to the community that you are able to contribute.
|
103
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
data/SECURITY.md
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK -->
|
2
|
-
|
3
|
-
## Security
|
4
|
-
|
5
|
-
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
|
6
|
-
|
7
|
-
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
|
8
|
-
|
9
|
-
## Reporting Security Issues
|
10
|
-
|
11
|
-
**Please do not report security vulnerabilities through public GitHub issues.**
|
12
|
-
|
13
|
-
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
|
14
|
-
|
15
|
-
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
|
16
|
-
|
17
|
-
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
|
18
|
-
|
19
|
-
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
20
|
-
|
21
|
-
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
22
|
-
* Full paths of source file(s) related to the manifestation of the issue
|
23
|
-
* The location of the affected source code (tag/branch/commit or direct URL)
|
24
|
-
* Any special configuration required to reproduce the issue
|
25
|
-
* Step-by-step instructions to reproduce the issue
|
26
|
-
* Proof-of-concept or exploit code (if possible)
|
27
|
-
* Impact of the issue, including how an attacker might exploit the issue
|
28
|
-
|
29
|
-
This information will help us triage your report more quickly.
|
30
|
-
|
31
|
-
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
|
32
|
-
|
33
|
-
## Preferred Languages
|
34
|
-
|
35
|
-
We prefer all communications to be in English.
|
36
|
-
|
37
|
-
## Policy
|
38
|
-
|
39
|
-
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
|
40
|
-
|
41
|
-
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
1
|
+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK -->
|
2
|
+
|
3
|
+
## Security
|
4
|
+
|
5
|
+
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
|
6
|
+
|
7
|
+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
|
8
|
+
|
9
|
+
## Reporting Security Issues
|
10
|
+
|
11
|
+
**Please do not report security vulnerabilities through public GitHub issues.**
|
12
|
+
|
13
|
+
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
|
14
|
+
|
15
|
+
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
|
16
|
+
|
17
|
+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
|
18
|
+
|
19
|
+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
20
|
+
|
21
|
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
22
|
+
* Full paths of source file(s) related to the manifestation of the issue
|
23
|
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
24
|
+
* Any special configuration required to reproduce the issue
|
25
|
+
* Step-by-step instructions to reproduce the issue
|
26
|
+
* Proof-of-concept or exploit code (if possible)
|
27
|
+
* Impact of the issue, including how an attacker might exploit the issue
|
28
|
+
|
29
|
+
This information will help us triage your report more quickly.
|
30
|
+
|
31
|
+
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
|
32
|
+
|
33
|
+
## Preferred Languages
|
34
|
+
|
35
|
+
We prefer all communications to be in English.
|
36
|
+
|
37
|
+
## Policy
|
38
|
+
|
39
|
+
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
|
40
|
+
|
41
|
+
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
@@ -1,138 +1,166 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'logstash/outputs/base'
|
4
|
-
require 'logstash/namespace'
|
5
|
-
require 'logstash/errors'
|
6
|
-
|
7
|
-
class LogStash::Outputs::Kusto < LogStash::Outputs::Base
|
8
|
-
##
|
9
|
-
# This handles the overall logic and communication with Kusto
|
10
|
-
#
|
11
|
-
class Ingestor
|
12
|
-
require 'logstash-output-kusto_jars'
|
13
|
-
RETRY_DELAY_SECONDS = 3
|
14
|
-
DEFAULT_THREADPOOL = Concurrent::ThreadPoolExecutor.new(
|
15
|
-
min_threads: 1,
|
16
|
-
max_threads: 8,
|
17
|
-
max_queue: 1,
|
18
|
-
fallback_policy: :caller_runs
|
19
|
-
)
|
20
|
-
LOW_QUEUE_LENGTH = 3
|
21
|
-
FIELD_REF = /%\{[^}]+\}/
|
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)
|
24
|
-
@workers_pool = threadpool
|
25
|
-
@logger = logger
|
26
|
-
validate_config(database, table, json_mapping,proxy_protocol)
|
27
|
-
@logger.info('Preparing Kusto resources.')
|
28
|
-
|
29
|
-
kusto_java = Java::com.microsoft.azure.kusto
|
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)
|
32
|
-
#
|
33
|
-
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
def
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'logstash/outputs/base'
|
4
|
+
require 'logstash/namespace'
|
5
|
+
require 'logstash/errors'
|
6
|
+
|
7
|
+
class LogStash::Outputs::Kusto < LogStash::Outputs::Base
|
8
|
+
##
|
9
|
+
# This handles the overall logic and communication with Kusto
|
10
|
+
#
|
11
|
+
class Ingestor
|
12
|
+
require 'logstash-output-kusto_jars'
|
13
|
+
RETRY_DELAY_SECONDS = 3
|
14
|
+
DEFAULT_THREADPOOL = Concurrent::ThreadPoolExecutor.new(
|
15
|
+
min_threads: 1,
|
16
|
+
max_threads: 8,
|
17
|
+
max_queue: 1,
|
18
|
+
fallback_policy: :caller_runs
|
19
|
+
)
|
20
|
+
LOW_QUEUE_LENGTH = 3
|
21
|
+
FIELD_REF = /%\{[^}]+\}/
|
22
|
+
|
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
|
+
@workers_pool = threadpool
|
25
|
+
@logger = logger
|
26
|
+
validate_config(database, table, json_mapping,proxy_protocol,app_id, app_key, managed_identity_id)
|
27
|
+
@logger.info('Preparing Kusto resources.')
|
28
|
+
|
29
|
+
kusto_java = Java::com.microsoft.azure.kusto
|
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)
|
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
|
+
|
51
|
+
#
|
52
|
+
@logger.debug(Gem.loaded_specs.to_s)
|
53
|
+
# Unfortunately there's no way to avoid using the gem/plugin name directly...
|
54
|
+
name_for_tracing = "logstash-output-kusto:#{Gem.loaded_specs['logstash-output-kusto']&.version || "unknown"}"
|
55
|
+
@logger.debug("Client name for tracing: #{name_for_tracing}")
|
56
|
+
|
57
|
+
tuple_utils = Java::org.apache.commons.lang3.tuple
|
58
|
+
# kusto_connection_string.setClientVersionForTracing(name_for_tracing)
|
59
|
+
version_for_tracing=Gem.loaded_specs['logstash-output-kusto']&.version || "unknown"
|
60
|
+
kusto_connection_string.setConnectorDetails("Logstash",version_for_tracing.to_s,"","",false,"", tuple_utils.Pair.emptyArray());
|
61
|
+
|
62
|
+
@kusto_client = begin
|
63
|
+
if is_direct_conn
|
64
|
+
kusto_java.ingest.IngestClientFactory.createClient(kusto_connection_string)
|
65
|
+
else
|
66
|
+
kusto_http_client_properties = kusto_java.data.HttpClientProperties.builder().proxy(apache_http.HttpHost.new(proxy_host,proxy_port,proxy_protocol)).build()
|
67
|
+
kusto_java.ingest.IngestClientFactory.createClient(kusto_connection_string, kusto_http_client_properties)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
@ingestion_properties = kusto_java.ingest.IngestionProperties.new(database, table)
|
72
|
+
@ingestion_properties.setIngestionMapping(json_mapping, kusto_java.ingest.IngestionMapping::IngestionMappingKind::JSON)
|
73
|
+
@ingestion_properties.setDataFormat(kusto_java.ingest.IngestionProperties::DataFormat::JSON)
|
74
|
+
@delete_local = delete_local
|
75
|
+
|
76
|
+
@logger.debug('Kusto resources are ready.')
|
77
|
+
end
|
78
|
+
|
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
|
85
|
+
if database =~ FIELD_REF
|
86
|
+
@logger.error('database config value should not be dynamic.', database)
|
87
|
+
raise LogStash::ConfigurationError.new('database config value should not be dynamic.')
|
88
|
+
end
|
89
|
+
|
90
|
+
if table =~ FIELD_REF
|
91
|
+
@logger.error('table config value should not be dynamic.', table)
|
92
|
+
raise LogStash::ConfigurationError.new('table config value should not be dynamic.')
|
93
|
+
end
|
94
|
+
|
95
|
+
if json_mapping =~ FIELD_REF
|
96
|
+
@logger.error('json_mapping config value should not be dynamic.', json_mapping)
|
97
|
+
raise LogStash::ConfigurationError.new('json_mapping config value should not be dynamic.')
|
98
|
+
end
|
99
|
+
|
100
|
+
if not(["https", "http"].include? proxy_protocol)
|
101
|
+
@logger.error('proxy_protocol has to be http or https.', proxy_protocol)
|
102
|
+
raise LogStash::ConfigurationError.new('proxy_protocol has to be http or https.')
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
def upload_async(path, delete_on_success)
|
108
|
+
if @workers_pool.remaining_capacity <= LOW_QUEUE_LENGTH
|
109
|
+
@logger.warn("Ingestor queue capacity is running low with #{@workers_pool.remaining_capacity} free slots.")
|
110
|
+
end
|
111
|
+
|
112
|
+
@workers_pool.post do
|
113
|
+
LogStash::Util.set_thread_name("Kusto to ingest file: #{path}")
|
114
|
+
upload(path, delete_on_success)
|
115
|
+
end
|
116
|
+
rescue Exception => e
|
117
|
+
@logger.error('StandardError.', exception: e.class, message: e.message, path: path, backtrace: e.backtrace)
|
118
|
+
raise e
|
119
|
+
end
|
120
|
+
|
121
|
+
def upload(path, delete_on_success)
|
122
|
+
file_size = File.size(path)
|
123
|
+
@logger.debug("Sending file to kusto: #{path}. size: #{file_size}")
|
124
|
+
|
125
|
+
# TODO: dynamic routing
|
126
|
+
# file_metadata = path.partition('.kusto.').last
|
127
|
+
# file_metadata_parts = file_metadata.split('.')
|
128
|
+
|
129
|
+
# if file_metadata_parts.length == 3
|
130
|
+
# # this is the number we expect - database, table, json_mapping
|
131
|
+
# database = file_metadata_parts[0]
|
132
|
+
# table = file_metadata_parts[1]
|
133
|
+
# json_mapping = file_metadata_parts[2]
|
134
|
+
|
135
|
+
# local_ingestion_properties = Java::KustoIngestionProperties.new(database, table)
|
136
|
+
# local_ingestion_properties.addJsonMappingName(json_mapping)
|
137
|
+
# end
|
138
|
+
|
139
|
+
if file_size > 0
|
140
|
+
file_source_info = Java::com.microsoft.azure.kusto.ingest.source.FileSourceInfo.new(path, 0); # 0 - let the sdk figure out the size of the file
|
141
|
+
@kusto_client.ingestFromFile(file_source_info, @ingestion_properties)
|
142
|
+
else
|
143
|
+
@logger.warn("File #{path} is an empty file and is not ingested.")
|
144
|
+
end
|
145
|
+
File.delete(path) if delete_on_success
|
146
|
+
@logger.debug("File #{path} sent to kusto.")
|
147
|
+
rescue Errno::ENOENT => e
|
148
|
+
@logger.error("File doesn't exist! Unrecoverable error.", exception: e.class, message: e.message, path: path, backtrace: e.backtrace)
|
149
|
+
rescue Java::JavaNioFile::NoSuchFileException => e
|
150
|
+
@logger.error("File doesn't exist! Unrecoverable error.", exception: e.class, message: e.message, path: path, backtrace: e.backtrace)
|
151
|
+
rescue => e
|
152
|
+
# When the retry limit is reached or another error happen we will wait and retry.
|
153
|
+
#
|
154
|
+
# Thread might be stuck here, but I think its better than losing anything
|
155
|
+
# its either a transient errors or something bad really happened.
|
156
|
+
@logger.error('Uploading failed, retrying.', exception: e.class, message: e.message, path: path, backtrace: e.backtrace)
|
157
|
+
sleep RETRY_DELAY_SECONDS
|
158
|
+
retry
|
159
|
+
end
|
160
|
+
|
161
|
+
def stop
|
162
|
+
@workers_pool.shutdown
|
163
|
+
@workers_pool.wait_for_termination(nil) # block until its done
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|