Commit 2ab1b9c6 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Permite comunicación directa con Loki

Para prescindir del servicio fluentd, ahora fluent-bit es capaz de
enviar logs directamente a loki.

Aplica los cambios necesarios para que sea posible el reemplazo, como
reescribir campos de los eventos de log recibidos para hacerlos más
granulares.

Acota la entrada de log mediante el uso de tag, con valor configurable.
Por defecto, espera tags con el prefijo "docker.".

Omite algunos contenidos no deseados y variables cuyo valor por defecto
era el deseado.

Parametriza nivel de log y prefijo de tag (fluent) de entrada mediante
variables de entorno asignadas en config.

Reduce timeout de actualización de tareas del servicio.

Renombra nombre interno de config y variable de configuración de nombre.
parent 1ebbd887
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -6,10 +6,6 @@ include:
stages:
  - deploy

variables:
  PROJECT_PARENT_NAME: log

.deploy:
  variables:
    STACK: ${PROJECT_PARENT_NAME}
    SERVICES_TO_CHECK: ${PROJECT_PARENT_NAME}_${CI_PROJECT_NAME}
    STACK: log
+1 −1
Original line number Diff line number Diff line
# Fluent Bit

Configure and deploy Fluent Bit, a lightweight service to feed Fluentd
Configure and deploy Fluent Bit, a lightweight service to ingest logs and feed Loki
+3 −0
Original line number Diff line number Diff line
LOG_LEVEL=info
INPUT_TAG_PREFIX=docker.

PORT=24224
+20 −7
Original line number Diff line number Diff line
[SERVICE]
	Flush 5
	Daemon off
	Log_Level info
	flush 1
	log_level ${LOG_LEVEL}

[INPUT]
	Name forward
	name forward

[FILTER]
	name rewrite_tag
	match ${INPUT_TAG_PREFIX}*
	rule $container_name ^\/([^_]+)_([^.]+)\.(\d+)\.(.*)$ loki.$1.$2.$3.$4 false

[FILTER]
	name record_modifier
	match loki.*
	remove_key source
	remove_key container_name

[OUTPUT]
	Name forward
	Match *
	Host fluentd
	name loki
	match loki.*
	host loki
	labels stack_name=$TAG[1], service_name=$TAG[1]_$TAG[2], slot=$TAG[3], container_name=$TAG[1]_$TAG[2].$TAG[3].$TAG[4]
	label_keys $container_id
	drop_single_key true
+7 −4
Original line number Diff line number Diff line
@@ -3,6 +3,9 @@ version: '3.5'
services:
  fluent-bit:
    image: ${IMAGE_NAME:-fluent/fluent-bit}:${IMAGE_TAG:-latest}
    environment:
      LOG_LEVEL:
      INPUT_TAG_PREFIX:
    networks:
      log-net:
    ports:
@@ -10,7 +13,7 @@ services:
        published: ${PORT}
        mode: host
    configs:
      - source: fluent-bit-conf
      - source: fluent-bit
        target: /fluent-bit/etc/fluent-bit.conf
    logging:
      driver: json-file
@@ -19,7 +22,7 @@ services:
      restart_policy:
        delay: ${RESTART_DELAY:-1s}
      update_config:
        delay: ${UPDATE_DELAY:-10s}
        delay: ${UPDATE_DELAY:-1s}
      resources:
        limits:
          cpus: '${RESOURCES_LIMITS_CPUS:-0.1}'
@@ -35,6 +38,6 @@ networks:
    attachable: ${LOG_NET_ATTACHABLE:-true}

configs:
  fluent-bit-conf:
    name: ${FLUENT_BIT_CONF_NAME:-fluent-bit-conf}
  fluent-bit:
    name: ${FLUENT_BIT_CONFIG_NAME:-fluent-bit-conf}
    file: ./conf/fluent-bit.conf