logstash-output-vespa 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05d52921a31026d0ec3211b06fe3c79d8d0244253015bb74695ea3aaf80ec93f
4
- data.tar.gz: b8b69aea8f790482f799574e73ac00496d1dfd95b2ea9a97ba56b50665ff5c7a
3
+ metadata.gz: 41c0e438716ffaaa72e96627a14c74d4f312dcbf39917e7f75ab59b6f5aec6ae
4
+ data.tar.gz: 25278f341f1f723611c4027ff39ab4fa3b9c6d72b9bd933f0a0ee2771faaefa9
5
5
  SHA512:
6
- metadata.gz: b5644a86918bb0f72e9b7656ae4a6c864c12afb00979603366175d42728d1816d1285088a2a652543d6de703430e345d2dc6c658fc2203e19a97ab4aa13fe567
7
- data.tar.gz: 2b4c7e6922a94efda2923fc8af562e1c9ae5f78a62e326922f3c02406a9f270ffd899b152fcc6d74a476766c738ba182bfeac9e0ef207e721dbc3f9eb2d5e3ea
6
+ metadata.gz: 748862347e49001a6176f5ad169757eec674037552bf1f6b02057ad4387c6caf005078a32d9aaf9ce8f5467e4830eb6d1fe8eed2c6ad90917f3dc2eb3fd5cc79
7
+ data.tar.gz: 9bc3f31f0da3ac7811cd238a1d018f7f33aef97151ecc64caa84e9ed4e0a7c721dae732cbf355bc4831de22247f9aa03538e0cf56df64b44a2d48d7e16230277
data/README.md CHANGED
@@ -4,83 +4,32 @@ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
4
 
5
5
  It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
6
 
7
- ## Documentation
7
+ ## Installation
8
8
 
9
- Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
10
-
11
- - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
- - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
-
14
- ## Need Help?
15
-
16
- Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
-
18
- ## Developing
19
-
20
- ### 1. Plugin Developement and Testing
21
-
22
- #### Code
23
- - To get started, you'll need JRuby with the Bundler gem installed.
24
-
25
- - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
26
-
27
- - Install dependencies
28
- ```sh
29
- bundle install
9
+ If you're developing it, then:
30
10
  ```
31
-
32
- #### Test
33
-
34
- - Update your dependencies
35
-
36
- ```sh
11
+ # get the dependencies
37
12
  bundle install
13
+ # build the gem
14
+ gem build logstash-output-vespa.gemspec
15
+ # install it as a Logstash plugin
16
+ /opt/logstash/bin/logstash-plugin install /path/to/logstash-output-vespa/logstash-output-vespa-$VERSION.gem
17
+ # profit
18
+ /opt/logstash/bin/logstash
38
19
  ```
39
20
 
40
- - Run tests
41
-
42
- ```sh
43
- bundle exec rspec
44
- ```
21
+ ## Usage
45
22
 
46
- ### 2. Running your unpublished Plugin in Logstash
23
+ In your Logstash config:
47
24
 
48
- #### 2.1 Run in a local Logstash clone
49
-
50
- - Edit Logstash `Gemfile` and add the local plugin path, for example:
51
- ```ruby
52
- gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
53
- ```
54
- - Install plugin
55
- ```sh
56
- bin/logstash-plugin install --no-verify
57
- ```
58
- - Run Logstash with your plugin
59
- ```sh
60
- bin/logstash -e 'filter {awesome {}}'
61
- ```
62
- At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
63
-
64
- #### 2.2 Run in an installed Logstash
65
-
66
- You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
67
-
68
- - Build your plugin gem
69
- ```sh
70
- gem build logstash-filter-awesome.gemspec
71
25
  ```
72
- - Install the plugin from the Logstash home
73
- ```sh
74
- bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
75
- ```
76
- - Start Logstash and proceed to test the plugin
77
-
78
- ## Contributing
79
-
80
- All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
81
-
82
- Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
83
-
84
- It is more important to the community that you are able to contribute.
85
-
86
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/main/CONTRIBUTING.md) file.
26
+ output {
27
+ vespa {
28
+ vespa_url => "http://localhost:8080"
29
+ namespace => "used_car"
30
+ document_type => "used_car"
31
+ id_field => "id"
32
+ max_retries => 60
33
+ }
34
+ }
35
+ ```
@@ -9,9 +9,9 @@ class LogStash::Outputs::Vespa < LogStash::Outputs::Base
9
9
  config_name "vespa"
10
10
 
11
11
  # URL to the Vespa instance
12
- config :vespa_url, :validate => :string, :required => true, :default => "http://localhost:8080"
12
+ config :vespa_url, :validate => :string, :default => "http://localhost:8080"
13
13
 
14
- # Namespace. You should see it in the Vespa services.xml file as "id" in the <content> tag
14
+ # Vespa namespace. A logical grouping of documents in Vespa
15
15
  config :namespace, :validate => :string, :required => true
16
16
 
17
17
  # Document type. You should see it in the Vespa services.xml file as well as in the schema file
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-vespa'
3
- s.version = '0.1.0'
3
+ s.version = '0.1.1'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = 'Logstash Output Plugin for Vespa'
6
6
  s.description = 'Writes documents to Vespa'
@@ -20,6 +20,5 @@ Gem::Specification.new do |s|
20
20
  # Gem dependencies
21
21
  s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
22
22
  s.add_runtime_dependency "logstash-codec-plain"
23
- s.add_runtime_dependency "httpx"
24
23
  s.add_development_dependency "logstash-devutils"
25
24
  end
@@ -12,6 +12,7 @@ describe LogStash::Outputs::Vespa do
12
12
  output.register
13
13
  end
14
14
 
15
+ ## TODO add tests :)
15
16
  describe "receive message" do
16
17
  subject { output.receive(sample_event) }
17
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-vespa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radu Gheorghe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-15 00:00:00.000000000 Z
11
+ date: 2024-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core-plugin-api
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: httpx
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: logstash-devutils
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -74,12 +60,10 @@ extra_rdoc_files: []
74
60
  files:
75
61
  - CHANGELOG.md
76
62
  - CONTRIBUTORS
77
- - DEVELOPER.md
78
63
  - Gemfile
79
64
  - LICENSE
80
65
  - README.md
81
66
  - lib/logstash/outputs/vespa.rb
82
- - lib/logstash/outputs/vespa.rb.http2
83
67
  - logstash-output-vespa.gemspec
84
68
  - spec/outputs/vespa_spec.rb
85
69
  homepage: http://vespa.ai
data/DEVELOPER.md DELETED
@@ -1,2 +0,0 @@
1
- # logstash-output-vespa
2
- Example output plugin. This should help bootstrap your effort to write your own output plugin!
@@ -1,93 +0,0 @@
1
- # encoding: utf-8
2
- require "logstash/outputs/base"
3
- require "logstash/namespace"
4
- require "httpx"
5
- require "json"
6
- require "uri"
7
- require "securerandom"
8
-
9
- class LogStash::Outputs::Vespa < LogStash::Outputs::Base
10
- config_name "vespa"
11
-
12
- # URL to the Vespa instance
13
- config :vespa_url, :validate => :string, :required => true, :default => "http://localhost:8080"
14
-
15
- # Content cluster name. You should see it in the Vespa services.xml file as "id" in the <content> tag
16
- config :content_cluster, :validate => :string, :required => true
17
-
18
- # Document type name. You should see it in the Vespa services.xml file as well as in the schema file
19
- config :document_type, :validate => :string, :required => true
20
-
21
- # field name to use as the document id. If not present, a UUID will be generated
22
- config :id_field, :validate => :string, :default => "id"
23
-
24
- # On failure, retry this many times
25
- config :max_retries, :validate => :number, :default => 60
26
-
27
- concurrency :shared
28
-
29
- public
30
- def register
31
- # initialize a dead letter queue writer
32
- @dlq_writer = execution_context.dlq_writer
33
-
34
- @base_uri = URI.parse(@vespa_url)
35
- end # def register
36
-
37
- public
38
- def multi_receive(events)
39
- return if events.empty?
40
-
41
- # HTTPX client with HTTP/2 support and retries
42
- http_client = HTTPX.with(:http2).plugin(:retries, max_retries: @max_retries).with(
43
- persistent: true,
44
- max_concurrent_requests: 100,
45
- buffer_size: 64_000, # 64 KB r/w buffer
46
- window_size: 64_000 # 64 KB flow control window
47
- )
48
-
49
- # initialize list of requests
50
- requests = []
51
-
52
- events.map do |event|
53
- # If there's a document "id" field, we should use it as the document id
54
- # Otherwise, we generate a UUID
55
- id = event.get(@id_field) || SecureRandom.uuid
56
-
57
- # Build the path from the cluster name, document type, and document id
58
- uri = @base_uri.dup
59
- uri.path = "/document/v1/#{@content_cluster}/#{@document_type}/docid/#{id}"
60
-
61
- document = {
62
- "fields" => event.to_hash
63
- }
64
-
65
- # Build the request. We don't run it yet
66
- request = http_client.build_request(:post, uri.to_s, json: document)
67
- # add it to the list of requests
68
- requests << request
69
- end # events.map
70
-
71
- @logger.debug("Sending #{requests.size} requests to Vespa")
72
- # Run all requests async
73
- responses = http_client.request(*requests)
74
-
75
- # Handle responses
76
- responses.each do |response|
77
- if response.status != 200
78
- # Handle non-200 response by writing to the DLQ
79
- # TODO Should we retry some of those?
80
- @logger.error("Error sending event to Vespa. Writing to dead letter queue (if configured).",
81
- :response_code => response.status, :response_body => response.body)
82
- # TODO fix this, we need to write the corresponding event
83
- @dlq_writer.write(event, response.body)
84
- end
85
- end
86
-
87
- rescue => e
88
- @logger.error("Exception caught while sending events to Vespa. Writing to dead letter queue (if configured).", :exception => e)
89
- events.each do |event|
90
- @dlq_writer.write(event, e.message)
91
- end
92
- end # def multi_receive
93
- end # class LogStash::Outputs::Vespa