diff --git a/docker-compose.yml b/docker-compose.yml index 83b6c2f3d9deb2ea084f17433ad5796e9328aeaa..57bef73a49f94e2ab4711a71ffba3c5a055ce5b9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,14 +16,6 @@ services: - ./storage:/var/www/storage - ./.env:/var/www/.env restart: unless-stopped - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=${WEBZERO_VERSION},public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # Nginx server # Rinning on port 8002 @@ -38,14 +30,6 @@ services: - app:/var/www - ./nginx/conf.d/:/etc/nginx/conf.d/ restart: unless-stopped - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=latest,public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # One API # Running on port 8081 @@ -61,14 +45,6 @@ services: - ./logs/oneapi:/logs command: bash -c '/usr/local/bin/rust-one-subcom-link' restart: unless-stopped - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=${ONEAPI_VERSION},public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # Vmagent to push metrics to Victoria Metrics # Running on port 8429 @@ -82,14 +58,6 @@ services: - "--remoteWrite.url=${METRICS_STORAGE_URLS}" - "--remoteWrite.bearerToken=${METRICS_AUTH_TOKEN}" restart: unless-stopped - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=latest,public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # Reports reports_accumulator: @@ -104,14 +72,6 @@ services: volumes: - ./logs/reports-acumulator:/logs restart: unless-stopped - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=${REPORTS_ACCUMULATOR_VERSION},public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # Running on port 3000 reports_cruncher: @@ -124,14 +84,6 @@ services: extra_hosts: - "host.docker.internal:host-gateway" restart: unless-stopped - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=${REPORTS_CRUNCHER_VERSION},public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # Running on port 3030 reports_engine: @@ -146,14 +98,6 @@ services: volumes: - ./reports:/reports restart: unless-stopped - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=${REPORTS_ENGINE_VERSION},public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # VictoriaMetrics # Running on port 8428 @@ -170,14 +114,6 @@ services: - "--httpListenAddr=:8428" - "--influxListenAddr=:8089" restart: always - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=v1.90.0,public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # Running on port 3000 grafana: @@ -192,14 +128,6 @@ services: - ./dashboards:/var/lib/grafana/dashboards/ - ./provisioning:/etc/grafana/provisioning/ restart: always - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=8.2.2,public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # Running on port 8427 vmauth: @@ -213,14 +141,6 @@ services: command: - "-auth.config=/etc/auth.yaml" restart: unless-stopped - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=latest,public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # Vmalert # Running on port 8880 @@ -246,14 +166,6 @@ services: - '--external.alert.source=explore?orgId=1&left=["now-1h","now","VictoriaMetrics",{"expr":"{{$$expr|quotesEscape|crlfEscape|queryEscape}}"},{"mode":"Metrics"},{"ui":[t rue,true,true,"none"]}]' ## when copypaste the line be aware of '$$' for escaping in '$expr' networks: restart: always - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=v1.90.0,public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # Alertmanager # Running on port 9093 @@ -270,14 +182,6 @@ services: command: - '--config.file=/config/alertmanager.yml' restart: always - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=v0.27.0,public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # ADM Required scep: @@ -297,14 +201,6 @@ services: volumes: - ./adm_scep_depot:/depot restart: always - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=${TAG},public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # ADM Required nanomdm: @@ -328,14 +224,6 @@ services: volumes: - ./adm_scep_depot:/depot restart: always - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=${TAG},public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # ADM Required migrations: @@ -346,14 +234,6 @@ services: - ./.env command: ["/shepherd-mdm", "-migrate"] restart: on-failure - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=${TAG},public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # ADM # Running on port 8000 @@ -373,14 +253,6 @@ services: restart: always ports: - 8000:8000 - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=${TAG},public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" # Redis redis: @@ -388,18 +260,58 @@ services: image: redis:latest network_mode: host restart: always - # logging: - # driver: loki - # options: - # loki-url: "${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push" - # max-size: "200m" - # max-file: "2" - # keep-file: "false" - # loki-external-labels: "job={{.Name}},version=${TAG},public_teamspace_id=${PUBLIC_TEAMSPACE_ID}" + ports: + - 6379:6379 + + # Loki + # Running on port 3100 + loki: + container_name: loki + image: grafana/loki:2.5.0 + networks: + - log-net + env_file: + - ./.env + volumes: + - ./lokidata:/loki + - ./loki-config.yml:/etc/loki/config.yml + command: + - '-config.file=/etc/loki/config.yml' + - '-config.expand-env=true' + restart: always + ports: + - 3100:3100 + + # Promtail + # Running on port 9080 + promtail: + container_name: promtail + image: grafana/promtail:2.5.0 + networks: + - log-net + env_file: + - ./.env + volumes: + - /var/log:/var/log + - /var/lib/docker/containers:/var/lib/docker/containers:ro + - /etc/machine-id:/etc/machine-id:ro + - /var/run/docker.sock:/var/run/docker.sock:ro + - ./logs/oneapi:/var/logs/oneapi:ro + - ./logs/reports-accumulator:/var/logs/repors-accumulator:ro + - ./cron-logs:/var/logs/cron:ro + - ./storage/logs:/var/logs/portal:ro + - ./promtail-config.yml:/etc/promtail/config.yml + command: + - '-config.file=/etc/promtail/config.yml' + - '-config.expand-env=true' + depends_on: + - loki + restart: always networks: reports-net: adm-net: + log-net: volumes: cache: driver: local diff --git a/loki-config.yml b/loki-config.yml new file mode 100644 index 0000000000000000000000000000000000000000..5daab225b5582a67d703202564ec249897a2e9d6 --- /dev/null +++ b/loki-config.yml @@ -0,0 +1,52 @@ +auth_enabled: false + +server: + http_listen_port: 3100 + +ingester: + lifecycler: + # address: 0.0.0.0 + address: 127.0.0.1 + ring: + kvstore: + store: inmemory + replication_factor: 1 + # chunk_idle_period: 15m + # chunk_retain_period: 30s + wal: + dir: /loki/wal + +storage_config: + boltdb_shipper: + active_index_directory: /loki/index + cache_location: /loki/index_cache + # cacte_ttl: 24h + shared_store: filesystem + filesystem: + directory: /loki/chunks + +chunk_store_config: + max_look_back_period: 0s + +schema_config: + configs: + - from: 2020-10-24 + store: boltdb-shipper + object_store: filesystem + schema: v11 + index: + prefix: index_ + period: 24h + +compactor: + working_directory: /loki/compactor + shared_store: filesystem + +limits_config: + enforce_metric_name: false + reject_old_samples: true + reject_old_samples_max_age: 168h + +table_manager: + retention_deletes_enabled: false + retention_period: 0s \ No newline at end of file diff --git a/lokidata/.gitkeep b/lokidata/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/promtail-config.yml b/promtail-config.yml new file mode 100644 index 0000000000000000000000000000000000000000..135034367566abf95a8c399d294c7ccd6eea80db --- /dev/null +++ b/promtail-config.yml @@ -0,0 +1,82 @@ +server: + # http_listen_address: 0.0.0.0 + http_listen_port: 9080 + grpc_listen_port: 0 + +clients: + - url: http://loki:3100/loki/api/v1/push + external_labels: + public_teamspace_id: ${PUBLIC_TEAMSPACE_ID} + - url: ${SUBCOM_INTERNAL_LOG_HOST}/loki/api/v1/push + external_labels: + public_teamspace_id: ${PUBLIC_TEAMSPACE_ID} + +positions: + filename: /tmp/positions.yaml + +scrape_configs: + - job_name: system + static_configs: + - targets: + - localhost + labels: + job: varlogs + __path__: /var/log/*log + - job_name: one + static_configs: + - targets: + - localhost + labels: + job: one + source: file + __path__: /var/logs/oneapi/oneapi.log.* + - job_name: portal + static_configs: + - targets: + - localhost + labels: + job: portal + source: file + __path__: /var/logs/portal/laravel-*.log + - job_name: reports-accumulator + static_configs: + - targets: + - localhost + labels: + job: reports-accumulator + source: file + __path__: /var/logs/reports-accumulator/reports-accumulator.log.* + - job_name: setup-debian-cron + static_configs: + - targets: + - localhost + labels: + job: setup-debian-cron + source: file + __path__: /var/logs/cron/setup-debian-cron.log + - job_name: vimacog-gen-cron + static_configs: + - targets: + - localhost + labels: + job: vimacog-gen-cron + source: file + __path__: /var/logs/cron/vimacog-gen-cron.log + - job_name: vimacog-hard-gen-cron + static_configs: + - targets: + - localhost + labels: + job: vimacog-hard-gen-cron + source: file + __path__: /var/logs/cron/vimacog-hard-gen-cron.log + - job_name: docker + docker_sd_configs: + - host: unix:///var/run/docker.sock + # host_networking_host: 0.0.0.0 + refresh_interval: 10s + relabel_configs: + - source_labels: ['__meta_docker_container_name'] + target_label: 'job' + pipeline_stages: + - docker: {} \ No newline at end of file diff --git a/provisioning/datasources/datasource.yml b/provisioning/datasources/datasource.yml index f24ccc4728710b28e9f61154ae6ee6ad00147713..83bab1493b7d6e7ed2039374a16b6030d246c9da 100644 --- a/provisioning/datasources/datasource.yml +++ b/provisioning/datasources/datasource.yml @@ -6,3 +6,7 @@ datasources: access: proxy url: http://0.0.0.0:8428 isDefault: true + - name: Loki + type: loki + access: proxy + url: http://0.0.0.0:3100 diff --git a/provisioning/notifiers/.gitkeep b/provisioning/notifiers/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/provisioning/plugins/.gitkeep b/provisioning/plugins/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/setup-debian.sh b/setup-debian.sh index 9e8a2c0133494b0234756feccde51cd9bb1c45d2..35bd4ac9b57b780e00d652f412c680e6b5f4768c 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -111,8 +111,6 @@ ensure_dependencies() { sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - sudo docker plugin install grafana/loki-docker-driver:2.9.4 --alias loki --grant-all-permissions - sudo docker plugin enable loki sudo systemctl restart docker else echo "Docker is installed." @@ -134,6 +132,9 @@ ENV_VIMACOG_HARD_GEN="$PROJECT_PATH/vimacog/.env-hard-gen" CADDYFILE_PATH="$PROJECT_PATH/Caddyfile" +GRAFANADATA_PATH="$PROJECT_PATH/grafanadata" +LOKIDATA_PATH="$PROJECT_PATH/lokidata" + SCRIPT_PATH="$PROJECT_PATH/setup-debian.sh" SCRIPT_LOG_PATH="$PROJECT_PATH/cron-logs/setup-debian-cron.log" CRON_JOB="0 0 * * * $SCRIPT_PATH >> $SCRIPT_LOG_PATH 2>&1" @@ -171,6 +172,8 @@ setup_git() { chmod +x "$SCRIPT_PATH" chmod +x "$VIMACOG_GEN_PATH" chmod +x "$VIMACOG_HARD_GEN_PATH" + chmod 777 "$GRAFANADATA_PATH" + chmod 777 "$LOKIDATA_PATH" # Hard refresh the setup echo "Force updating script due to changes..." exec "$SCRIPT_PATH" true