From 8f3c5d4bd37014b55ee44e20d0527b6e07445b13 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 16 Nov 2023 17:40:49 +0100 Subject: [PATCH 01/11] Add donation link and update version numbers --- README.md | 32 +++++++++++++++++++------------- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3d3e1abf5..c485aa55e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,12 @@ No vendor lock-in, which means that all the configuration for your applications/ For more information, take a look at our landing page [here](https://coolify.io). -> If you are looking for previous (v3) version, it is [here](https://github.com/coollabsio/coolify/tree/v3). +# Donations +To stay completely free, open-source, no feature behind paywall and evolve the project, we need your help. If you like Coolify, please consider donating to help us fund the future development of the project. + +https://coolify.io/sponsorships + +Thank you so much! # Cloud @@ -20,25 +25,26 @@ You can easily attach your own servers, get all the automations, free email noti For more information & pricing, take a look at our landing page [here](https://coolify.io). -# Beta +## Why should I use the Cloud version? +The recommended way to use Coolify is to have one server for Coolify and one (or more) for the resources you are deploying. A server is around 4-5$/month. -The latest version (v4) is still in beta. That does not mean it is unstable. All the features that are available are stable enough be usable in real-life. - -There are hundreds of people using it for managing their client's applications, freelancers, hobbyists, businesses. +By subscribing to the cloud version, you get the Coolify server for the same price, but with: +- highly availability +- free email notifications +- etc # Installation ```bash curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash ``` +You can find the installation script source [here](./scripts/install.sh). -You can find the installation script [here](./scripts/install.sh). - -## Support +# Support Contact us [here](https://coolify.io/docs/contact). -## Recognitions +# Recognitions

@@ -54,11 +60,11 @@ Contact us [here](https://coolify.io/docs/contact). coollabsio%2Fcoolify | Trendshift -## 💰 Financial Contributors +# 💰 Financial Contributors Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/coollabsio/contribute)] -### Organizations +## Organizations Special thanks to our biggest sponsors, [CCCareers](https://cccareers.org/) and [Appwrite](https://appwrite.io)! @@ -78,10 +84,10 @@ Support this project with your organization. Your logo will show up here with a -### Individuals +## Individuals -## Star History +# Star History [![Star History Chart](https://api.star-history.com/svg?repos=coollabsio/coolify&type=Date)](https://star-history.com/#coollabsio/coolify&Date) diff --git a/config/sentry.php b/config/sentry.php index 2de0f59df..b66785b50 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.138', + 'release' => '4.0.0-beta.139', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 8915456f9..085941feb 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Thu, 16 Nov 2023 17:42:25 +0100 Subject: [PATCH 02/11] Improve Cloud version features and reduce maintenance --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c485aa55e..e5d0b48e5 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,10 @@ For more information & pricing, take a look at our landing page [here](https://c The recommended way to use Coolify is to have one server for Coolify and one (or more) for the resources you are deploying. A server is around 4-5$/month. By subscribing to the cloud version, you get the Coolify server for the same price, but with: -- highly availability -- free email notifications -- etc +- High-availability +- Free email notifications +- Better support +- Less maintenance for you # Installation From aa00389824361b21dff8faf074b984d3098e91c7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 16 Nov 2023 17:43:20 +0100 Subject: [PATCH 03/11] Remove redundant sentence about cloud version in README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index e5d0b48e5..8c8edf60a 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,6 @@ Thank you so much! If you do not want to self-host Coolify, there is a paid cloud version available: https://app.coolify.io -You can easily attach your own servers, get all the automations, free email notifications, etc. - For more information & pricing, take a look at our landing page [here](https://coolify.io). ## Why should I use the Cloud version? From 91e3d33c0b3303e169be0997e2c57a3b82ef54ec Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 16 Nov 2023 20:48:25 +0100 Subject: [PATCH 04/11] Add cleanup of stucked helper containers on servers --- app/Console/Commands/Init.php | 12 ++++++++ app/Jobs/CleanupHelperContainersJob.php | 40 +++++++++++++++++++++++++ bootstrap/helpers/docker.php | 2 -- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 app/Jobs/CleanupHelperContainersJob.php diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index e0081d0d5..1bb4aa055 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -3,9 +3,11 @@ namespace App\Console\Commands; use App\Enums\ApplicationDeploymentStatus; +use App\Jobs\CleanupHelperContainersJob; use App\Models\Application; use App\Models\ApplicationDeploymentQueue; use App\Models\InstanceSettings; +use App\Models\Server; use App\Models\Service; use App\Models\ServiceApplication; use App\Models\ServiceDatabase; @@ -32,6 +34,16 @@ class Init extends Command $this->cleanup_ssh(); } $this->cleanup_in_progress_application_deployments(); + $this->cleanup_stucked_helper_containers(); + } + private function cleanup_stucked_helper_containers() { + $servers = Server::all(); + foreach ($servers as $server) { + if ($server->isFunctional()) { + CleanupHelperContainersJob::dispatch($server); + } + } + } private function alive() { diff --git a/app/Jobs/CleanupHelperContainersJob.php b/app/Jobs/CleanupHelperContainersJob.php new file mode 100644 index 000000000..5c26ca930 --- /dev/null +++ b/app/Jobs/CleanupHelperContainersJob.php @@ -0,0 +1,40 @@ +server->name); + $containers = instant_remote_process(['docker container ps --filter "ancestor=ghcr.io/coollabsio/coolify-helper:next" --filter "ancestor=ghcr.io/coollabsio/coolify-helper:latest" --format \'{{json .}}\''], $this->server, false); + $containers = format_docker_command_output_to_json($containers); + if ($containers->count() > 0) { + foreach ($containers as $container) { + $containerId = data_get($container,'ID'); + ray('Removing container ' . $containerId); + instant_remote_process(['docker container rm -f ' . $containerId], $this->server, false); + } + } + } catch (\Throwable $e) { + send_internal_notification('CleanupHelperContainersJob failed with error: ' . $e->getMessage()); + ray($e->getMessage()); + } + } +} diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 42ea0f9bc..36f8733b3 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -10,7 +10,6 @@ use Visus\Cuid2\Cuid2; function getCurrentApplicationContainerStatus(Server $server, int $id, ?int $pullRequestId = null): Collection { - ray($id, $pullRequestId); $containers = collect([]); $containers = instant_remote_process(["docker ps -a --filter='label=coolify.applicationId={$id}' --format '{{json .}}' "], $server); $containers = format_docker_command_output_to_json($containers); @@ -26,7 +25,6 @@ function getCurrentApplicationContainerStatus(Server $server, int $id, ?int $pul return null; }); $containers = $containers->filter(); - ray($containers); return $containers; } From 6c7e091e1bf7472eca757994a2b15a1ecc9b31b9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Nov 2023 00:37:09 +0100 Subject: [PATCH 05/11] feat: log drain (wip) --- app/Actions/Server/InstallLogDrain.php | 130 ++++++++++++++++++ app/Http/Livewire/Server/LogDrains.php | 74 ++++++++++ app/Jobs/ApplicationDeploymentJob.php | 18 +-- app/Models/Server.php | 6 + .../2023_11_16_220647_add_log_drains.php | 38 +++++ examples/fluent-bit/fluent-bit.conf | 16 --- examples/fluent-bit/fluent-bit.yaml | 9 -- examples/newrelic.yaml | 21 --- examples/otl/config.yaml | 34 ----- .../views/components/server/navbar.blade.php | 6 + .../livewire/server/log-drains.blade.php | 49 +++++++ routes/web.php | 2 + 12 files changed, 315 insertions(+), 88 deletions(-) create mode 100644 app/Actions/Server/InstallLogDrain.php create mode 100644 app/Http/Livewire/Server/LogDrains.php create mode 100644 database/migrations/2023_11_16_220647_add_log_drains.php delete mode 100644 examples/fluent-bit/fluent-bit.conf delete mode 100644 examples/fluent-bit/fluent-bit.yaml delete mode 100644 examples/newrelic.yaml delete mode 100644 examples/otl/config.yaml create mode 100644 resources/views/livewire/server/log-drains.blade.php diff --git a/app/Actions/Server/InstallLogDrain.php b/app/Actions/Server/InstallLogDrain.php new file mode 100644 index 000000000..79acda8e7 --- /dev/null +++ b/app/Actions/Server/InstallLogDrain.php @@ -0,0 +1,130 @@ +settings->is_logdrain_newrelic_enabled) { + throw new \Exception('New Relic log drain is not enabled.'); + } + $config = base64_encode(" +[SERVICE] + Flush 5 + Daemon off + Tag container_logs +[INPUT] + Name forward + Buffer_Chunk_Size 1M + Buffer_Max_Size 6M +[FILTER] + Name grep + Match * + Exclude log 127.0.0.1 +[FILTER] + Name modify + Match * + Set server_name {$server->name} + +[OUTPUT] + Name nrlogs + Match * + license_key \${LICENSE_KEY} + # https://log-api.eu.newrelic.com/log/v1 - EU + # https://log-api.newrelic.com/log/v1 - US + base_uri \${BASE_URI} +"); + } else if ($type === 'highlight') { + if (!$server->settings->is_logdrain_highlight_enabled) { + throw new \Exception('Highlight log drain is not enabled.'); + } + $config = base64_encode(' +[SERVICE] + Flush 5 + Daemon off + Tag container_logs +[INPUT] + Name forward + tag ${HIGHLIGHT_PROJECT_ID} + Buffer_Chunk_Size 1M + Buffer_Max_Size 6M +[FILTER] + Name grep + Match * + Exclude log 127.0.0.1 +[FILTER] + Name modify + Match * + Set server_name {$server->name} +[OUTPUT] + Name forward + Match * + Host otel.highlight.io + Port 24224 +'); + } + + $compose = base64_encode(" +services: + coolify-log-drain: + image: cr.fluentbit.io/fluent/fluent-bit:2.0 + container_name: coolify-log-drain + command: -c /fluent-bit.conf + env_file: + - .env + volumes: + - ./fluent-bit.conf:/fluent-bit.conf + ports: + - 127.0.0.1:24224:24224 +"); + $readme = base64_encode('# New Relic Log Drain +This log drain is based on [Fluent Bit](https://fluentbit.io/) and New Relic Log Forwarder. + +Files: +- `fluent-bit.conf` - configuration file for Fluent Bit +- `docker-compose.yml` - docker-compose file to run Fluent Bit +- `.env` - environment variables for Fluent Bit +'); + $license_key = $server->settings->logdrain_newrelic_license_key; + $base_uri = $server->settings->logdrain_newrelic_base_uri; + $base_path = config('coolify.base_config_path'); + + $config_path = $base_path . '/log-drains'; + $fluent_bit_config = $config_path . '/fluent-bit.conf'; + $compose_path = $config_path . '/docker-compose.yml'; + $readme_path = $config_path . '/README.md'; + $command = [ + "echo 'Saving configuration'", + "mkdir -p $config_path", + "echo '{$config}' | base64 -d > $fluent_bit_config", + "echo '{$compose}' | base64 -d > $compose_path", + "echo '{$readme}' | base64 -d > $readme_path", + "rm $config_path/.env || true", + + ]; + if ($type === 'newrelic') { + $add_envs_command = [ + "echo LICENSE_KEY=$license_key >> $config_path/.env", + "echo BASE_URI=$base_uri >> $config_path/.env", + ]; + } else if ($type === 'highlight') { + $add_envs_command = [ + "echo HIGHLIGHT_PROJECT_ID={$server->settings->logdrain_highlight_project_id} >> $config_path/.env", + ]; + } + $restart_command = [ + "echo 'Stopping old Fluent Bit'", + "cd $config_path && docker rm -f coolify-log-drain || true", + "echo 'Starting Fluent Bit'", + "cd $config_path && docker compose up -d --remove-orphans", + ]; + $command = array_merge($command, $add_envs_command, $restart_command); + return instant_remote_process($command, $server); + } +} diff --git a/app/Http/Livewire/Server/LogDrains.php b/app/Http/Livewire/Server/LogDrains.php new file mode 100644 index 000000000..823886b3f --- /dev/null +++ b/app/Http/Livewire/Server/LogDrains.php @@ -0,0 +1,74 @@ + 'required|boolean', + 'server.settings.logdrain_newrelic_license_key' => 'required|string', + 'server.settings.logdrain_newrelic_base_uri' => 'required|string', + 'server.settings.is_logdrain_highlight_enabled' => 'required|boolean', + 'server.settings.logdrain_highlight_project_id' => 'required|string', + ]; + + public function mount() { + $this->parameters = get_route_parameters(); + try { + $this->server = Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->first(); + if (is_null($this->server)) { + return redirect()->route('server.all'); + } + } catch (\Throwable $e) { + return handleError($e, $this); + } + } + public function configureLogDrain(string $type) { + try { + $this->server->logDrain($type); + $this->emit('serverRefresh'); + $this->emit('success', 'Log drain configured successfully.'); + } catch (\Throwable $e) { + return handleError($e, $this); + } + } + public function instantSave(string $type) { + $this->submit($type); + } + public function submit(string $type) { + try { + $this->resetErrorBag(); + if ($type === 'newrelic') { + $this->validate([ + 'server.settings.is_logdrain_newrelic_enabled' => 'required|boolean', + 'server.settings.logdrain_newrelic_license_key' => 'required|string', + 'server.settings.logdrain_newrelic_base_uri' => 'required|string', + ]); + $this->server->settings->update([ + 'is_logdrain_highlight_enabled' => false, + ]); + } else if ($type === 'highlight') { + $this->validate([ + 'server.settings.is_logdrain_highlight_enabled' => 'required|boolean', + 'server.settings.logdrain_highlight_project_id' => 'required|string', + ]); + $this->server->settings->update([ + 'is_logdrain_newrelic_enabled' => false, + ]); + } + $this->server->settings->save(); + $this->emit('success', 'Settings saved successfully.'); + } catch (\Throwable $e) { + return handleError($e, $this); + } + } + public function render() + { + return view('livewire.server.log-drains'); + } +} diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 83674e815..c74c973f9 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -498,7 +498,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted if ($this->full_healthcheck_url) { $this->execute_remote_command( [ - "echo 'Healthcheck URL inside your container: {$this->full_healthcheck_url}'" + "echo 'Healthcheck URL (inside the container): {$this->full_healthcheck_url}'" ] ); } @@ -837,13 +837,15 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted 'networks' => [ $this->destination->network, ], - // 'logging' => [ - // 'driver' => 'fluentd', - // 'options' => [ - // 'fluentd-async' => 'true', - // 'tag' => $this->application->name . '-' . $this->application->uuid - // ] - // ], + 'logging' => [ + 'driver' => 'fluentd', + 'options' => [ + 'fluentd-address' => "tcp://127.0.0.1:24224", + 'fluentd-async' => "true", + 'fluentd-sub-second-precision' => "true", + + ] + ], 'healthcheck' => [ 'test' => [ 'CMD-SHELL', diff --git a/app/Models/Server.php b/app/Models/Server.php index d1b11a080..6fa5bda7b 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -2,6 +2,8 @@ namespace App\Models; +use App\Actions\Server\InstallLogDrain; +use App\Actions\Server\InstallNewRelic; use App\Enums\ProxyStatus; use App\Enums\ProxyTypes; use App\Notifications\Server\Revived; @@ -296,6 +298,10 @@ class Server extends BaseModel // } return true; } + public function logDrain($type) + { + InstallLogDrain::run($this, $type); + } public function isFunctional() { return $this->settings->is_reachable && $this->settings->is_usable; diff --git a/database/migrations/2023_11_16_220647_add_log_drains.php b/database/migrations/2023_11_16_220647_add_log_drains.php new file mode 100644 index 000000000..82274a999 --- /dev/null +++ b/database/migrations/2023_11_16_220647_add_log_drains.php @@ -0,0 +1,38 @@ +boolean('is_logdrain_newrelic_enabled')->default(false); + $table->string('logdrain_newrelic_license_key')->nullable(); + $table->string('logdrain_newrelic_base_uri')->nullable(); + + $table->boolean('is_logdrain_highlight_enabled')->default(false); + $table->string('logdrain_highlight_project_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('server_settings', function (Blueprint $table) { + $table->dropColumn('is_logdrain_newrelic_enabled'); + $table->dropColumn('logdrain_newrelic_license_key'); + $table->dropColumn('logdrain_newrelic_base_uri'); + + $table->dropColumn('is_logdrain_highlight_enabled'); + $table->dropColumn('logdrain_highlight_project_id'); + }); + } +}; diff --git a/examples/fluent-bit/fluent-bit.conf b/examples/fluent-bit/fluent-bit.conf deleted file mode 100644 index 5d10f559a..000000000 --- a/examples/fluent-bit/fluent-bit.conf +++ /dev/null @@ -1,16 +0,0 @@ -[SERVICE] - Flush 1 - Daemon off -[INPUT] - Name forward - Buffer_Chunk_Size 1M - Buffer_Max_Size 6M -# [OUTPUT] -# Name nrlogs -# Match * -# license_key ${LICENSE_KEY} -# base_uri https://log-api.eu.newrelic.com/log/v1 - -[OUTPUT] - Name stdout - Match * diff --git a/examples/fluent-bit/fluent-bit.yaml b/examples/fluent-bit/fluent-bit.yaml deleted file mode 100644 index ca573635e..000000000 --- a/examples/fluent-bit/fluent-bit.yaml +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' -services: - coolify-fluent-bit: - image: cr.fluentbit.io/fluent/fluent-bit:2.0 - command: -c /fluent-bit.conf - volumes: - - ./fluent-bit.conf:/fluent-bit.conf - ports: - - 24224:24224 diff --git a/examples/newrelic.yaml b/examples/newrelic.yaml deleted file mode 100644 index 40bd5b0f2..000000000 --- a/examples/newrelic.yaml +++ /dev/null @@ -1,21 +0,0 @@ -version: '3' -services: - newrelic-infra: - container_name: newrelic-infra - image: newrelic/infrastructure:latest - networks: - - coolify - cap_add: - - SYS_PTRACE - privileged: true - pid: host - volumes: - - "/:/host:ro" - - "/var/run/docker.sock:/var/run/docker.sock" - - "newrelic-infra:/etc/newrelic-infra" - environment: - - NRIA_LICENSE_KEY=${NRIA_LICENSE_KEY} - - NRIA_DISPLAY_NAME=${HOSTNAME} - -networks: - coolify: diff --git a/examples/otl/config.yaml b/examples/otl/config.yaml deleted file mode 100644 index a1b8b7ec4..000000000 --- a/examples/otl/config.yaml +++ /dev/null @@ -1,34 +0,0 @@ -receivers: - hostmetrics: - collection_interval: 5s - scrapers: - cpu: - metrics: - system.cpu.utilization: - enabled: true -processors: - resourcedetection: - detectors: [env, system] - system: - hostname_sources: ["os"] - resource_attributes: - host.id: - enabled: true - batch: - memory_limiter: - check_interval: 1s - limit_mib: 1000 - spike_limit_mib: 200 -exporters: - debug: - verbosity: detailed - otlp: - endpoint: ${OTLP_ENDPOINT} - headers: - api-key: ${OTLP_API_KEY} -service: - pipelines: - metrics: - receivers: [hostmetrics] - processors: [memory_limiter, resourcedetection, batch] - exporters: [debug, otlp] diff --git a/resources/views/components/server/navbar.blade.php b/resources/views/components/server/navbar.blade.php index fbbdc545b..56b11ef78 100644 --- a/resources/views/components/server/navbar.blade.php +++ b/resources/views/components/server/navbar.blade.php @@ -32,6 +32,12 @@ ]) }}"> + + +

diff --git a/resources/views/livewire/server/log-drains.blade.php b/resources/views/livewire/server/log-drains.blade.php new file mode 100644 index 000000000..38c5b0cc4 --- /dev/null +++ b/resources/views/livewire/server/log-drains.blade.php @@ -0,0 +1,49 @@ +
+ +

Log Drains

+
Sends resource logs to external services.
+
+
+

New Relic

+
+ +
+
+
+
+ + +
+ +
+
+ + Save + + + Configure On Server + +
+
+

Highlight.io

+
+ +
+
+
+
+ +
+
+
+ + Save + + + Configure On Server + +
+
+
+
+
diff --git a/routes/web.php b/routes/web.php index 54226ca89..6ac0d578c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,6 +16,7 @@ use App\Http\Livewire\Security\ApiTokens; use App\Http\Livewire\Server\All; use App\Http\Livewire\Server\Create; use App\Http\Livewire\Server\Destination\Show as DestinationShow; +use App\Http\Livewire\Server\LogDrains; use App\Http\Livewire\Server\PrivateKey\Show as PrivateKeyShow; use App\Http\Livewire\Server\Proxy\Show as ProxyShow; use App\Http\Livewire\Server\Proxy\Logs as ProxyLogs; @@ -130,6 +131,7 @@ Route::middleware(['auth'])->group(function () { Route::get('/server/{server_uuid}/proxy/logs', ProxyLogs::class)->name('server.proxy.logs'); Route::get('/server/{server_uuid}/private-key', PrivateKeyShow::class)->name('server.private-key'); Route::get('/server/{server_uuid}/destinations', DestinationShow::class)->name('server.destinations'); + Route::get('/server/{server_uuid}/log-drains', LogDrains::class)->name('server.log-drains'); }); From 88c5d8708476ea5d039c19964f32478146326828 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Nov 2023 10:21:19 +0100 Subject: [PATCH 06/11] Add log drain settings for New Relic,Highlight.io, and Axiom --- app/Actions/Server/InstallLogDrain.php | 143 ++++++++++++------ app/Http/Livewire/Server/LogDrains.php | 85 +++++++++-- app/Jobs/ApplicationDeploymentJob.php | 5 +- app/Models/Server.php | 2 + .../2023_11_16_220647_add_log_drains.php | 9 ++ .../livewire/server/log-drains.blade.php | 47 ++++-- 6 files changed, 215 insertions(+), 76 deletions(-) diff --git a/app/Actions/Server/InstallLogDrain.php b/app/Actions/Server/InstallLogDrain.php index 79acda8e7..e4e43dc1b 100644 --- a/app/Actions/Server/InstallLogDrain.php +++ b/app/Actions/Server/InstallLogDrain.php @@ -10,11 +10,18 @@ class InstallLogDrain use AsAction; public function handle(Server $server, string $type) { - if ($type === 'newrelic') { - if (!$server->settings->is_logdrain_newrelic_enabled) { - throw new \Exception('New Relic log drain is not enabled.'); - } - $config = base64_encode(" + try { + if ($type === 'none') { + $command = [ + "echo 'Stopping old Fluent Bit'", + "docker rm -f coolify-log-drain || true", + ]; + return instant_remote_process($command, $server); + } else if ($type === 'newrelic') { + if (!$server->settings->is_logdrain_newrelic_enabled) { + throw new \Exception('New Relic log drain is not enabled.'); + } + $config = base64_encode(" [SERVICE] Flush 5 Daemon off @@ -40,18 +47,36 @@ class InstallLogDrain # https://log-api.newrelic.com/log/v1 - US base_uri \${BASE_URI} "); - } else if ($type === 'highlight') { - if (!$server->settings->is_logdrain_highlight_enabled) { - throw new \Exception('Highlight log drain is not enabled.'); - } - $config = base64_encode(' + } else if ($type === 'highlight') { + if (!$server->settings->is_logdrain_highlight_enabled) { + throw new \Exception('Highlight log drain is not enabled.'); + } + $config = base64_encode(" +[SERVICE] + Flush 1 + Daemon off + Log_Level debug +[INPUT] + Name forward + tag \${HIGHLIGHT_PROJECT_ID} + Buffer_Chunk_Size 1M + Buffer_Max_Size 6M +[OUTPUT] + Name forward + Match * + Host otel.highlight.io + Port 24224 +"); + } else if ($type === 'axiom') { + if (!$server->settings->is_logdrain_axiom_enabled) { + throw new \Exception('Axiom log drain is not enabled.'); + } + $config = base64_encode(" [SERVICE] Flush 5 Daemon off - Tag container_logs [INPUT] Name forward - tag ${HIGHLIGHT_PROJECT_ID} Buffer_Chunk_Size 1M Buffer_Max_Size 6M [FILTER] @@ -63,14 +88,24 @@ class InstallLogDrain Match * Set server_name {$server->name} [OUTPUT] - Name forward - Match * - Host otel.highlight.io - Port 24224 -'); - } + Name http + Match * + Host api.axiom.co + Port 443 + URI /v1/datasets/\${AXIOM_DATASET_NAME}/ingest + # Authorization Bearer should be an API token + Header Authorization Bearer \${AXIOM_API_KEY} + compress gzip + format json + json_date_key _time + json_date_format iso8601 + tls On +"); + } else { + throw new \Exception('Unknown log drain type.'); + } - $compose = base64_encode(" + $compose = base64_encode(" services: coolify-log-drain: image: cr.fluentbit.io/fluent/fluent-bit:2.0 @@ -83,7 +118,7 @@ services: ports: - 127.0.0.1:24224:24224 "); - $readme = base64_encode('# New Relic Log Drain + $readme = base64_encode('# New Relic Log Drain This log drain is based on [Fluent Bit](https://fluentbit.io/) and New Relic Log Forwarder. Files: @@ -91,40 +126,48 @@ Files: - `docker-compose.yml` - docker-compose file to run Fluent Bit - `.env` - environment variables for Fluent Bit '); - $license_key = $server->settings->logdrain_newrelic_license_key; - $base_uri = $server->settings->logdrain_newrelic_base_uri; - $base_path = config('coolify.base_config_path'); + $license_key = $server->settings->logdrain_newrelic_license_key; + $base_uri = $server->settings->logdrain_newrelic_base_uri; + $base_path = config('coolify.base_config_path'); - $config_path = $base_path . '/log-drains'; - $fluent_bit_config = $config_path . '/fluent-bit.conf'; - $compose_path = $config_path . '/docker-compose.yml'; - $readme_path = $config_path . '/README.md'; - $command = [ - "echo 'Saving configuration'", - "mkdir -p $config_path", - "echo '{$config}' | base64 -d > $fluent_bit_config", - "echo '{$compose}' | base64 -d > $compose_path", - "echo '{$readme}' | base64 -d > $readme_path", - "rm $config_path/.env || true", + $config_path = $base_path . '/log-drains'; + $fluent_bit_config = $config_path . '/fluent-bit.conf'; + $compose_path = $config_path . '/docker-compose.yml'; + $readme_path = $config_path . '/README.md'; + $command = [ + "echo 'Saving configuration'", + "mkdir -p $config_path", + "echo '{$config}' | base64 -d > $fluent_bit_config", + "echo '{$compose}' | base64 -d > $compose_path", + "echo '{$readme}' | base64 -d > $readme_path", + "test -f $config_path/.env && rm $config_path/.env", - ]; - if ($type === 'newrelic') { - $add_envs_command = [ - "echo LICENSE_KEY=$license_key >> $config_path/.env", - "echo BASE_URI=$base_uri >> $config_path/.env", ]; - } else if ($type === 'highlight') { - $add_envs_command = [ - "echo HIGHLIGHT_PROJECT_ID={$server->settings->logdrain_highlight_project_id} >> $config_path/.env", + if ($type === 'newrelic') { + $add_envs_command = [ + "echo LICENSE_KEY=$license_key >> $config_path/.env", + "echo BASE_URI=$base_uri >> $config_path/.env", + ]; + } else if ($type === 'highlight') { + $add_envs_command = [ + "echo HIGHLIGHT_PROJECT_ID={$server->settings->logdrain_highlight_project_id} >> $config_path/.env", + ]; + } else if ($type === 'axiom') { + $add_envs_command = [ + "echo AXIOM_DATASET_NAME={$server->settings->logdrain_axiom_dataset_name} >> $config_path/.env", + "echo AXIOM_API_KEY={$server->settings->logdrain_axiom_api_key} >> $config_path/.env", + ]; + } + $restart_command = [ + "echo 'Stopping old Fluent Bit'", + "cd $config_path && docker rm -f coolify-log-drain || true", + "echo 'Starting Fluent Bit'", + "cd $config_path && docker compose up -d --remove-orphans", ]; + $command = array_merge($command, $add_envs_command, $restart_command); + return instant_remote_process($command, $server); + } catch (\Throwable $e) { + return handleError($e); } - $restart_command = [ - "echo 'Stopping old Fluent Bit'", - "cd $config_path && docker rm -f coolify-log-drain || true", - "echo 'Starting Fluent Bit'", - "cd $config_path && docker compose up -d --remove-orphans", - ]; - $command = array_merge($command, $add_envs_command, $restart_command); - return instant_remote_process($command, $server); } } diff --git a/app/Http/Livewire/Server/LogDrains.php b/app/Http/Livewire/Server/LogDrains.php index 823886b3f..4545e205f 100644 --- a/app/Http/Livewire/Server/LogDrains.php +++ b/app/Http/Livewire/Server/LogDrains.php @@ -15,32 +15,70 @@ class LogDrains extends Component 'server.settings.logdrain_newrelic_base_uri' => 'required|string', 'server.settings.is_logdrain_highlight_enabled' => 'required|boolean', 'server.settings.logdrain_highlight_project_id' => 'required|string', + 'server.settings.is_logdrain_axiom_enabled' => 'required|boolean', + 'server.settings.logdrain_axiom_dataset_name' => 'required|string', + 'server.settings.logdrain_axiom_api_key' => 'required|string', + ]; + protected $validationAttributes = [ + 'server.settings.is_logdrain_newrelic_enabled' => 'New Relic log drain', + 'server.settings.logdrain_newrelic_license_key' => 'New Relic license key', + 'server.settings.logdrain_newrelic_base_uri' => 'New Relic base URI', + 'server.settings.is_logdrain_highlight_enabled' => 'Highlight log drain', + 'server.settings.logdrain_highlight_project_id' => 'Highlight project ID', + 'server.settings.is_logdrain_axiom_enabled' => 'Axiom log drain', + 'server.settings.logdrain_axiom_dataset_name' => 'Axiom dataset name', + 'server.settings.logdrain_axiom_api_key' => 'Axiom API key', ]; - public function mount() { + public function mount() + { $this->parameters = get_route_parameters(); try { - $this->server = Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->first(); - if (is_null($this->server)) { + $server = Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->first(); + if (is_null($server)) { return redirect()->route('server.all'); } + $this->server = $server; } catch (\Throwable $e) { return handleError($e, $this); } } - public function configureLogDrain(string $type) { + public function configureLogDrain() + { try { - $this->server->logDrain($type); + if ($this->server->settings->is_logdrain_newrelic_enabled) { + $this->server->logDrain('newrelic'); + } else if ($this->server->settings->is_logdrain_highlight_enabled) { + $this->server->logDrain('highlight'); + } else if ($this->server->settings->is_logdrain_axiom_enabled) { + $this->server->logDrain('axiom'); + } else { + $this->server->logDrain('none'); + $this->emit('serverRefresh'); + $this->emit('success', 'Log drain service stopped.'); + return; + } $this->emit('serverRefresh'); - $this->emit('success', 'Log drain configured successfully.'); + $this->emit('success', 'Log drain service started successfully.'); } catch (\Throwable $e) { return handleError($e, $this); } } - public function instantSave(string $type) { - $this->submit($type); + public function instantSave(string $type) + { + try { + $ok = $this->submit($type); + ray($ok); + if (!$ok) { + return; + } + $this->configureLogDrain(); + } catch (\Throwable $e) { + return handleError($e, $this); + } } - public function submit(string $type) { + public function submit(string $type) + { try { $this->resetErrorBag(); if ($type === 'newrelic') { @@ -51,6 +89,7 @@ class LogDrains extends Component ]); $this->server->settings->update([ 'is_logdrain_highlight_enabled' => false, + 'is_logdrain_axiom_enabled' => false, ]); } else if ($type === 'highlight') { $this->validate([ @@ -59,12 +98,38 @@ class LogDrains extends Component ]); $this->server->settings->update([ 'is_logdrain_newrelic_enabled' => false, + 'is_logdrain_axiom_enabled' => false, + ]); + } else if ($type === 'axiom') { + $this->validate([ + 'server.settings.is_logdrain_axiom_enabled' => 'required|boolean', + 'server.settings.logdrain_axiom_dataset_name' => 'required|string', + 'server.settings.logdrain_axiom_api_key' => 'required|string', + ]); + $this->server->settings->update([ + 'is_logdrain_newrelic_enabled' => false, + 'is_logdrain_highlight_enabled' => false, ]); } $this->server->settings->save(); $this->emit('success', 'Settings saved successfully.'); + return true; } catch (\Throwable $e) { - return handleError($e, $this); + if ($type === 'newrelic') { + $this->server->settings->update([ + 'is_logdrain_newrelic_enabled' => false, + ]); + } else if ($type === 'highlight') { + $this->server->settings->update([ + 'is_logdrain_highlight_enabled' => false, + ]); + } else if ($type === 'axiom') { + $this->server->settings->update([ + 'is_logdrain_axiom_enabled' => false, + ]); + } + handleError($e, $this); + return false; } } public function render() diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index c74c973f9..e67a43e46 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -843,7 +843,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted 'fluentd-address' => "tcp://127.0.0.1:24224", 'fluentd-async' => "true", 'fluentd-sub-second-precision' => "true", - ] ], 'healthcheck' => [ @@ -1021,6 +1020,10 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); listen [::]:80; server_name localhost; + // real_ip_header X-Forwarded-For; + // proxy_set_header X-Real-IP \$remote_addr; + // proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + location / { root /usr/share/nginx/html; index index.html; diff --git a/app/Models/Server.php b/app/Models/Server.php index 6fa5bda7b..83df8d61a 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -61,6 +61,8 @@ class Server extends BaseModel public $casts = [ 'proxy' => SchemalessAttributes::class, + 'logdrain_axiom_api_key' => 'encrypted', + 'logdrain_newrelic_license_key' => 'encrypted', ]; protected $schemalessAttributes = [ 'proxy', diff --git a/database/migrations/2023_11_16_220647_add_log_drains.php b/database/migrations/2023_11_16_220647_add_log_drains.php index 82274a999..05b1ed054 100644 --- a/database/migrations/2023_11_16_220647_add_log_drains.php +++ b/database/migrations/2023_11_16_220647_add_log_drains.php @@ -18,6 +18,11 @@ return new class extends Migration $table->boolean('is_logdrain_highlight_enabled')->default(false); $table->string('logdrain_highlight_project_id')->nullable(); + + $table->boolean('is_logdrain_axiom_enabled')->default(false); + $table->string('logdrain_axiom_dataset_name')->nullable(); + $table->string('logdrain_axiom_api_key')->nullable(); + }); } @@ -33,6 +38,10 @@ return new class extends Migration $table->dropColumn('is_logdrain_highlight_enabled'); $table->dropColumn('logdrain_highlight_project_id'); + + $table->dropColumn('is_logdrain_axiom_enabled'); + $table->dropColumn('logdrain_axiom_dataset_name'); + $table->dropColumn('logdrain_axiom_api_key'); }); } }; diff --git a/resources/views/livewire/server/log-drains.blade.php b/resources/views/livewire/server/log-drains.blade.php index 38c5b0cc4..6a2a48349 100644 --- a/resources/views/livewire/server/log-drains.blade.php +++ b/resources/views/livewire/server/log-drains.blade.php @@ -2,45 +2,62 @@

Log Drains

Sends resource logs to external services.
-
+
-

New Relic

-
- -
+

New Relic

+
+ +
- - + +
-
Save - - Configure On Server -

Highlight.io

- +
- +
Save - - Configure On Server +
+
+

Axiom

+
+ +
+
+
+
+ + +
+
+
+ + Save
From 81e6482d7ae0ad9f9b970eda0012da713945347d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Nov 2023 10:21:42 +0100 Subject: [PATCH 07/11] Remove commented out code and fix indentation --- resources/views/livewire/server/log-drains.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/livewire/server/log-drains.blade.php b/resources/views/livewire/server/log-drains.blade.php index 6a2a48349..60f51665c 100644 --- a/resources/views/livewire/server/log-drains.blade.php +++ b/resources/views/livewire/server/log-drains.blade.php @@ -24,7 +24,7 @@
-

Highlight.io

+ {{--

Highlight.io

@@ -41,7 +41,7 @@ Save
- + --}}

Axiom

Date: Fri, 17 Nov 2023 10:50:02 +0100 Subject: [PATCH 08/11] Update Fluent Bit configuration file --- app/Actions/Server/InstallLogDrain.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/Actions/Server/InstallLogDrain.php b/app/Actions/Server/InstallLogDrain.php index e4e43dc1b..5ea1d5e43 100644 --- a/app/Actions/Server/InstallLogDrain.php +++ b/app/Actions/Server/InstallLogDrain.php @@ -26,6 +26,8 @@ class InstallLogDrain Flush 5 Daemon off Tag container_logs + Log_Level debug + Parsers_File parsers.conf [INPUT] Name forward Buffer_Chunk_Size 1M @@ -38,7 +40,6 @@ class InstallLogDrain Name modify Match * Set server_name {$server->name} - [OUTPUT] Name nrlogs Match * @@ -53,9 +54,10 @@ class InstallLogDrain } $config = base64_encode(" [SERVICE] - Flush 1 + Flush 5 Daemon off Log_Level debug + Parsers_File parsers.conf [INPUT] Name forward tag \${HIGHLIGHT_PROJECT_ID} @@ -75,6 +77,8 @@ class InstallLogDrain [SERVICE] Flush 5 Daemon off + Log_Level debug + Parsers_File parsers.conf [INPUT] Name forward Buffer_Chunk_Size 1M @@ -104,7 +108,12 @@ class InstallLogDrain } else { throw new \Exception('Unknown log drain type.'); } - + $parsers = base64_encode(" +[PARSER] + Name empty_line_skipper + Format regex + Regex /^(?!\s*$).+/ +"); $compose = base64_encode(" services: coolify-log-drain: @@ -115,6 +124,7 @@ services: - .env volumes: - ./fluent-bit.conf:/fluent-bit.conf + - ./parsers.conf:/parsers.conf ports: - 127.0.0.1:24224:24224 "); @@ -132,11 +142,13 @@ Files: $config_path = $base_path . '/log-drains'; $fluent_bit_config = $config_path . '/fluent-bit.conf'; + $parsers_config = $config_path . '/parsers.conf'; $compose_path = $config_path . '/docker-compose.yml'; $readme_path = $config_path . '/README.md'; $command = [ "echo 'Saving configuration'", "mkdir -p $config_path", + "echo '{$parsers}' | base64 -d > $parsers_config", "echo '{$config}' | base64 -d > $fluent_bit_config", "echo '{$compose}' | base64 -d > $compose_path", "echo '{$readme}' | base64 -d > $readme_path", From b8252b85b0dcc44aa0c804c04cd6433243689daa Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Nov 2023 11:13:16 +0100 Subject: [PATCH 09/11] Refactor logging configuration in ApplicationDeploymentJob.php --- app/Jobs/ApplicationDeploymentJob.php | 19 +++++++++++-------- app/Models/Server.php | 3 +++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index e67a43e46..55dbefedd 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -837,14 +837,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted 'networks' => [ $this->destination->network, ], - 'logging' => [ - 'driver' => 'fluentd', - 'options' => [ - 'fluentd-address' => "tcp://127.0.0.1:24224", - 'fluentd-async' => "true", - 'fluentd-sub-second-precision' => "true", - ] - ], 'healthcheck' => [ 'test' => [ 'CMD-SHELL', @@ -872,6 +864,17 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted ] ] ]; + ray($this->server->isDrainLogActivated()); + if ($this->server->isDrainLogActivated()) { + $docker_compose['services'][$this->container_name]['logging'] = [ + 'driver' => 'fluentd', + 'options' => [ + 'fluentd-address' => "tcp://127.0.0.1:24224", + 'fluentd-async' => "true", + 'fluentd-sub-second-precision' => "true", + ] + ]; + } if ($this->application->isHealthcheckDisabled()) { data_forget($docker_compose, 'services.' . $this->container_name . '.healthcheck'); } diff --git a/app/Models/Server.php b/app/Models/Server.php index 83df8d61a..788808430 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -308,6 +308,9 @@ class Server extends BaseModel { return $this->settings->is_reachable && $this->settings->is_usable; } + public function isDrainLogActivated() { + return $this->settings->is_logdrain_newrelic_enabled || $this->settings->is_logdrain_highlight_enabled || $this->settings->is_logdrain_axiom_enabled; + } public function validateConnection() { $uptime = instant_remote_process(['uptime'], $this, false); From 57738198ad67b77b0caac277bed6fd0ded61101f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Nov 2023 11:32:52 +0100 Subject: [PATCH 10/11] Add fluentd logging configuration for database & services --- app/Actions/Database/StartMariadb.php | 10 ++++++++++ app/Actions/Database/StartMongodb.php | 10 ++++++++++ app/Actions/Database/StartMysql.php | 10 ++++++++++ app/Actions/Database/StartPostgresql.php | 10 ++++++++++ app/Actions/Database/StartRedis.php | 10 ++++++++++ app/Jobs/ApplicationDeploymentJob.php | 1 - app/Models/Service.php | 10 ++++++++++ 7 files changed, 60 insertions(+), 1 deletion(-) diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.php index d42b53c09..3e32c2481 100644 --- a/app/Actions/Database/StartMariadb.php +++ b/app/Actions/Database/StartMariadb.php @@ -69,6 +69,16 @@ class StartMariadb ] ] ]; + if ($this->database->destination->server->isDrainLogActivated()) { + $docker_compose['services'][$container_name]['logging'] = [ + 'driver' => 'fluentd', + 'options' => [ + 'fluentd-address' => "tcp://127.0.0.1:24224", + 'fluentd-async' => "true", + 'fluentd-sub-second-precision' => "true", + ] + ]; + } if (count($this->database->ports_mappings_array) > 0) { $docker_compose['services'][$container_name]['ports'] = $this->database->ports_mappings_array; } diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.php index c1f1b71df..4ebbb9ec4 100644 --- a/app/Actions/Database/StartMongodb.php +++ b/app/Actions/Database/StartMongodb.php @@ -76,6 +76,16 @@ class StartMongodb ] ] ]; + if ($this->database->destination->server->isDrainLogActivated()) { + $docker_compose['services'][$container_name]['logging'] = [ + 'driver' => 'fluentd', + 'options' => [ + 'fluentd-address' => "tcp://127.0.0.1:24224", + 'fluentd-async' => "true", + 'fluentd-sub-second-precision' => "true", + ] + ]; + } if (count($this->database->ports_mappings_array) > 0) { $docker_compose['services'][$container_name]['ports'] = $this->database->ports_mappings_array; } diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.php index 4cf4282b6..c3f04dc9f 100644 --- a/app/Actions/Database/StartMysql.php +++ b/app/Actions/Database/StartMysql.php @@ -69,6 +69,16 @@ class StartMysql ] ] ]; + if ($this->database->destination->server->isDrainLogActivated()) { + $docker_compose['services'][$container_name]['logging'] = [ + 'driver' => 'fluentd', + 'options' => [ + 'fluentd-address' => "tcp://127.0.0.1:24224", + 'fluentd-async' => "true", + 'fluentd-sub-second-precision' => "true", + ] + ]; + } if (count($this->database->ports_mappings_array) > 0) { $docker_compose['services'][$container_name]['ports'] = $this->database->ports_mappings_array; } diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index 6eefd45ff..1acdcf957 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -79,6 +79,16 @@ class StartPostgresql ] ] ]; + if ($this->database->destination->server->isDrainLogActivated()) { + $docker_compose['services'][$container_name]['logging'] = [ + 'driver' => 'fluentd', + 'options' => [ + 'fluentd-address' => "tcp://127.0.0.1:24224", + 'fluentd-async' => "true", + 'fluentd-sub-second-precision' => "true", + ] + ]; + } if (count($this->database->ports_mappings_array) > 0) { $docker_compose['services'][$container_name]['ports'] = $this->database->ports_mappings_array; } diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php index a585678b3..0cbd01f63 100644 --- a/app/Actions/Database/StartRedis.php +++ b/app/Actions/Database/StartRedis.php @@ -78,6 +78,16 @@ class StartRedis ] ] ]; + if ($this->database->destination->server->isDrainLogActivated()) { + $docker_compose['services'][$container_name]['logging'] = [ + 'driver' => 'fluentd', + 'options' => [ + 'fluentd-address' => "tcp://127.0.0.1:24224", + 'fluentd-async' => "true", + 'fluentd-sub-second-precision' => "true", + ] + ]; + } if (count($this->database->ports_mappings_array) > 0) { $docker_compose['services'][$container_name]['ports'] = $this->database->ports_mappings_array; } diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 55dbefedd..25c6c879c 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -864,7 +864,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted ] ] ]; - ray($this->server->isDrainLogActivated()); if ($this->server->isDrainLogActivated()) { $docker_compose['services'][$this->container_name]['logging'] = [ 'driver' => 'fluentd', diff --git a/app/Models/Service.php b/app/Models/Service.php index 320d53ded..76c88eb85 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -797,6 +797,16 @@ class Service extends BaseModel $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik($this->uuid, $fqdns, true)); } } + if ($this->server->isDrainLogActivated()) { + data_set($service, 'logging', [ + 'driver' => 'fluentd', + 'options' => [ + 'fluentd-address' => "tcp://127.0.0.1:24224", + 'fluentd-async' => "true", + 'fluentd-sub-second-precision' => "true", + ] + ]); + } data_set($service, 'labels', $serviceLabels->toArray()); data_forget($service, 'is_database'); data_set($service, 'restart', RESTART_MODE); From ebc4ab9af5503d1effa5bc0783d286a6205a86c5 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 17 Nov 2023 11:33:46 +0100 Subject: [PATCH 11/11] Remove unnecessary ray() statement --- app/Http/Livewire/Server/LogDrains.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Livewire/Server/LogDrains.php b/app/Http/Livewire/Server/LogDrains.php index 4545e205f..cb7a5138a 100644 --- a/app/Http/Livewire/Server/LogDrains.php +++ b/app/Http/Livewire/Server/LogDrains.php @@ -68,7 +68,6 @@ class LogDrains extends Component { try { $ok = $this->submit($type); - ray($ok); if (!$ok) { return; }