diff --git a/infrastructure/config.alloy b/infrastructure/config.alloy new file mode 100644 index 000000000..af46d1192 --- /dev/null +++ b/infrastructure/config.alloy @@ -0,0 +1,56 @@ +// Copyright Dave Verwer, Sven A. Schmidt, and other contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +loki.process "system" { + forward_to = [loki.write.default.receiver] + + stage.docker { } + + stage.regex { + expression = "\\[component:\\s*(?P[\\w,-]+)\\]" + } + + stage.labels { + values = { + component = null, + } + } + + stage.drop { + // Drop Grafana logs so we don't do the "grep greps its own output"-thing + // https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/839 + expression = "caller=metrics.go:" + } +} + +loki.source.file "system" { + targets = [{ + __address__ = "localhost", + __path__ = "/var/log/*/*.log", + job = "containers", + }] + forward_to = [loki.process.system.receiver] + + file_match { + enabled = true + } + legacy_positions_file = "/tmp/positions.yaml" +} + +loki.write "default" { + endpoint { + url = "http://loki:3100/loki/api/v1/push" + } + external_labels = {} +} diff --git a/infrastructure/promtail.yml b/infrastructure/promtail.yml deleted file mode 100644 index 0980821ca..000000000 --- a/infrastructure/promtail.yml +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright Dave Verwer, Sven A. Schmidt, and other contributors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -server: - http_listen_port: 9080 - grpc_listen_port: 0 - -positions: - filename: /tmp/positions.yaml - -clients: - - url: http://loki:3100/loki/api/v1/push - -scrape_configs: - - job_name: system - static_configs: - - targets: - - localhost - labels: - job: containers - __path__: /var/log/*/*.log - pipeline_stages: - - docker: {} - - regex: - expression: "\\[component:\\s*(?P[\\w,-]+)\\]" - - labels: - component: - - drop: - # Drop Grafana logs so we don't do the "grep greps its own output"-thing - # https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/839 - expression: "caller=metrics.go:" diff --git a/mon.yml b/mon.yml index 62cb52103..780864697 100644 --- a/mon.yml +++ b/mon.yml @@ -51,14 +51,13 @@ services: - app_backend - promtail: - # https://github.com/grafana/loki/releases - # (promtail is released in parallel with loki) - image: grafana/promtail:3.5.1 - command: -config.file=/promtail.yml + alloy: + # https://github.com/grafana/alloy/releases + image: grafana/alloy:v1.15.1 + command: run /config.alloy configs: - - source: promtail_cfg - target: /promtail.yml + - source: alloy_cfg + target: /config.alloy volumes: - /var/lib/docker/containers:/var/log networks: @@ -129,8 +128,8 @@ services: configs: loki_cfg: file: ./infrastructure/loki.yml - promtail_cfg: - file: ./infrastructure/promtail.yml + alloy_cfg: + file: ./infrastructure/config.alloy prometheus_cfg: file: ./infrastructure/prometheus.yml