From 0c475419c6e1b73666f656e813d6ddd80e91bfa1 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Wed, 3 Apr 2024 16:27:49 +0900 Subject: [PATCH 1/2] Delete unnecessary `Promtail` config. --- .../nginx/templates/etc/promtail/nginx.yaml | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 cookbooks/nginx/templates/etc/promtail/nginx.yaml diff --git a/cookbooks/nginx/templates/etc/promtail/nginx.yaml b/cookbooks/nginx/templates/etc/promtail/nginx.yaml deleted file mode 100644 index 0287fce..0000000 --- a/cookbooks/nginx/templates/etc/promtail/nginx.yaml +++ /dev/null @@ -1,79 +0,0 @@ -server: - disable: true - -positions: - filename: /var/opt/promtail/promtail_nginx_position.yaml - -clients: - - url: http://<%= @LOKIENDPOINT %>/loki/api/v1/push - - -scrape_configs: - - job_name: nginx-access - static_configs: - - targets: - - localhost - labels: - job: nginx - hostname: <%= @HOSTNAME %> - __path__: /var/log/nginx/*access.log - - pipeline_stages: - - match: - selector: '{job="nginx"}' - stages: - - regex: - expression: "^time:(?P[^\t]+)\thost:(?P[^\t]+)\tforwardedfor:(?P[^\t]+)\tmethod:(?P[^\t]+)\tpath:(?P[^\t]+)\tprotocol:(?P[^\t]+)\tstatus:(?P[^\t]+)\tsize:(?P[^\t]+)\treferer:(?P[^\t]+)\tua:(?P[^\t]+)\ttaken_sec:(?P[^\t]+)\tbackend:(?P[^\t]+)\tbackend_status:(?P[^\t]+)\tcache:(?P[^\t]+)\tbackend_runtime:(?P[^\t]+)\tvhost:(?P[^\t]+)$" - - - timestamp: - source: timestamp - format: 02/Jan/2006:15:04:05 -0700 - - - template: - source: level - template: '{{ .status }}' - - - template: - source: level - template: '{{ regexReplaceAllLiteral "(1|2|3)[0-9]+" .Value "info" }}' - - - template: - source: level - template: '{{ regexReplaceAllLiteral "4[0-9]+" .Value "warning" }}' - - - template: - source: level - template: '{{ regexReplaceAllLiteral "5[0-9]+" .Value "error" }}' - - - labels: - hostname: - level: - vhost: - - - job_name: nginx-error - static_configs: - - targets: - - localhost - labels: - job: nginx - hostname: <%= @HOSTNAME %> - level: error - __path__: /var/log/nginx/*error.log - - pipeline_stages: - - match: - selector: '{job="nginx"}' - stages: - - regex: - expression: '^(?P[0-9\/]+ [0-9:]+) \[(?P[^ ]+)\] (?P.+), host: "(?P[^"]+)"(?P.*)$' - - - timestamp: - source: timestamp - format: 2006/01/02 15:04:05 - location: Asia/Tokyo - - - labels: - vhost: - - - output: - source: message -- 2.40.1 From 302cc2fa289fb7afe6e7db722b143fff91a981e4 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Wed, 3 Apr 2024 16:28:20 +0900 Subject: [PATCH 2/2] Delete unnecessary `systemd` config for `Promtail`. --- .../files/lib/systemd/system/promtail-nginx.service | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 cookbooks/nginx/files/lib/systemd/system/promtail-nginx.service diff --git a/cookbooks/nginx/files/lib/systemd/system/promtail-nginx.service b/cookbooks/nginx/files/lib/systemd/system/promtail-nginx.service deleted file mode 100644 index dc8c2b6..0000000 --- a/cookbooks/nginx/files/lib/systemd/system/promtail-nginx.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Grafana Promtail (nginx) -Documentation=https://github.com/grafana/loki -After=network-online.target - -[Service] -User=root -Restart=always -ExecStart=/usr/local/bin/promtail --config.file=/etc/promtail/nginx.yaml - -[Install] -WantedBy=multi-user.target -- 2.40.1