Add periodic job to run goaccess reporting

This adds a simple periodic job that runs against static.opendev.org and
produces opendev reports. To start we don't publish these reports
publicly so that we can double check their contents first. Assuming that
all goes well we'll be able to apply this to all of our
static.opendev.org hosted sites and publish these reports through the
zuul logging system.

Change-Id: I66705808d435c16bf0da6989296c896099964aaa
Story: 2007387
This commit is contained in:
Clark Boylan 2020-03-10 09:43:16 -07:00
parent b2b0cc1c83
commit 8fb306a22b
3 changed files with 88 additions and 1 deletions

View File

@ -1189,6 +1189,27 @@
nodes: []
run: playbooks/periodic/404.yaml
- job:
name: system-config-goaccess-report
description: |
Run goaccess tool on static.opendev.org hosted site.
abstract: true
protected: true
nodeset:
nodes: []
run: playbooks/periodic/goaccess.yaml
# TODO add publishing step once output is checked and clean.
- job:
name: zuul-ci-goaccess-report
parent: system-config-goaccess-report
description: |
Run goaccess tool on zuul-ci.org.
final: true
protected: true
vars:
goaccess_site: zuul-ci.org
- project:
templates:
- system-config-zuul-role-integration
@ -1359,3 +1380,4 @@
periodic:
jobs:
- system-config-static-404-checker
- zuul-ci-goaccess-report

View File

@ -0,0 +1,60 @@
- hosts: localhost
tasks:
- name: Add static.opendev.org to inventory
add_host:
name: static.opendev.org
ansible_connection: ssh
ansible_host: static.opendev.org
ansible_port: 22
ansible_user: zuul
- name: Add static.opendev.org host key
known_hosts:
name: static.opendev.org
key: static.opendev.org,23.253.245.150,2001:4800:7818:101:be76:4eff:fe04:7c28 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMu3PnnkNhPS2d5Z2uPju3Qqcbbc0lwHA1j9MgHlLnbK3bx1O2Kfez6RJUGl2i6nshdzkKwPBvN2vehQKiw1oSk=
- hosts: static.opendev.org
tasks:
- name: Configure goaccess
copy:
dest: /home/zuul/goaccess.conf
owner: zuul
group: zuul
mode: '0444'
content: |
log-format COMBINED
ignore-panel VISITORS
ignore-panel REQUESTS
ignore-panel REQUESTS_STATIC
ignore-panel NOT_FOUND
ignore-panel HOSTS
ignore-panel OS
ignore-panel BROWSERS
ignore-panel VISIT_TIMES
ignore-panel VIRTUAL_HOSTS
ignore-panel REFERRERS
ignore-panel REFERRING_SITES
ignore-panel KEYPHRASES
ignore-panel STATUS_CODES
ignore-panel REMOTE_USER
ignore-panel GEO_LOCATION
enable-panel VISITORS
enable-panel REQUESTS
enable-panel REQUESTS_STATIC
enable-panel NOT_FOUND
enable-panel STATUS_CODES
- name: Run goaccess
become: yes
shell: |
# We will publish to the zuul homedir for now as that allows us to
# double check the data produced is clean before making it
# public.
OUT_FILE="/home/zuul/{{ goaccess_site }}_goaccess_report.html"
SOURCE_FILE="/var/log/apache2/{{ goaccess_site }}_access.log"
# This pipes in all the compressed logs as well as the current
# uncompressed logs. Giving us a window as wide as our log retention.
zcat ${SOURCE_FILE}.*.gz | goaccess -o $OUT_FILE -p /home/zuul/goaccess.conf $SOURCE_FILE ${SOURCE_FILE}.1 -
args:
executable: /bin/bash

View File

@ -21,6 +21,11 @@
- apache2-utils
state: present
- name: Install goaccess
apt:
name: goaccess
state: present
- name: Rewrite module
apache2_module:
state: present
@ -95,4 +100,4 @@
- git.starlingx.io
- git.zuul-ci.org
loop_control:
loop_var: hostname
loop_var: hostname