Make Heka collect Neutron logs

Partially implements: blueprint heka
Change-Id: I70e94f4ef7380c6f376a3066d7ddda042c703637
This commit is contained in:
Éric Lemoine 2016-02-11 18:49:40 +01:00 committed by SamYaple
parent 684873b89b
commit a2b130d6ba
9 changed files with 44 additions and 32 deletions

View File

@ -6,5 +6,5 @@ filename = "lua_decoders/os_openstack_log.lua"
type = "LogstreamerInput"
decoder = "openstack_log_decoder"
log_directory = "/var/log/kolla"
file_match = '(?P<Service>nova|glance|keystone)/(?P<Program>.*)\.log'
file_match = '(?P<Service>nova|glance|keystone|neutron)/(?P<Program>.*)\.log'
differentiator = ["Service", "_", "Program"]

View File

@ -16,24 +16,6 @@ $template HeatAPICfnFile,"/var/log/heat/heat-api-cfn.log"
$template HeatEngineFile,"/var/log/heat/heat-engine.log"
:syslogtag,contains,"heat-engine" ?HeatEngineFile
$template NeutronServerFile,"/var/log/neutron/neutron-server.log"
:syslogtag,contains,"neutron-server" ?NeutronServerFile
$template NeutronOVSAgentFile,"/var/log/neutron/neutron-openvswitch-agent.log"
:syslogtag,contains,"neutron-openvswitch-agent" ?NeutronOVSAgentFile
$template NeutronLinuxbrAgentFile,"/var/log/neutron/neutron-linuxbridge-agent.log"
:syslogtag,contains,"neutron-linuxbridge-agent" ?NeutronLinuxbrAgentFile
$template NeutronDHCPAgentFile,"/var/log/neutron/neutron-dhcp-agent.log"
:syslogtag,contains,"neutron-dhcp-agent" ?NeutronDHCPAgentFile
$template NeutronMetadataAgentFile,"/var/log/neutron/neutron-metadata-agent.log"
:syslogtag,contains,"neutron-metadata-agent" ?NeutronMetadataAgentFile
$template NeutronL3AgentFile,"/var/log/neutron/neutron-l3-agent.log"
:syslogtag,contains,"neutron-l3-agent" ?NeutronL3AgentFile
$template CinderApiFile,"/var/log/cinder/cinder-api.log"
:syslogtag,contains,"cinder-api" ?CinderApiFile

View File

@ -48,7 +48,9 @@
BOOTSTRAP:
name: "bootstrap_neutron"
restart_policy: "never"
volumes: "{{ node_config_directory }}/neutron-server/:{{ container_config_directory }}/:ro"
volumes:
- "{{ node_config_directory }}/neutron-server/:{{ container_config_directory }}/:ro"
- "kolla_logs:/var/log/kolla/"
run_once: True
delegate_to: "{{ groups['neutron-server'][0] }}"
when: database_created

View File

@ -67,7 +67,7 @@
name: "neutron_server"
volumes:
- "{{ node_config_directory }}/neutron-server/:{{ container_config_directory }}/:ro"
- "rsyslog_socket:/var/lib/kolla/rsyslog/"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['neutron-server']
- name: Starting neutron-openvswitch-agent container
@ -81,7 +81,7 @@
- "{{ node_config_directory }}/neutron-openvswitch-agent/:{{ container_config_directory }}/:ro"
- "/lib/modules:/lib/modules:ro"
- "/run:/run"
- "rsyslog_socket:/var/lib/kolla/rsyslog/"
- "kolla_logs:/var/log/kolla/"
when:
- (
( inventory_hostname in groups['compute']
@ -109,7 +109,7 @@
- "{{ node_config_directory }}/neutron-openvswitch-agent-fake-{{ item }}/:{{ container_config_directory }}/:ro"
- "/lib/modules:/lib/modules:ro"
- "/run:/run"
- "rsyslog_socket:/var/lib/kolla/rsyslog/"
- "kolla_logs:/var/log/kolla/"
with_sequence: start=1 end={{ num_nova_fake_per_node }}
when:
- inventory_hostname in groups['compute']
@ -131,7 +131,7 @@
- "{{ node_config_directory }}/neutron-linuxbridge-agent/:{{ container_config_directory }}/:ro"
- "/lib/modules:/lib/modules:ro"
- "/run:/run"
- "rsyslog_socket:/var/lib/kolla/rsyslog/"
- "kolla_logs:/var/log/kolla/"
when:
- (inventory_hostname in groups['compute']
or inventory_hostname in groups['neutron-dhcp-agent']
@ -151,7 +151,7 @@
- "/run/:/run/"
- "/run/netns/:/run/netns/:shared"
- "neutron_metadata_socket:/var/lib/neutron/kolla/"
- "rsyslog_socket:/var/lib/kolla/rsyslog/"
- "kolla_logs:/var/log/kolla/"
when:
- inventory_hostname in groups['neutron-dhcp-agent']
@ -167,7 +167,7 @@
- "/run:/run"
- "/run/netns/:/run/netns/:shared"
- "neutron_metadata_socket:/var/lib/neutron/kolla/"
- "rsyslog_socket:/var/lib/kolla/rsyslog/"
- "kolla_logs:/var/log/kolla/"
when:
- inventory_hostname in groups['neutron-l3-agent']
@ -182,6 +182,6 @@
- "{{ node_config_directory }}/neutron-metadata-agent/:{{ container_config_directory }}/:ro"
- "/run/netns/:/run/netns/:shared"
- "neutron_metadata_socket:/var/lib/neutron/kolla/"
- "rsyslog_socket:/var/lib/kolla/rsyslog/"
- "kolla_logs:/var/log/kolla/"
when:
- inventory_hostname in groups['neutron-metadata-agent']

View File

@ -2,8 +2,11 @@
[DEFAULT]
debug = {{ neutron_logging_debug }}
use_syslog = True
syslog_log_facility = LOG_LOCAL0
log_dir = /var/log/kolla/neutron
# NOTE(elemoine): set use_stderr to False or the logs will also be sent to
# stderr and collected by Docker
use_stderr = False
bind_host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}
bind_port = {{ neutron_server_port }}

View File

@ -48,17 +48,20 @@ ADD neutron-base-archive /neutron-base-source
RUN ln -s neutron-base-source/* neutron \
&& useradd --user-group neutron \
&& /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt /neutron \
&& mkdir -p /etc/neutron /usr/share/neutron /var/lib/neutron /var/log/neutron /home/neutron \
&& mkdir -p /etc/neutron /usr/share/neutron /var/lib/neutron /home/neutron \
&& cp -r /neutron/etc/* /etc/neutron/ \
&& cp -r /neutron/etc/neutron/* /etc/neutron/ \
&& cp /neutron/etc/api-paste.ini /usr/share/neutron \
&& mv /etc/neutron/neutron/ /etc/neutron/plugins/ \
&& chown -R neutron: /etc/neutron /usr/share/neutron /var/lib/neutron /var/log/neutron /home/neutron \
&& chown -R neutron: /etc/neutron /usr/share/neutron /var/lib/neutron /home/neutron \
&& sed -i 's|^exec_dirs.*|exec_dirs=/var/lib/kolla/venv/bin,/sbin,/usr/sbin,/bin,/usr/bin,/usr/local/bin,/usr/local/sbin|g' /etc/neutron/rootwrap.conf
{% endif %}
COPY neutron_sudoers /etc/sudoers.d/neutron_sudoers
COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN usermod -a -G kolla neutron \
&& chmod 750 /etc/sudoers.d \
&& chmod 440 /etc/sudoers.d/neutron_sudoers
&& chmod 440 /etc/sudoers.d/neutron_sudoers \
&& chmod 755 /usr/local/bin/kolla_extend_start

View File

@ -0,0 +1,8 @@
#!/bin/bash
if [[ ! -d "/var/log/kolla/neutron" ]]; then
mkdir -p /var/log/kolla/neutron
fi
if [[ $(stat -c %a /var/log/kolla/neutron) != "755" ]]; then
chmod 755 /var/log/kolla/neutron
fi

View File

@ -4,3 +4,10 @@
if [[ $(stat -c %U:%G /var/lib/neutron/kolla) != "neutron:neutron" ]]; then
sudo chown neutron: /var/lib/neutron/kolla
fi
if [[ ! -d "/var/log/kolla/neutron" ]]; then
mkdir -p /var/log/kolla/neutron
fi
if [[ $(stat -c %a /var/log/kolla/neutron) != "755" ]]; then
chmod 755 /var/log/kolla/neutron
fi

View File

@ -1,5 +1,12 @@
#!/bin/bash
if [[ ! -d "/var/log/kolla/neutron" ]]; then
mkdir -p /var/log/kolla/neutron
fi
if [[ $(stat -c %a /var/log/kolla/neutron) != "755" ]]; then
chmod 755 /var/log/kolla/neutron
fi
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then