From 7c19402403482aa9f5f6410d2be54fe359406cee Mon Sep 17 00:00:00 2001 From: Doug Szumski Date: Thu, 28 Feb 2019 17:12:33 +0000 Subject: [PATCH] Add Google mtail for generating metrics from logs This adds support for building an mtail image for generating metrics from logs. These metrics can then be used to trigger alerts. For example, one may want to track user logins, kernel errors, filesystem corruption etc. Change-Id: I0b3eee33c608b08f1e915a08096a1194d359805a Partially-Implements: blueprint mtail --- .../prometheus/prometheus-mtail/Dockerfile.j2 | 30 +++++++++++++++++++ .../notes/add-mtail-b806e87da3ae950d.yaml | 5 ++++ 2 files changed, 35 insertions(+) create mode 100644 docker/prometheus/prometheus-mtail/Dockerfile.j2 create mode 100644 releasenotes/notes/add-mtail-b806e87da3ae950d.yaml diff --git a/docker/prometheus/prometheus-mtail/Dockerfile.j2 b/docker/prometheus/prometheus-mtail/Dockerfile.j2 new file mode 100644 index 0000000000..28008f16d3 --- /dev/null +++ b/docker/prometheus/prometheus-mtail/Dockerfile.j2 @@ -0,0 +1,30 @@ +FROM {{ namespace }}/{{ image_prefix }}prometheus-base:{{ tag }} +LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}" + +{% block prometheus_mtail_header %}{% endblock %} + +{% if base_arch not in ['x86_64'] %} + +RUN echo 'There are no mtail binaries for {{ base_arch }}' \ + && /bin/false + +{% endif %} + +{% block prometheus_mtail_version %} +ARG prometheus_mtail_version=v3.0.0-rc24 +ARG prometheus_mtail_url=https://github.com/google/mtail/releases/download/${prometheus_mtail_version}/mtail_${prometheus_mtail_version}_linux_amd64 +{% endblock %} + +{% block prometheus_mtail_install %} +RUN curl -sSL -o /opt/mtail ${prometheus_mtail_url} \ + && chmod +x /opt/mtail +{% endblock %} + +{% block prometheus_mtail_footer %}{% endblock %} +{% block footer %}{% endblock %} + +# NOTE(dszumski): We run as root so that mtail can scrape root owned logs +# such as /var/log/secure which are mounted into the container as read only +# for auditing purposes. Longer term we should use a more secure mechanism +# for tailing these logs. +USER root diff --git a/releasenotes/notes/add-mtail-b806e87da3ae950d.yaml b/releasenotes/notes/add-mtail-b806e87da3ae950d.yaml new file mode 100644 index 0000000000..cef37f96cc --- /dev/null +++ b/releasenotes/notes/add-mtail-b806e87da3ae950d.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add mtail, a utility for turning logs into metrics for use with + Prometheus.