Skip to content

Instantly share code, notes, and snippets.

@grenade
Last active July 27, 2022 09:03
Show Gist options
  • Save grenade/c3d4d931a98a13c19457e41979900237 to your computer and use it in GitHub Desktop.
Save grenade/c3d4d931a98a13c19457e41979900237 to your computer and use it in GitHub Desktop.
auth_enabled: false
server:
http_listen_port: 3100
grpc_listen_port: 9096
common:
# path_prefix: /tmp/loki
# storage:
# filesystem:
# chunks_directory: /tmp/loki/chunks
# rules_directory: /tmp/loki/rules
# replication_factor: 1
ring:
instance_addr: 127.0.0.1
kvstore:
store: inmemory
schema_config:
configs:
- from: 2020-05-15
store: aws
object_store: s3
schema: v11
index:
prefix: loki_
storage_config:
aws:
s3: s3://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@${AWS_REGION}/${AWS_BUCKET}
dynamodb:
dynamodb_url: dynamodb://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@${AWS_REGION}
ruler:
alertmanager_url: http://localhost:9093
analytics:
reporting_enabled: false
[Unit]
Description=Grafana Loki Service
Wants=network-online.target
After=network-online.target
[Service]
User=root
Group=root
Type=simple
ExecStart=/usr/local/bin/loki-linux-amd64 --config.file=/etc/loki/config.yml
[Install]
WantedBy=multi-user.target
server {
server_name loki.pulse.pelagos.systems;
listen 443 ssl;
location / {
proxy_read_timeout 1800s;
proxy_connect_timeout 1600s;
proxy_pass http://127.0.0.1:3100;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
proxy_redirect off;
}
location /ready {
proxy_pass http://127.0.0.1:3100;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
proxy_redirect off;
}
ssl_certificate /etc/letsencrypt/live/pulse.pelagos.systems/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/pulse.pelagos.systems/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
#!/usr/bin/env bash
# usage:
# curl -sL https://gist.github.com/grenade/c3d4d931a98a13c19457e41979900237/raw/pulse-grafana-loki-install.sh | bash
AWS_ACCESS_KEY_ID=$(pass manta/aws/loki/aws_access_key_id)
AWS_SECRET_ACCESS_KEY=$(pass manta/aws/loki/aws_secret_access_key)
AWS_REGION=eu-central-1
AWS_BUCKET=manta-infra-logs
ssh pulse.pelagos.systems "
[ -s /tmp/loki-linux-amd64.zip ] || curl -sLo /tmp/loki-linux-amd64.zip https://github.com/grafana/loki/releases/download/v2.6.1/loki-linux-amd64.zip;
[ -x /usr/local/bin/loki-linux-amd64 ] || sudo unzip -o /tmp/loki-linux-amd64.zip -d /usr/local/bin;
[ -x /usr/local/bin/loki-linux-amd64 ] || sudo chmod a+x /usr/local/bin/loki-linux-amd64;
[ -d /etc/loki ] || sudo mkdir -p /etc/loki;
[ -s /etc/loki/config.yml ] || sudo curl -sLo /etc/loki/config.yml https://gist.github.com/grenade/c3d4d931a98a13c19457e41979900237/raw/grafana-loki-config.yml;
sudo sed -i 's/\${AWS_ACCESS_KEY_ID}/${AWS_ACCESS_KEY_ID}/g' /etc/loki/config.yml;
sudo sed -i 's/\${AWS_SECRET_ACCESS_KEY}/${AWS_SECRET_ACCESS_KEY}/g' /etc/loki/config.yml;
sudo sed -i 's/\${AWS_REGION}/${AWS_REGION}/g' /etc/loki/config.yml;
sudo sed -i 's/\${AWS_BUCKET}/${AWS_BUCKET}/g' /etc/loki/config.yml;
[ -s /etc/systemd/system/grafana-loki.service ] || sudo curl -sLo /etc/systemd/system/grafana-loki.service https://gist.github.com/grenade/c3d4d931a98a13c19457e41979900237/raw/grafana-loki.service;
systemctl is-active --quiet grafana-loki.service || sudo systemctl enable --now grafana-loki.service;
[ -s /etc/nginx/sites-available/loki.pulse.pelagos.systems.conf ] || sudo curl -sLo /etc/nginx/sites-available/loki.pulse.pelagos.systems.conf https://gist.github.com/grenade/c3d4d931a98a13c19457e41979900237/raw/loki.pulse.pelagos.systems.conf;
[ -L /etc/nginx/sites-enabled/loki.pulse.pelagos.systems.conf ] || sudo ln -sfr /etc/nginx/sites-available/loki.pulse.pelagos.systems.conf /etc/nginx/sites-enabled/loki.pulse.pelagos.systems.conf && sudo systemctl reload nginx.service;
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment