logstash-filter-docker_metadata 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +79 -36
- data/dockerTest.sh +7 -0
- data/lib/logstash/filters/docker_metadata.rb +4 -1
- data/logstash-filter-docker_metadata.gemspec +1 -1
- data/setup.sh +3 -0
- metadata +4 -6
- data/CHANGELOG.md +0 -0
- data/CONTRIBUTORS +0 -11
- data/DEVELOPER.md +0 -2
- data/test.sh +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a66da1eeb97f430fd70b50c0f64e919720f4deb7
|
4
|
+
data.tar.gz: b7541a2bf62f822fa9451add76409f44a84a4cf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18ec65c708656acbbd13a616cb575a731a773c440e6e5d2dbdadcf0138c0988b0380a246b4d545ca6772e29243c3ede67376b20113991a308a7eae9efcf4af47
|
7
|
+
data.tar.gz: 06873c46f5dc1bffcb953ddd7b358f55ba4958a7437797e0c1129edd9de573c3fea505d6528b33c3f95ed12a9958e4667838394a0d77ede70d5aa8e3dec789f0
|
data/README.md
CHANGED
@@ -2,18 +2,65 @@
|
|
2
2
|
|
3
3
|
This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
|
4
4
|
|
5
|
-
|
5
|
+
This filter add docker metadata to messages that contain a docker ID. It's heavily inspired from [fluent-plugin-docker_metadata_filter](https://github.com/fabric8io/fluent-plugin-docker_metadata_filter).
|
6
6
|
|
7
|
-
|
7
|
+
This plugin use the Docker socket to call Docker API, therefore it needs the docker socket to be mounted (at least in read-only mode) inside the container.
|
8
|
+
Example :
|
9
|
+
```
|
10
|
+
docker run -ti -v /var/run/docker.sock:/var/run/docker.sock:ro logstash
|
11
|
+
```
|
12
|
+
|
13
|
+
At this point, It add to the event :
|
14
|
+
- name of the container
|
15
|
+
- complete id of the container
|
16
|
+
- image used
|
17
|
+
- labels
|
18
|
+
- environment variables injected inside the container
|
19
|
+
|
20
|
+
But everything accessible from the docker API (or via `docker inspect `) can be exported.
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Configuration used : `logstash agent -e "filter { docker_metadata{} }"`
|
25
|
+
|
26
|
+
Another container is running with `-e jesuis=goleri` with ID `68073a44cdde2d2a14a91e06a036c9c03f8c3122deb47e44c908f5fb6391394e` .
|
27
|
+
|
28
|
+
Input :
|
29
|
+
```json
|
30
|
+
ConfPath": "/var/lib/docker/containers/68073a44cdde2d2a14a91e06a036c9c03f8c3122deb47e44c908f5fb6391394e/resolv.conf",
|
31
|
+
```
|
8
32
|
|
9
|
-
Logstash
|
33
|
+
Logstash output :
|
34
|
+
```
|
35
|
+
{
|
36
|
+
"message" => "ConfPath\": \"/var/lib/docker/containers/68073a44cdde2d2a14a91e06a036c9c03f8c3122deb47e44c908f5fb6391394e/resolv.conf\",",
|
37
|
+
"@version" => "1",
|
38
|
+
"@timestamp" => "2015-08-04T14:49:51.807Z",
|
39
|
+
"type" => "stdin",
|
40
|
+
"host" => "4187a88a77cf",
|
41
|
+
"docker" => {
|
42
|
+
:id => "68073a44cdde2d2a14a91e06a036c9c03f8c3122deb47e44c908f5fb6391394e",
|
43
|
+
:name => "/serene_wilson",
|
44
|
+
:container_hostname => "68073a44cdde",
|
45
|
+
:image => "kk_centos",
|
46
|
+
:image_id => "c0050e8a70ae96325986222df1ce0b81e9170a01442173de39c6b622eb0bda22",
|
47
|
+
:labels => {},
|
48
|
+
:env => {
|
49
|
+
"jesuis" => "goleri",
|
50
|
+
"PATH" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
```
|
55
|
+
## Filter parameters
|
10
56
|
|
11
|
-
|
12
|
-
|
57
|
+
| name | default value | comment |
|
58
|
+
| :------------- | :------------- | :------------- |
|
59
|
+
| `docker_url` | `unix:///var/run/docker.sock` | make sure it match where you mount the docker socket |
|
60
|
+
| `container_id_regexp` | `(\w{64})` | match the complete Id of a docker container |
|
61
|
+
| `cache_size` | 100 | |
|
13
62
|
|
14
|
-
## Need Help?
|
15
63
|
|
16
|
-
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
17
64
|
|
18
65
|
## Developing
|
19
66
|
|
@@ -22,58 +69,51 @@ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/log
|
|
22
69
|
#### Code
|
23
70
|
- To get started, you'll need JRuby with the Bundler gem installed.
|
24
71
|
|
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
72
|
- Install dependencies
|
28
73
|
```sh
|
29
74
|
bundle install
|
30
75
|
```
|
31
76
|
|
32
77
|
#### Test
|
78
|
+
There is no unit tests.
|
79
|
+
TODO : write unit tests
|
33
80
|
|
34
|
-
|
35
|
-
|
81
|
+
#### Build gem
|
36
82
|
```sh
|
37
|
-
|
83
|
+
gem build logstash-filter-docker_metadata.gemspec
|
38
84
|
```
|
39
85
|
|
40
|
-
|
86
|
+
### 2. Running your unpublished Plugin in Logstash
|
41
87
|
|
88
|
+
#### 2.1 Run in a local Logstash Docker container
|
89
|
+
There is a script which launch a docker container using the latest logstash image and mount this directory into the container at `/tmp/logstash-filter/`
|
90
|
+
|
91
|
+
- Build the gem outside of the container
|
42
92
|
```sh
|
43
|
-
|
93
|
+
gem build logstash-filter-docker_metadata.gemspec
|
44
94
|
```
|
45
95
|
|
46
|
-
|
47
|
-
|
48
|
-
|
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"
|
96
|
+
- start the docker container
|
97
|
+
```sh
|
98
|
+
./dockerTest.sh
|
53
99
|
```
|
100
|
+
|
54
101
|
- Install plugin
|
55
102
|
```sh
|
56
|
-
|
103
|
+
plugin install /tmp/logstash-filter/logstash-filter-docker_metadata-0.1.0.gem
|
57
104
|
```
|
58
105
|
- Run Logstash with your plugin
|
59
106
|
```sh
|
60
|
-
|
107
|
+
logstash agent -e "filter { docker_metadata{} }"
|
61
108
|
```
|
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
109
|
|
64
|
-
|
110
|
+
The 2 last steps can be done in one command using `setupPlugin` command.
|
111
|
+
|
112
|
+
|
113
|
+
At this point any modifications to the plugin code will not be applied to this local Logstash setup.
|
114
|
+
After modifying the plugin, rebuild the gem and reinstalle it inside the docker container.
|
65
115
|
|
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
116
|
|
68
|
-
- Build your plugin gem
|
69
|
-
```sh
|
70
|
-
gem build logstash-filter-awesome.gemspec
|
71
|
-
```
|
72
|
-
- Install the plugin from the Logstash home
|
73
|
-
```sh
|
74
|
-
bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
|
75
|
-
```
|
76
|
-
- Start Logstash and proceed to test the plugin
|
77
117
|
|
78
118
|
## Contributing
|
79
119
|
|
@@ -83,4 +123,7 @@ Programming is not a required skill. Whatever you've seen about open source and
|
|
83
123
|
|
84
124
|
It is more important to the community that you are able to contribute.
|
85
125
|
|
86
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
|
126
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
|
127
|
+
|
128
|
+
## Licence
|
129
|
+
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.
|
data/dockerTest.sh
ADDED
@@ -13,6 +13,7 @@ class LogStash::Filters::DockerMetadata < LogStash::Filters::Base
|
|
13
13
|
# Setting the config_name here is required.
|
14
14
|
config_name "docker_metadata"
|
15
15
|
|
16
|
+
|
16
17
|
config :docker_url,
|
17
18
|
:validate => :string,
|
18
19
|
:default => 'unix:///var/run/docker.sock',
|
@@ -63,7 +64,9 @@ class LogStash::Filters::DockerMetadata < LogStash::Filters::Base
|
|
63
64
|
def filter(event)
|
64
65
|
|
65
66
|
# get container id from message field
|
66
|
-
|
67
|
+
if event["message"]
|
68
|
+
container_id = event["message"].match(@container_id_regexp_compiled)
|
69
|
+
end
|
67
70
|
|
68
71
|
# if it failed fall back to source field
|
69
72
|
if !container_id || !container_id[0]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-filter-docker_metadata'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.1'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "This filter add docker metadata to messages that contain a docker ID. It's heavily inspired from https://github.com/fabric8io/fluent-plugin-docker_metadata_filter."
|
6
6
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
data/setup.sh
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-docker_metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,19 +93,17 @@ extensions: []
|
|
93
93
|
extra_rdoc_files: []
|
94
94
|
files:
|
95
95
|
- .gitignore
|
96
|
-
- CHANGELOG.md
|
97
|
-
- CONTRIBUTORS
|
98
|
-
- DEVELOPER.md
|
99
96
|
- Gemfile
|
100
97
|
- LICENSE
|
101
98
|
- NOTICE.TXT
|
102
99
|
- README.md
|
103
100
|
- Rakefile
|
101
|
+
- dockerTest.sh
|
104
102
|
- lib/logstash/filters/docker_metadata.rb
|
105
103
|
- logstash-filter-docker_metadata.gemspec
|
104
|
+
- setup.sh
|
106
105
|
- spec/filters/docker_metadata_spec.rb
|
107
106
|
- spec/spec_helper.rb
|
108
|
-
- test.sh
|
109
107
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
110
108
|
licenses:
|
111
109
|
- Apache License (2.0)
|
data/CHANGELOG.md
DELETED
File without changes
|
data/CONTRIBUTORS
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
The following is a list of people who have contributed ideas, code, bug
|
2
|
-
reports, or in general have helped logstash along its way.
|
3
|
-
|
4
|
-
Contributors:
|
5
|
-
* Aaron Mildenstein (untergeek)
|
6
|
-
* Pier-Hugues Pellerin (ph)
|
7
|
-
|
8
|
-
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
9
|
-
Logstash, and you aren't on the list above and want to be, please let us know
|
10
|
-
and we'll make sure you're here. Contributions from folks like you are what make
|
11
|
-
open source awesome.
|
data/DEVELOPER.md
DELETED
data/test.sh
DELETED