Monitor remote logging (#162)

* Added remote logging for monitor

* Legacy line

* Tempaltes
This commit is contained in:
Przemyslaw Rzad 2019-07-26 10:51:39 +02:00 committed by GitHub
parent d3653bc31f
commit c94b68ab5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 70 additions and 1 deletions

@ -46,6 +46,7 @@ cp hosts.yml.example hosts.yml
hosts:
<host_ip_B>:
ansible_user: <user>
#syslog_server_port: "<protocol>://<ip>:<port>"
```
The config above would install the Oracle on `<host_ip_A>`, UI on `<host_ip_C>`, and both Oracle, UI and Monitor on `<host_ip_B>`.

@ -16,3 +16,4 @@ sokol-kovan:
hosts:
127.0.0.1:
ansible_user: ubuntu
#syslog_server_port: "<protocol>://<ip>:<port>"

@ -1,5 +1,4 @@
{
"disable-legacy-registry": true,
"live-restore": true,
"no-new-privileges": true
}

@ -0,0 +1,41 @@
---
- name: Slurp docker compose file
slurp:
src: "{{ bridge_path }}/monitor/docker-compose.yml"
register: docker_compose_slurp
- name: Parse docker compose file
set_fact:
docker_compose_parsed: "{{ docker_compose_slurp['content'] | b64decode | from_yaml }}"
- name: Set logger to remote server
set_fact:
docker_compose_parsed: "{{ docker_compose_parsed |combine({'services': {item: {'logging': {'driver': 'syslog','options': {'tag': '{{.Name}}/{{.ID}}'}}}}}, recursive=True) }}"
with_items: "{{ docker_compose_parsed.services }}"
- name: Write new docker-compose file
copy:
content: "{{ docker_compose_parsed | to_yaml }}"
dest: "{{ bridge_path }}/monitor/docker-compose.yml"
- name: Set the local container logs configuration file
template:
src: 33-monitor-docker.conf.j2
dest: /etc/rsyslog.d/33-monitor-docker.conf
owner: root
group: root
mode: 0644
- name: Set the log configuration file to send container logs to remote server
template:
src: 38-monitor-remote-logging.conf.j2
dest: /etc/rsyslog.d/38-monitor-remote-logging.conf
owner: root
group: root
mode: 0644
when: syslog_server_port is defined
- name: restart rsyslog
service:
name: rsyslog
state: restarted

@ -1,4 +1,5 @@
---
- include_tasks: pre_config.yml
- include_tasks: logging.yml
- include_tasks: jumpbox.yml
- include_tasks: servinstall.yml

@ -0,0 +1,11 @@
$FileCreateMode 0644
template(name="DockerLogFileName_Monitor" type="list") {
constant(value="/var/log/docker/")
property(name="syslogtag" securepath="replace" regex.type="ERE" regex.submatch="1" regex.expression="monitor_(.*)\\/[a-zA-Z0-9]+\\[")
constant(value="/docker.log")
}
if $programname startswith 'monitor_' then \
?DockerLogFileName_Monitor
$FileCreateMode 0600

@ -0,0 +1,15 @@
if $programname startswith 'monitor_' then {
action(
type="omfwd"
protocol="{{ syslog_server_port.split(":")[0] }}"
target="{{ (syslog_server_port.split(":")[1])[2:] }}"
port="{{ syslog_server_port.split(":")[2] }}"
template="RemoteForwardFormat"
queue.SpoolDirectory="/var/spool/rsyslog"
queue.FileName="remote"
queue.MaxDiskSpace="1g"
queue.SaveOnShutdown="on"
queue.Type="LinkedList"
ResendLastMSGOnReconnect="on"
)
}