From d3d4a933be797d1dc7ab156529878bc0c00f9e1c Mon Sep 17 00:00:00 2001 From: zhubingbing <1392607554@qq.com> Date: Fri, 2 Dec 2016 14:35:28 +0000 Subject: [PATCH] Add fluentd role * add fluentd role * remove heka configure Co-Authored-By: yangzb09 Partially-Implements: blueprint add-fluentd-role Change-Id: Ica804a99f5bb8b157f406299c5982b7b6283b3e3 --- ansible/group_vars/all.yml | 2 + ansible/roles/common/defaults/main.yml | 4 - ansible/roles/common/tasks/clean_heka.yml | 13 ++ ansible/roles/common/tasks/config.yml | 86 +++++----- ansible/roles/common/tasks/pull.yml | 4 +- ansible/roles/common/tasks/reconfigure.yml | 20 +-- ansible/roles/common/tasks/start.yml | 11 +- ansible/roles/common/tasks/upgrade.yml | 2 + .../conf/filter/00-record_transformer.conf.j2 | 8 + .../templates/conf/filter/01-rewrite.conf.j2 | 17 ++ .../conf/format/apache_access.conf.j2 | 20 +++ .../templates/conf/format/wsgi_access.conf.j2 | 12 ++ .../templates/conf/format/wsgi_python.conf.j2 | 12 ++ .../templates/conf/input/00-global.conf.j2 | 8 + .../templates/conf/input/01-syslog.conf.j2 | 7 + .../templates/conf/input/02-mariadb.conf.j2 | 10 ++ .../templates/conf/input/03-rabbitmq.conf.j2 | 10 ++ .../templates/conf/output/00-local.conf.j2 | 41 +++++ .../templates/conf/output/01-es.conf.j2 | 11 ++ .../roles/common/templates/fluentd.json.j2 | 84 ++++++++++ .../roles/common/templates/heka-aodh.toml.j2 | 13 -- .../common/templates/heka-barbican.toml.j2 | 13 -- .../common/templates/heka-ceilometer.toml.j2 | 13 -- .../templates/heka-elasticsearch.toml.j2 | 16 -- .../common/templates/heka-global.toml.j2 | 30 ---- .../common/templates/heka-gnocchi.toml.j2 | 13 -- .../common/templates/heka-grafana.toml.j2 | 18 --- .../common/templates/heka-haproxy.toml.j2 | 9 -- .../common/templates/heka-horizon.toml.j2 | 13 -- .../common/templates/heka-keepalived.toml.j2 | 9 -- .../common/templates/heka-keystone.toml.j2 | 13 -- .../common/templates/heka-mariadb.toml.j2 | 11 -- .../common/templates/heka-openstack.toml.j2 | 11 -- .../roles/common/templates/heka-panko.toml.j2 | 13 -- .../common/templates/heka-rabbitmq.toml.j2 | 18 --- .../roles/common/templates/heka-swift.toml.j2 | 9 -- ansible/roles/common/templates/heka.json.j2 | 153 ------------------ .../roles/common/templates/td-agent.conf.j2 | 4 + ansible/roles/haproxy/tasks/start.yml | 2 - .../roles/haproxy/templates/haproxy.cfg.j2 | 2 +- ansible/roles/swift/tasks/start.yml | 13 -- ansible/roles/swift/templates/account.conf.j2 | 3 +- .../roles/swift/templates/container.conf.j2 | 3 +- ansible/roles/swift/templates/object.conf.j2 | 3 +- .../swift/templates/proxy-server.conf.j2 | 3 +- .../add-fluentd-role-bc3f4976c807a50b.yaml | 5 + tools/setup_gate.sh | 2 +- 47 files changed, 334 insertions(+), 463 deletions(-) create mode 100644 ansible/roles/common/tasks/clean_heka.yml create mode 100644 ansible/roles/common/templates/conf/filter/00-record_transformer.conf.j2 create mode 100644 ansible/roles/common/templates/conf/filter/01-rewrite.conf.j2 create mode 100644 ansible/roles/common/templates/conf/format/apache_access.conf.j2 create mode 100644 ansible/roles/common/templates/conf/format/wsgi_access.conf.j2 create mode 100644 ansible/roles/common/templates/conf/format/wsgi_python.conf.j2 create mode 100644 ansible/roles/common/templates/conf/input/00-global.conf.j2 create mode 100644 ansible/roles/common/templates/conf/input/01-syslog.conf.j2 create mode 100644 ansible/roles/common/templates/conf/input/02-mariadb.conf.j2 create mode 100644 ansible/roles/common/templates/conf/input/03-rabbitmq.conf.j2 create mode 100644 ansible/roles/common/templates/conf/output/00-local.conf.j2 create mode 100644 ansible/roles/common/templates/conf/output/01-es.conf.j2 create mode 100644 ansible/roles/common/templates/fluentd.json.j2 delete mode 100644 ansible/roles/common/templates/heka-aodh.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-barbican.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-ceilometer.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-elasticsearch.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-global.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-gnocchi.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-grafana.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-haproxy.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-horizon.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-keepalived.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-keystone.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-mariadb.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-openstack.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-panko.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-rabbitmq.toml.j2 delete mode 100644 ansible/roles/common/templates/heka-swift.toml.j2 delete mode 100644 ansible/roles/common/templates/heka.json.j2 create mode 100644 ansible/roles/common/templates/td-agent.conf.j2 create mode 100644 releasenotes/notes/add-fluentd-role-bc3f4976c807a50b.yaml diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 54b6268661..f8729b0118 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -224,6 +224,8 @@ grafana_server_port: "3000" tacker_server_port: "9890" +fluentd_syslog_port: "5140" + public_protocol: "{{ 'https' if kolla_enable_tls_external | bool else 'http' }}" internal_protocol: "http" admin_protocol: "http" diff --git a/ansible/roles/common/defaults/main.yml b/ansible/roles/common/defaults/main.yml index 8e93160512..11db34b922 100644 --- a/ansible/roles/common/defaults/main.yml +++ b/ansible/roles/common/defaults/main.yml @@ -10,10 +10,6 @@ kolla_toolbox_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ d kolla_toolbox_tag: "{{ openstack_release }}" kolla_toolbox_image_full: "{{ kolla_toolbox_image }}:{{ kolla_toolbox_tag }}" -heka_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-heka" -heka_tag: "{{ openstack_release }}" -heka_image_full: "{{ heka_image }}:{{ heka_tag }}" - cron_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-cron" cron_tag: "{{ openstack_release }}" cron_image_full: "{{ cron_image }}:{{ cron_tag }}" diff --git a/ansible/roles/common/tasks/clean_heka.yml b/ansible/roles/common/tasks/clean_heka.yml new file mode 100644 index 0000000000..94191031ff --- /dev/null +++ b/ansible/roles/common/tasks/clean_heka.yml @@ -0,0 +1,13 @@ +--- +- name: Get container facts + kolla_container_facts: + name: + - heka + register: container_facts + +- name: Removing heka container + kolla_docker: + action: "remove_container" + name: "heka" + when: + - container_facts['heka'] is defined diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index 4fb093683d..dfaee19e75 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -5,7 +5,11 @@ state: "directory" recurse: yes with_items: - - "heka" + - "fluentd" + - "fluentd/input" + - "fluentd/output" + - "fluentd/format" + - "fluentd/filter" - "kolla-toolbox" - "cron" - "cron/logrotate" @@ -15,56 +19,50 @@ src: "{{ item }}.json.j2" dest: "{{ node_config_directory }}/{{ item }}/config.json" with_items: - - "heka" + - "fluentd" - "kolla-toolbox" - "cron" -- name: Copying over heka config files +- name: Copying over fluentd input config files template: - src: "heka-{{ item.src|default(item.name) }}.toml.j2" - dest: "{{ node_config_directory }}/heka/heka-{{ item.name }}.toml" - when: item.enabled | bool + src: "conf/input/{{ item }}.conf.j2" + dest: "{{ node_config_directory }}/fluentd/input/{{ item }}.conf" with_items: - - { name: "aodh", enabled: "{{ enable_aodh }}" } - - { name: "barbican", enabled: "{{ enable_barbican }}"} - - { name: "ceilometer", enabled: "{{ enable_ceilometer }}" } - - { name: "elasticsearch", enabled: "{{ enable_elasticsearch }}" } - - { name: "global", enabled: "yes" } - - { name: "gnocchi", enabled: "{{ enable_gnocchi }}" } - - { name: "grafana", enabled: "{{ enable_grafana }}" } - - { name: "haproxy", enabled: "{{ enable_haproxy }}" } - - { name: "horizon", enabled: "{{ enable_horizon }}" } - - { name: "keepalived", enabled: "{{ enable_haproxy }}" } - - { name: "keystone", enabled: "{{ enable_keystone }}" } - - { name: "mariadb", enabled: "{{ enable_mariadb }}" } - - { name: "openstack", enabled: "yes" } - - { name: "panko", enabled: "{{ enable_panko }}" } - - { name: "rabbitmq", enabled: "{{ enable_rabbitmq }}" } - - { name: "swift-account-auditor", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-account-reaper", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-account-replicator", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-account-server", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-container-auditor", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-container-replicator", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-container-server", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-container-updater", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-object-auditor", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-object-expirer", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-object-replicator", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-object-server", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-object-updater", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-proxy-server", src: "swift", enabled: "{{ enable_swift }}" } - - { name: "swift-rsyncd", src: "swift", enabled: "{{ enable_swift }}" } + - "00-global" + - "01-syslog" + - "02-mariadb" + - "03-rabbitmq" -- name: Heka custom config file exists - local_action: stat path="{{ node_custom_config }}/heka/heka-custom.toml" - register: heka_custom_stat_result - -- name: Copying over heka custom config file +- name: Copying over fluentd ouput config files template: - src: "{{ node_custom_config }}/heka/heka-custom.toml" - dest: "{{ node_config_directory }}/heka/heka-custom.toml" - when: heka_custom_stat_result.stat.exists == true + src: "conf/output/{{ item }}.conf.j2" + dest: "{{ node_config_directory }}/fluentd/output/{{ item }}.conf" + with_items: + - "00-local" + - "01-es" +- name: Copying over fluentd format config files + template: + src: "conf/format/{{ item }}.conf.j2" + dest: "{{ node_config_directory }}/fluentd/format/{{ item }}.conf" + with_items: + - "apache_access" + - "wsgi_access" + - "wsgi_python" + +- name: Copying over fluentd filter config files + template: + src: "conf/filter/{{ item }}.conf.j2" + dest: "{{ node_config_directory }}/fluentd/filter/{{ item }}.conf" + with_items: + - "00-record_transformer" + - "01-rewrite" + +- name: Copying over tg-agent.conf + template: + src: "td-agent.conf.j2" + dest: "{{ node_config_directory }}/{{ item }}/td-agent.conf" + with_items: + - "fluentd" - name: Copying over cron logrotate config files template: diff --git a/ansible/roles/common/tasks/pull.yml b/ansible/roles/common/tasks/pull.yml index e19971ce68..3cf41e2357 100644 --- a/ansible/roles/common/tasks/pull.yml +++ b/ansible/roles/common/tasks/pull.yml @@ -5,11 +5,11 @@ common_options: "{{ docker_common_options }}" image: "{{ kolla_toolbox_image_full }}" -- name: Pulling heka image +- name: Pulling fluentd image kolla_docker: action: "pull_image" common_options: "{{ docker_common_options }}" - image: "{{ heka_image_full }}" + image: "{{ fluentd_image_full }}" - name: Pulling cron image kolla_docker: diff --git a/ansible/roles/common/tasks/reconfigure.yml b/ansible/roles/common/tasks/reconfigure.yml index 961c656fa3..84e5c86c2b 100644 --- a/ansible/roles/common/tasks/reconfigure.yml +++ b/ansible/roles/common/tasks/reconfigure.yml @@ -1,28 +1,28 @@ --- -- name: Ensuring the heka container is up +- name: Ensuring the fluentd container is up kolla_docker: - name: "heka" + name: "fluentd" action: "get_container_state" register: container_state failed_when: container_state.Running == false - include: config.yml -- name: Checking the heka config - command: docker exec heka /usr/local/bin/kolla_set_configs --check +- name: Checking the fluentd config + command: docker exec fluentd /usr/local/bin/kolla_set_configs --check changed_when: false failed_when: false register: check_result -- name: Getting the heka container config strategy +- name: Getting the fluentd container config strategy kolla_docker: - name: "heka" + name: "fluentd" action: "get_container_env" register: container_env -- name: Removing the heka container +- name: Removing the fluentd container kolla_docker: - name: "heka" + name: "fluentd" action: "remove_container" register: remove_container when: @@ -32,9 +32,9 @@ - include: start.yml when: remove_container.changed -- name: Restarting the heka container +- name: Restarting the fluentd container kolla_docker: - name: "heka" + name: "fluentd" action: "restart_container" when: - config_strategy == "COPY_ALWAYS" diff --git a/ansible/roles/common/tasks/start.yml b/ansible/roles/common/tasks/start.yml index 963cd5de1c..cfba855032 100644 --- a/ansible/roles/common/tasks/start.yml +++ b/ansible/roles/common/tasks/start.yml @@ -1,19 +1,17 @@ --- -- name: Starting heka container +- name: Starting fluentd container kolla_docker: action: "start_container" common_options: "{{ docker_common_options }}" environment: KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" SKIP_LOG_SETUP: "true" - image: "{{ heka_image_full }}" - name: "heka" + image: "{{ fluentd_image_full }}" + name: "fluentd" volumes: - - "{{ node_config_directory }}/heka/:{{ container_config_directory }}/:ro" + - "{{ node_config_directory }}/fluentd/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - - "heka:/var/cache/hekad" - - "heka_socket:/var/lib/kolla/heka/" - name: Starting kolla-toolbox container kolla_docker: @@ -45,5 +43,4 @@ volumes: - "{{ node_config_directory }}/cron/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" - - "heka_socket:/var/lib/kolla/heka/" - "kolla_logs:/var/log/kolla/" diff --git a/ansible/roles/common/tasks/upgrade.yml b/ansible/roles/common/tasks/upgrade.yml index 1f16915ad9..b31527f661 100644 --- a/ansible/roles/common/tasks/upgrade.yml +++ b/ansible/roles/common/tasks/upgrade.yml @@ -1,4 +1,6 @@ --- - include: config.yml +- include: clean_heka.yml + - include: start.yml diff --git a/ansible/roles/common/templates/conf/filter/00-record_transformer.conf.j2 b/ansible/roles/common/templates/conf/filter/00-record_transformer.conf.j2 new file mode 100644 index 0000000000..1dbfaf5ecb --- /dev/null +++ b/ansible/roles/common/templates/conf/filter/00-record_transformer.conf.j2 @@ -0,0 +1,8 @@ + + @type record_transformer + + Hostname ${hostname} + Logger openstack.${tag_parts[4]} + programname ${tag_parts[5]} + + diff --git a/ansible/roles/common/templates/conf/filter/01-rewrite.conf.j2 b/ansible/roles/common/templates/conf/filter/01-rewrite.conf.j2 new file mode 100644 index 0000000000..3e9f0053af --- /dev/null +++ b/ansible/roles/common/templates/conf/filter/01-rewrite.conf.j2 @@ -0,0 +1,17 @@ + + @type rewrite_tag_filter + capitalize_regex_backreference yes + rewriterule1 programname ^(horizon-access|ceilometer-api-access|keystone-apache-admin-access|keystone-apache-public-access)$ apache_access + rewriterule2 programname ^aodh_wsgi_access$ wsgi_access + rewriterule3 programname ^(nova-api|nova-compute|nova-conductor|nova-consoleauth|nova-manage|nova-novncproxy|nova-scheduler|privsep-helper).* openstack_python + rewriterule4 programname ^(sahara-api|sahara-engine).* openstack_python + rewriterule5 programname ^(neutron-server|neutron-openvswitch-agent|neutron-ns-metadata-proxy|neutron-metadata-agent|neutron-l3-agent|neutron-dhcp-agent).* openstack_python + rewriterule6 programname ^(magnum-conductor|magnum-api).* openstack_python + rewriterule7 programname ^(keystone).* openstack_python + rewriterule8 programname ^(heat-engine|heat-api|heat-api-cfn).* openstack_python + rewriterule9 programname ^(registry|api).* openstack_python + rewriterule10 programname ^(cloudkitty-storage-init|cloudkitty-processor|cloudkitty-dbsync|cloudkitty-api).* openstack_python + rewriterule11 programname ^(ceilometer-polling|ceilometer-collector|ceilometer-agent-notification|loadwsgi).* openstack_python + rewriterule12 programname ^(barbican-worker|barbican-keystone-listener|barbican-db-manage|barbican-api|app).* openstack_python + rewriterule13 programname ^(aodh-notifier|aodh-listener|aodh-evaluator|aodh-dbsync).* openstack_python + diff --git a/ansible/roles/common/templates/conf/format/apache_access.conf.j2 b/ansible/roles/common/templates/conf/format/apache_access.conf.j2 new file mode 100644 index 0000000000..631b0180c2 --- /dev/null +++ b/ansible/roles/common/templates/conf/format/apache_access.conf.j2 @@ -0,0 +1,20 @@ + + @type parser + reserve_data true + key_name message + + @type "grok" + grok_pattern \[%{HTTPDATE:Timestamp}\] "(?:%{WORD:http_method} %{NOTSPACE:http_url}(?: HTTP/%{NUMBER:http_version})?|%{DATA:rawrequest})" %{NUMBER:http_status} (?:\d+|-) + time_key Timestamp + time_format %d/%b/%Y:%H:%M:%S %z + keep_time_key true + + + + + @type record_transformer + + severity_label INFO + Severity 6 + + diff --git a/ansible/roles/common/templates/conf/format/wsgi_access.conf.j2 b/ansible/roles/common/templates/conf/format/wsgi_access.conf.j2 new file mode 100644 index 0000000000..52ac0fab10 --- /dev/null +++ b/ansible/roles/common/templates/conf/format/wsgi_access.conf.j2 @@ -0,0 +1,12 @@ + + @type parser + reserve_data true + key_name message + + @type "grok" + grok_pattern %{IPORHOST:clientip} %{HTTPDUSER:ident} %{USER:auth} \[%{HTTPDATE:Timestamp}\] "(?:%{WORD:http_method} %{NOTSPACE:http_url}(?: HTTP/%{NUMBER:http_version})?|%{DATA:rawrequest})" %{NUMBER:http_status} (?:%{NUMBER:http_bytes}|-) (?:%{NUMBER:http_response_time_us}|-) %{QS:referrer} %{QS:agent} + time_key Timestamp + time_format %d/%b/%Y:%H:%M:%S %z + keep_time_key true + + diff --git a/ansible/roles/common/templates/conf/format/wsgi_python.conf.j2 b/ansible/roles/common/templates/conf/format/wsgi_python.conf.j2 new file mode 100644 index 0000000000..4f215f22ec --- /dev/null +++ b/ansible/roles/common/templates/conf/format/wsgi_python.conf.j2 @@ -0,0 +1,12 @@ + + @type parser + reserve_data true + key_name message + + @type "grok" + grok_pattern %{TIMESTAMP_ISO8601:Timestamp} %{NUMBER:Pid} %{LOGLEVEL:severity_label} %{NOTSPACE:python_module} \[req-(?:%{NOTSPACE:request_id}) (?:%{NOTSPACE:user_id}) (?:%{NOTSPACE:tenant_id}) .*\] %{GREEDYDATA:Payload} + time_format "%Y-%m-%d %H:%M:%S.%L" + time_key Timestamp + keep_time_key true + + diff --git a/ansible/roles/common/templates/conf/input/00-global.conf.j2 b/ansible/roles/common/templates/conf/input/00-global.conf.j2 new file mode 100644 index 0000000000..6bc0d5eb4f --- /dev/null +++ b/ansible/roles/common/templates/conf/input/00-global.conf.j2 @@ -0,0 +1,8 @@ + + @type tail + path /var/log/kolla/*/*.log + exclude_path ["/var/log/kolla/rabbitmq/*.log", "/var/log/kolla/mariadb/mariadb.log", "/var/log/kolla/haproxy/*.log", "/var/log/kolla/swift/*.log"] + pos_file /var/run/td-agent/kolla.pos + tag kolla.* + format /^(?.*)$/ + diff --git a/ansible/roles/common/templates/conf/input/01-syslog.conf.j2 b/ansible/roles/common/templates/conf/input/01-syslog.conf.j2 new file mode 100644 index 0000000000..d82208b591 --- /dev/null +++ b/ansible/roles/common/templates/conf/input/01-syslog.conf.j2 @@ -0,0 +1,7 @@ + + @type syslog + port {{ fluentd_syslog_port }} + bind {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} + tag syslog + format /^(?.*)$/ + diff --git a/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2 b/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2 new file mode 100644 index 0000000000..d2ef3b1cc6 --- /dev/null +++ b/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2 @@ -0,0 +1,10 @@ + + @type tail + path /var/log/kolla/mariadb/mariadb.log + pos_file /var/run/td-agent/mariadb.pos + tag mariadb.* + format multiline + format_firstline /^\d{6}/ + format1 /^(?