Ver código fonte

devenv: trying to make fluentd with inoffical fluent-plugin-loki work

Marcus Efraimsson 6 anos atrás
pai
commit
0f40b2d206

+ 26 - 0
devenv/docker/ha_test/docker-compose.yaml

@@ -7,6 +7,10 @@ services:
       - "80:80"
     volumes:
       - /var/run/docker.sock:/tmp/docker.sock:ro
+    logging:
+      driver: "fluentd"
+      options:
+        tag: nginx
 
   db:
     image: mysql:5.6
@@ -73,6 +77,10 @@ services:
     depends_on:
       db:
         condition: service_healthy
+    logging:
+      driver: "fluentd"
+      options:
+        tag: grafana
 
   prometheus:
     image: prom/prometheus:v2.4.2
@@ -82,3 +90,21 @@ services:
       - VIRTUAL_HOST=prometheus.loc
     ports:
       - 9090
+
+  loki:
+    image: grafana/loki:master
+    environment:
+      - VIRTUAL_HOST=loki.loc
+    ports:
+      - 3100
+    command: -config.file=/etc/loki/local-config.yaml
+
+  fluentd:
+    build: ./fluentd
+    volumes:
+      - ./fluentd/fluent.conf:/fluentd/etc/fluent.conf
+    links:
+      - loki
+    ports:
+      - "24224:24224"
+      - "24224:24224/udp"

+ 30 - 0
devenv/docker/ha_test/fluentd/Dockerfile

@@ -0,0 +1,30 @@
+FROM fluent/fluentd:v1.3.3-debian-1.0
+
+# USER root
+
+# RUN apk add --no-cache --update --virtual .build-deps \
+#         sudo build-base ruby-dev \
+#  && sudo gem install bundler \
+#  && gem 'loki', git: 'https://github.com/grafana/loki.git', glob: 'fluentd/fluent-plugin-loki/*.gemspec' \
+#  && sudo gem sources --clear-all \
+#  && apk del .build-deps \
+#  && rm -rf /home/fluent/.gem/ruby/2.5.0/cache/*.gem
+
+# USER fluent
+
+USER root
+
+COPY Gemfile .
+RUN ["gem", "install", "fluent-plugin-loki"]
+
+# RUN apt-get -y update \
+#  && apt-get -y install git \
+#  && apt-get clean \
+#  && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man/?? /usr/share/man/??_*
+
+# RUN gem install bundler \
+#  && bundler install
+
+# COPY fluent.conf /fluentd/etc
+
+USER fluent

+ 1 - 0
devenv/docker/ha_test/fluentd/Gemfile

@@ -0,0 +1 @@
+source 'https://rubygems.org'

+ 19 - 0
devenv/docker/ha_test/fluentd/fluent.conf

@@ -0,0 +1,19 @@
+<source>
+  @type forward
+  port 24224
+  bind 0.0.0.0
+</source>
+
+<match **>
+  @type stdout
+  format json
+</match>
+
+<match **>
+  @type loki
+  endpoint_url "http://loki:3100"
+  labels {"env":"dev"}
+  flush_interval 10s
+  flush_at_shutdown true
+  buffer_chunk_limit 1m
+</match>

+ 6 - 1
devenv/docker/ha_test/grafana/provisioning/datasources/datasources.yaml

@@ -8,4 +8,9 @@ datasources:
     jsonData:
       timeInterval: 10s
       queryTimeout: 30s
-      httpMethod: POST
+      httpMethod: POST
+
+  - name: Loki
+    type: loki
+    access: proxy
+    url: http://loki:3100