pillar config
diff --git a/README.md b/README.md
index 8ace0c2..b546862 100755
--- a/README.md
+++ b/README.md
@@ -13,6 +13,22 @@
plugins:
- fluent-plugin-elasticsearch
- fluent-plugin-mongo
+ config:
+ - name: forward
+ type: input
+ bind:
+ port: 24224
+ host: 0.0.0.0
+ - name: elasticsearch
+ type: output
+ bind:
+ port: 9200
+ host: localhost
+ - name: mongodb
+ type: output
+ bind:
+ port: localhost
+ host: localhost
## Read more
diff --git a/conf/td-agent.conf b/conf/td-agent.conf
index 11ab2c7..3ee09cf 100755
--- a/conf/td-agent.conf
+++ b/conf/td-agent.conf
@@ -1,24 +1,25 @@
-<source>
- type syslog
- port 42185
- tag syslog
-</source>
+{% from "fluentd/map.jinja" import server with context %}
+{%- for config in server.config %}
+
+{%- if config.type == "input" and config.name =="forward" %}
<source>
type forward
+ port {{ config.bind.port }}
+ bind {{ config.bind.host }}
</source>
-
-<source>
- type tail
- format apache2
- path /var/log/httpd/access_log
- pos_file /var/log/td-agent/apache2.access_log.pos
- tag mongo.apache.access
-</source>
- <source>
- type forward
- </source>
-<match mongo.*.*>
+{%- endif %}
+{%- if config.type == "output" and config.name == "elasticsearch" %}
+<match *>
+ port {{ config.bind.port }}
+ bind {{ config.bind.host }}
+ type elasticsearch
+ logstash_format true
+ flush_interval 10s # for testing
+</match>
+{%- endif %}
+{%- if config.type == "output" and config.name == "mongodb" %}
+<match *>
# plugin type
type mongo
@@ -33,12 +34,20 @@
# interval
flush_interval 10s
</match>
+{%- endif %}
-<match mongo.*.*>
- host 10.10.10.180
- port 9200
+{%- endfor %}
- type elasticsearch
- logstash_format true
- flush_interval 10s # for testing
-</match>
\ No newline at end of file
+<source>
+ type syslog
+ port 42185
+ tag syslog
+</source>
+
+<source>
+ type tail
+ format apache2
+ path /var/log/httpd/kibana_kibana.access.log
+ pos_file /var/log/td-agent/kibana_kibana.access_log.pos
+ tag mongo.apache.access
+</source>
\ No newline at end of file
diff --git a/map.jinja b/map.jinja
index 703c55c..e29b050 100755
--- a/map.jinja
+++ b/map.jinja
@@ -3,11 +3,11 @@
'Debian': {
'pkgs': ['td-agent'],
'service': 'td-agent',
- 'config': '/etc/td-agent/td-agent.conf',
+ 'config_path': '/etc/td-agent/td-agent.conf',
},
'RedHat': {
'pkgs': ['td-agent'],
'service': 'td-agent',
- 'config': '/etc/td-agent/td-agent.conf',
+ 'config_path': '/etc/td-agent/td-agent.conf',
},
}, merge=salt['pillar.get']('fluentd:server')) %}
\ No newline at end of file
diff --git a/server.sls b/server.sls
index 519c615..1f00e57 100755
--- a/server.sls
+++ b/server.sls
@@ -28,7 +28,7 @@
- pkg: fluentd_packages
{% endfor %}
-{{ server.config }}:
+{{ server.config_path }}:
file.managed:
- source: salt://fluentd/conf/td-agent.conf
- template: jinja
@@ -40,7 +40,7 @@
- name: {{ server.service }}
- enable: True
- watch:
- - file: {{ server.config }}
+ - file: {{ server.config_path }}
{#
fluentd_repo: