added loki, prometheus, promtail, statist

This commit is contained in:
2021-03-14 20:57:44 +01:00
parent 89b7fd0747
commit 1d8d30a8ab
18 changed files with 509 additions and 0 deletions

7
promtail/Dockerfile Normal file
View File

@@ -0,0 +1,7 @@
FROM centos:7
RUN yum update -y && yum install -y unzip && yum clean all
RUN curl -O -L "https://github.com/grafana/loki/releases/download/v2.1.0/promtail-linux-amd64.zip" && unzip promtail-linux-amd64.zip -d /promtail && rm promtail-linux-amd64.zip && cd /promtail && chmod a+x "promtail-linux-amd64"
COPY config.yaml /promtail
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

18
promtail/config.yaml Normal file
View File

@@ -0,0 +1,18 @@
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://localhost:3100/loki/api/v1/push
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*log

View File

@@ -0,0 +1,26 @@
#!/bin/bash
if [[ (! -z "${PROMTAIL_DAEMON_USER}" ) && ( "${PROMTAIL_DAEMON_USER}" != "root" ) ]]; then
useradd -r -s /bin/false $PROMTAIL_DAEMON_USER
if [[ ! -z "${PROMTAIL_DAEMON_USER_UID}" ]]; then
usermod -u $PROMTAIL_DAEMON_USER_UID $PROMTAIL_DAEMON_USER
fi
if [[ ! -z "${PROMTAIL_DAEMON_USER_GID}" ]]; then
groupmod -g $PROMTAIL_DAEMON_USER_GID $PROMTAIL_DAEMON_USER
fi
fi
echo "Chowning Data"
if [[ ! -z "${PROMTAIL_DAEMON_USER}" ]]; then
chown -R $(id -u ${PROMTAIL_DAEMON_USER}):$(id -g ${PROMTAIL_DAEMON_USER}) /promtail
else
chown -R $(id -u):$(id -g) /promtail
fi
if [[ ! -z "${PROMTAIL_DAEMON_USER}" ]]; then
runuser -u ${PROMTAIL_DAEMON_USER} -- /promtail/promtail-linux-amd64 -config.file=/promtail/config.yaml
else
/promtail/promtail-linux-amd64 -config.file=/promtail/config.yaml
fi