Merge lp:~michael.nelson/charms/trusty/logstash-forwarder/enable-files-to-be-list-of-hashes into lp:~canonical-is-sa/charms/trusty/logstash-forwarder/trunk

Proposed by Michael Nelson
Status: Merged
Merged at revision: 15
Proposed branch: lp:~michael.nelson/charms/trusty/logstash-forwarder/enable-files-to-be-list-of-hashes
Merge into: lp:~canonical-is-sa/charms/trusty/logstash-forwarder/trunk
Diff against target: 39 lines (+15/-3)
2 files modified
config.yaml (+3/-0)
hooks/hooks.py (+12/-3)
To merge this branch: bzr merge lp:~michael.nelson/charms/trusty/logstash-forwarder/enable-files-to-be-list-of-hashes
Reviewer Review Type Date Requested Status
Michael Foley (community) Approve
Review via email: mp+276726@code.launchpad.net

Commit message

Enable files option to be normal list of hashes as per https://github.com/elastic/logstash-forwarder .
This allows extra fields to be sent with the data (useful for providing a field to differentiate different services sending data).

Description of the change

I've tested this on staging already, and works as expected.

To post a comment you must log in.
Revision history for this message
Michael Foley (foli) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-10-27 00:53:20 +0000
3+++ config.yaml 2015-11-05 05:07:22 +0000
4@@ -23,6 +23,9 @@
5 and their field type
6 e.g. {"syslog": ["/var/log/syslog", "/var/log/*.log"],
7 "apache": ["/var/log/apache2/*log"]}
8+ Alternatively, this can also be the full list of hashes, as per the
9+ definition of the files attribute of the logstash-forwarder config at
10+ https://github.com/elastic/logstash-forwarder
11 package_name:
12 default: "logstash-forwarder_0.4.0_amd64.deb"
13 type: string
14
15=== modified file 'hooks/hooks.py'
16--- hooks/hooks.py 2015-09-28 18:29:30 +0000
17+++ hooks/hooks.py 2015-11-05 05:07:22 +0000
18@@ -99,9 +99,18 @@
19
20 fileSpec = conf.files()
21 if fileSpec is not None:
22- for logType in fileSpec:
23- files.append({"paths": fileSpec[logType], "fields": {"type": logType}})
24- config["files"] = files
25+ if isinstance(fileSpec, list):
26+ # The files option is a list of hashes, as per the definition
27+ # of the files attribute of the logstash-forwarder config at:
28+ # https://github.com/elastic/logstash-forwarder
29+ config["files"] = fileSpec
30+ else:
31+ for logType in fileSpec:
32+ files.append({
33+ "paths": fileSpec[logType],
34+ "fields": {"type": logType}
35+ })
36+ config["files"] = files
37
38 with open(conf.configFile(), "w") as f:
39 f.write(json.dumps(config, sort_keys=True, indent=4))

Subscribers

People subscribed via source and target branches