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.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -37
  3. data/CONTRIBUTORS +10 -10
  4. data/Gemfile +11 -22
  5. data/LICENSE +201 -201
  6. data/README.md +103 -94
  7. data/SECURITY.md +41 -41
  8. data/lib/logstash/outputs/kusto/ingestor.rb +166 -138
  9. data/lib/logstash/outputs/kusto/interval.rb +81 -81
  10. data/lib/logstash/outputs/kusto.rb +424 -422
  11. data/lib/logstash-output-kusto_jars.rb +72 -149
  12. data/logstash-output-kusto.gemspec +35 -36
  13. data/spec/outputs/kusto/ingestor_spec.rb +131 -121
  14. data/spec/outputs/kusto_spec.rb +56 -56
  15. data/spec/spec_helpers.rb +21 -21
  16. data/vendor/jar-dependencies/com/azure/azure-core/1.41.0/azure-core-1.41.0.jar +0 -0
  17. data/vendor/jar-dependencies/com/azure/azure-core-http-netty/1.13.5/azure-core-http-netty-1.13.5.jar +0 -0
  18. data/vendor/jar-dependencies/com/azure/azure-data-tables/12.3.13/azure-data-tables-12.3.13.jar +0 -0
  19. data/vendor/jar-dependencies/com/azure/azure-identity/1.9.2/azure-identity-1.9.2.jar +0 -0
  20. data/vendor/jar-dependencies/com/azure/azure-json/1.0.1/azure-json-1.0.1.jar +0 -0
  21. data/vendor/jar-dependencies/com/azure/azure-storage-blob/12.23.0/azure-storage-blob-12.23.0.jar +0 -0
  22. data/vendor/jar-dependencies/com/azure/azure-storage-common/12.22.0/azure-storage-common-12.22.0.jar +0 -0
  23. data/vendor/jar-dependencies/com/azure/azure-storage-internal-avro/12.8.0/azure-storage-internal-avro-12.8.0.jar +0 -0
  24. data/vendor/jar-dependencies/com/azure/azure-storage-queue/12.18.0/azure-storage-queue-12.18.0.jar +0 -0
  25. 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
  26. data/vendor/jar-dependencies/com/fasterxml/jackson/core/jackson-core/2.14.2/jackson-core-2.14.2.jar +0 -0
  27. 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
  28. data/vendor/jar-dependencies/com/fasterxml/jackson/dataformat/jackson-dataformat-xml/2.14.2/jackson-dataformat-xml-2.14.2.jar +0 -0
  29. data/vendor/jar-dependencies/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.14.2/jackson-datatype-jsr310-2.14.2.jar +0 -0
  30. 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
  31. data/vendor/jar-dependencies/com/microsoft/azure/kusto/kusto-data/5.0.2/kusto-data-5.0.2.jar +0 -0
  32. data/vendor/jar-dependencies/com/microsoft/azure/kusto/kusto-ingest/5.0.2/kusto-ingest-5.0.2.jar +0 -0
  33. data/vendor/jar-dependencies/com/microsoft/azure/msal4j/1.13.8/msal4j-1.13.8.jar +0 -0
  34. 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
  35. data/vendor/jar-dependencies/com/nimbusds/content-type/2.2/content-type-2.2.jar +0 -0
  36. data/vendor/jar-dependencies/com/nimbusds/lang-tag/1.7/lang-tag-1.7.jar +0 -0
  37. data/vendor/jar-dependencies/com/nimbusds/nimbus-jose-jwt/9.30.2/nimbus-jose-jwt-9.30.2.jar +0 -0
  38. data/vendor/jar-dependencies/com/nimbusds/oauth2-oidc-sdk/10.7.1/oauth2-oidc-sdk-10.7.1.jar +0 -0
  39. data/vendor/jar-dependencies/commons-codec/commons-codec/1.13/commons-codec-1.13.jar +0 -0
  40. data/vendor/jar-dependencies/io/netty/netty-buffer/4.1.94.Final/netty-buffer-4.1.94.Final.jar +0 -0
  41. 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
  42. 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
  43. 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
  44. 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
  45. data/vendor/jar-dependencies/io/netty/netty-codec-socks/4.1.94.Final/netty-codec-socks-4.1.94.Final.jar +0 -0
  46. data/vendor/jar-dependencies/io/netty/netty-common/4.1.94.Final/netty-common-4.1.94.Final.jar +0 -0
  47. 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
  48. 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
  49. 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
  50. data/vendor/jar-dependencies/io/netty/netty-resolver-dns/4.1.94.Final/netty-resolver-dns-4.1.94.Final.jar +0 -0
  51. 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
  52. 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
  53. 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
  54. data/vendor/jar-dependencies/io/netty/netty-tcnative-classes/2.0.61.Final/netty-tcnative-classes-2.0.61.Final.jar +0 -0
  55. 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
  56. 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
  57. 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
  58. 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
  59. 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
  60. 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
  61. data/vendor/jar-dependencies/io/projectreactor/netty/reactor-netty-core/1.0.33/reactor-netty-core-1.0.33.jar +0 -0
  62. data/vendor/jar-dependencies/io/projectreactor/netty/reactor-netty-http/1.0.33/reactor-netty-http-1.0.33.jar +0 -0
  63. 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
  64. data/vendor/jar-dependencies/net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar +0 -0
  65. data/vendor/jar-dependencies/net/java/dev/jna/jna-platform/5.13.0/jna-platform-5.13.0.jar +0 -0
  66. 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
  67. 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
  68. data/vendor/jar-dependencies/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar +0 -0
  69. data/vendor/jar-dependencies/org/apache/httpcomponents/httpclient/4.5.14/httpclient-4.5.14.jar +0 -0
  70. data/vendor/jar-dependencies/org/apache/httpcomponents/httpcore/4.4.16/httpcore-4.4.16.jar +0 -0
  71. data/vendor/jar-dependencies/org/logstash/outputs/logstash-output-kusto/2.0.1/logstash-output-kusto-2.0.1.jar +0 -0
  72. data/vendor/jar-dependencies/org/ow2/asm/asm/9.3/asm-9.3.jar +0 -0
  73. data/vendor/jar-dependencies/org/reactivestreams/reactive-streams/1.0.4/reactive-streams-1.0.4.jar +0 -0
  74. data/version +1 -0
  75. metadata +111 -113
  76. data/lib/com/azure/azure-core/1.21.0/azure-core-1.21.0.jar +0 -0
  77. data/lib/com/azure/azure-core-http-netty/1.11.1/azure-core-http-netty-1.11.1.jar +0 -0
  78. data/lib/com/azure/azure-identity/1.3.7/azure-identity-1.3.7.jar +0 -0
  79. data/lib/com/fasterxml/jackson/core/jackson-annotations/2.13.0/jackson-annotations-2.13.0.jar +0 -0
  80. data/lib/com/fasterxml/jackson/core/jackson-core/2.12.5/jackson-core-2.12.5.jar +0 -0
  81. data/lib/com/fasterxml/jackson/core/jackson-core/2.13.0/jackson-core-2.13.0.jar +0 -0
  82. data/lib/com/fasterxml/jackson/core/jackson-databind/2.12.5/jackson-databind-2.12.5.jar +0 -0
  83. data/lib/com/fasterxml/jackson/dataformat/jackson-dataformat-xml/2.12.5/jackson-dataformat-xml-2.12.5.jar +0 -0
  84. data/lib/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.12.5/jackson-datatype-jsr310-2.12.5.jar +0 -0
  85. data/lib/com/fasterxml/jackson/module/jackson-module-jaxb-annotations/2.12.5/jackson-module-jaxb-annotations-2.12.5.jar +0 -0
  86. data/lib/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar +0 -0
  87. data/lib/com/google/errorprone/error_prone_annotations/2.1.3/error_prone_annotations-2.1.3.jar +0 -0
  88. data/lib/com/google/guava/guava/24.1.1-jre/guava-24.1.1-jre.jar +0 -0
  89. data/lib/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar +0 -0
  90. data/lib/com/microsoft/azure/azure-keyvault-core/1.2.4/azure-keyvault-core-1.2.4.jar +0 -0
  91. data/lib/com/microsoft/azure/azure-storage/8.6.6/azure-storage-8.6.6.jar +0 -0
  92. data/lib/com/microsoft/azure/kusto/kusto-data/3.1.1/kusto-data-3.1.1.jar +0 -0
  93. data/lib/com/microsoft/azure/kusto/kusto-data/3.1.3/kusto-data-3.1.3.jar +0 -0
  94. data/lib/com/microsoft/azure/kusto/kusto-data/3.2.1/kusto-data-3.2.1.jar +0 -0
  95. data/lib/com/microsoft/azure/kusto/kusto-ingest/3.1.1/kusto-ingest-3.1.1.jar +0 -0
  96. data/lib/com/microsoft/azure/kusto/kusto-ingest/3.1.3/kusto-ingest-3.1.3.jar +0 -0
  97. data/lib/com/microsoft/azure/kusto/kusto-ingest/3.2.1/kusto-ingest-3.2.1.jar +0 -0
  98. data/lib/com/microsoft/azure/msal4j/1.11.0/msal4j-1.11.0.jar +0 -0
  99. data/lib/com/nimbusds/content-type/2.1/content-type-2.1.jar +0 -0
  100. data/lib/com/nimbusds/lang-tag/1.5/lang-tag-1.5.jar +0 -0
  101. data/lib/com/nimbusds/nimbus-jose-jwt/9.9.3/nimbus-jose-jwt-9.9.3.jar +0 -0
  102. data/lib/com/nimbusds/oauth2-oidc-sdk/9.7/oauth2-oidc-sdk-9.7.jar +0 -0
  103. data/lib/commons-codec/commons-codec/1.11/commons-codec-1.11.jar +0 -0
  104. data/lib/io/netty/netty-buffer/4.1.68.Final/netty-buffer-4.1.68.Final.jar +0 -0
  105. data/lib/io/netty/netty-codec-socks/4.1.68.Final/netty-codec-socks-4.1.68.Final.jar +0 -0
  106. data/lib/io/netty/netty-common/4.1.68.Final/netty-common-4.1.68.Final.jar +0 -0
  107. data/lib/io/netty/netty-resolver-dns/4.1.68.Final/netty-resolver-dns-4.1.68.Final.jar +0 -0
  108. 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
  109. data/lib/io/netty/netty-tcnative-boringssl-static/2.0.43.Final/netty-tcnative-boringssl-static-2.0.43.Final.jar +0 -0
  110. 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
  111. 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
  112. 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
  113. data/lib/io/projectreactor/netty/reactor-netty-core/1.0.11/reactor-netty-core-1.0.11.jar +0 -0
  114. data/lib/io/projectreactor/netty/reactor-netty-http/1.0.11/reactor-netty-http-1.0.11.jar +0 -0
  115. data/lib/jakarta/activation/jakarta.activation-api/1.2.1/jakarta.activation-api-1.2.1.jar +0 -0
  116. data/lib/jakarta/xml/bind/jakarta.xml.bind-api/2.3.2/jakarta.xml.bind-api-2.3.2.jar +0 -0
  117. data/lib/net/java/dev/jna/jna/5.5.0/jna-5.5.0.jar +0 -0
  118. data/lib/net/java/dev/jna/jna-platform/5.6.0/jna-platform-5.6.0.jar +0 -0
  119. data/lib/org/apache/commons/commons-lang3/3.11/commons-lang3-3.11.jar +0 -0
  120. data/lib/org/apache/commons/commons-text/1.9/commons-text-1.9.jar +0 -0
  121. data/lib/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar +0 -0
  122. data/lib/org/apache/httpcomponents/httpcore/4.4.15/httpcore-4.4.15.jar +0 -0
  123. data/lib/org/checkerframework/checker-compat-qual/2.0.0/checker-compat-qual-2.0.0.jar +0 -0
  124. data/lib/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar +0 -0
  125. data/lib/org/json/json/20201115/json-20201115.jar +0 -0
  126. data/lib/org/ow2/asm/asm/9.1/asm-9.1.jar +0 -0
  127. data/lib/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar +0 -0
  128. /data/{lib → vendor/jar-dependencies}/com/github/stephenc/jcip/jcip-annotations/1.0-1/jcip-annotations-1.0-1.jar +0 -0
  129. /data/{lib → vendor/jar-dependencies}/com/univocity/univocity-parsers/2.9.1/univocity-parsers-2.9.1.jar +0 -0
  130. /data/{lib → vendor/jar-dependencies}/commons-logging/commons-logging/1.2/commons-logging-1.2.jar +0 -0
  131. /data/{lib → vendor/jar-dependencies}/io/github/resilience4j/resilience4j-core/1.7.1/resilience4j-core-1.7.1.jar +0 -0
  132. /data/{lib → vendor/jar-dependencies}/io/github/resilience4j/resilience4j-retry/1.7.1/resilience4j-retry-1.7.1.jar +0 -0
  133. /data/{lib → vendor/jar-dependencies}/io/vavr/vavr/0.10.2/vavr-0.10.2.jar +0 -0
  134. /data/{lib → vendor/jar-dependencies}/io/vavr/vavr-match/0.10.2/vavr-match-0.10.2.jar +0 -0
  135. /data/{lib → vendor/jar-dependencies}/org/apache/commons/commons-text/1.10.0/commons-text-1.10.0.jar +0 -0
  136. /data/{lib → vendor/jar-dependencies}/org/codehaus/woodstox/stax2-api/4.2.1/stax2-api-4.2.1.jar +0 -0
  137. /data/{lib → vendor/jar-dependencies}/org/jetbrains/annotations/22.0.0/annotations-22.0.0.jar +0 -0
  138. /data/{lib → vendor/jar-dependencies}/org/slf4j/slf4j-api/1.8.0-beta4/slf4j-api-1.8.0-beta4.jar +0 -0
  139. /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. | Required|
57
- | **database**| Database name to place events | Required |
58
- | **table** | Target table name to place events | Required
59
- | **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 |
60
- | **recovery** | If set to true (default), plugin will attempt to resend pre-existing temp files found in the path upon startup | |
61
- | **delete_temp_files** | Determines if temp files will be deleted after a successful upload (true is default; set false for debug purposes only)| |
62
- | **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.| |
63
- | **proxy_host** | The proxy hostname for redirecting traffic to Kusto.| |
64
- | **proxy_port** | The proxy port for the proxy. Defaults to 80.| |
65
- | **proxy_protocol** | The proxy server protocol , is one of http or https.| |
66
-
67
- > Note : LS_JAVA_OPTS can be used to set proxy parameters as well (using export or SET options)
68
-
69
- ```bash
70
- export LS_JAVA_OPTS="-Dhttp.proxyHost=1.2.34 -Dhttp.proxyPort=8989 -Dhttps.proxyHost=1.2.3.4 -Dhttps.proxyPort=8989"
71
- ```
72
-
73
-
74
- ## Development Requirements
75
-
76
- - Openjdk **8 64bit** (https://www.openlogic.com/openjdk-downloads)
77
- - JRuby 9.2 or higher, defined with openjdk 8 64bit
78
- - Logstash, defined with openjdk 8 64bit
79
-
80
- *It is reccomened to use the bundled jdk and jruby with logstash to avoid compatibility issues.*
81
-
82
- To fully build the gem, run:
83
-
84
- ```shell
85
- bundle install
86
- lock_jars
87
- gem build
88
- ```
89
-
90
- ## Contributing
91
-
92
- All contributions are welcome: ideas, patches, documentation, bug reports, and complaints.
93
- Programming is not a required skill. It is more important to the community that you are able to contribute.
94
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
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
- @logger.debug(Gem.loaded_specs.to_s)
34
- # Unfortunately there's no way to avoid using the gem/plugin name directly...
35
- name_for_tracing = "logstash-output-kusto:#{Gem.loaded_specs['logstash-output-kusto']&.version || "unknown"}"
36
- @logger.debug("Client name for tracing: #{name_for_tracing}")
37
- kusto_connection_string.setClientVersionForTracing(name_for_tracing)
38
-
39
- @kusto_client = begin
40
- if proxy_host.nil? || proxy_host.empty?
41
- kusto_java.ingest.IngestClientFactory.createClient(kusto_connection_string)
42
- else
43
- kusto_http_client_properties = kusto_java.data.HttpClientProperties.builder().proxy(apache_http.HttpHost.new(proxy_host,proxy_port,proxy_protocol)).build()
44
- kusto_java.ingest.IngestClientFactory.createClient(kusto_connection_string, kusto_http_client_properties)
45
- end
46
- end
47
-
48
- @ingestion_properties = kusto_java.ingest.IngestionProperties.new(database, table)
49
- @ingestion_properties.setIngestionMapping(json_mapping, kusto_java.ingest.IngestionMapping::IngestionMappingKind::JSON)
50
- @ingestion_properties.setDataFormat(kusto_java.ingest.IngestionProperties::DataFormat::JSON)
51
- @delete_local = delete_local
52
-
53
- @logger.debug('Kusto resources are ready.')
54
- end
55
-
56
- def validate_config(database, table, json_mapping,proxy_protocol)
57
- if database =~ FIELD_REF
58
- @logger.error('database config value should not be dynamic.', database)
59
- raise LogStash::ConfigurationError.new('database config value should not be dynamic.')
60
- end
61
-
62
- if table =~ FIELD_REF
63
- @logger.error('table config value should not be dynamic.', table)
64
- raise LogStash::ConfigurationError.new('table config value should not be dynamic.')
65
- end
66
-
67
- if json_mapping =~ FIELD_REF
68
- @logger.error('json_mapping config value should not be dynamic.', json_mapping)
69
- raise LogStash::ConfigurationError.new('json_mapping config value should not be dynamic.')
70
- end
71
-
72
- if not(["https", "http"].include? proxy_protocol)
73
- @logger.error('proxy_protocol has to be http or https.', proxy_protocol)
74
- raise LogStash::ConfigurationError.new('proxy_protocol has to be http or https.')
75
- end
76
-
77
- end
78
-
79
- def upload_async(path, delete_on_success)
80
- if @workers_pool.remaining_capacity <= LOW_QUEUE_LENGTH
81
- @logger.warn("Ingestor queue capacity is running low with #{@workers_pool.remaining_capacity} free slots.")
82
- end
83
-
84
- @workers_pool.post do
85
- LogStash::Util.set_thread_name("Kusto to ingest file: #{path}")
86
- upload(path, delete_on_success)
87
- end
88
- rescue Exception => e
89
- @logger.error('StandardError.', exception: e.class, message: e.message, path: path, backtrace: e.backtrace)
90
- raise e
91
- end
92
-
93
- def upload(path, delete_on_success)
94
- file_size = File.size(path)
95
- @logger.debug("Sending file to kusto: #{path}. size: #{file_size}")
96
-
97
- # TODO: dynamic routing
98
- # file_metadata = path.partition('.kusto.').last
99
- # file_metadata_parts = file_metadata.split('.')
100
-
101
- # if file_metadata_parts.length == 3
102
- # # this is the number we expect - database, table, json_mapping
103
- # database = file_metadata_parts[0]
104
- # table = file_metadata_parts[1]
105
- # json_mapping = file_metadata_parts[2]
106
-
107
- # local_ingestion_properties = Java::KustoIngestionProperties.new(database, table)
108
- # local_ingestion_properties.addJsonMappingName(json_mapping)
109
- # end
110
-
111
- if file_size > 0
112
- 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
113
- @kusto_client.ingestFromFile(file_source_info, @ingestion_properties)
114
- else
115
- @logger.warn("File #{path} is an empty file and is not ingested.")
116
- end
117
- File.delete(path) if delete_on_success
118
- @logger.debug("File #{path} sent to kusto.")
119
- rescue Errno::ENOENT => e
120
- @logger.error("File doesn't exist! Unrecoverable error.", exception: e.class, message: e.message, path: path, backtrace: e.backtrace)
121
- rescue Java::JavaNioFile::NoSuchFileException => e
122
- @logger.error("File doesn't exist! Unrecoverable error.", exception: e.class, message: e.message, path: path, backtrace: e.backtrace)
123
- rescue => e
124
- # When the retry limit is reached or another error happen we will wait and retry.
125
- #
126
- # Thread might be stuck here, but I think its better than losing anything
127
- # its either a transient errors or something bad really happened.
128
- @logger.error('Uploading failed, retrying.', exception: e.class, message: e.message, path: path, backtrace: e.backtrace)
129
- sleep RETRY_DELAY_SECONDS
130
- retry
131
- end
132
-
133
- def stop
134
- @workers_pool.shutdown
135
- @workers_pool.wait_for_termination(nil) # block until its done
136
- end
137
- end
138
- end
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