Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation about local installation #2103

Closed
cyriltovena opened this issue May 21, 2020 · 5 comments · Fixed by #2740
Closed

Documentation about local installation #2103

cyriltovena opened this issue May 21, 2020 · 5 comments · Fixed by #2740
Labels
help wanted We would love help on these issues. Please come help us!

Comments

@cyriltovena
Copy link
Contributor

The docs section for running Loki locally is not very well furnished see https://github.com/grafana/loki/blob/master/docs/installation/local.md

Would be great to have more on how to get up and running.

Windows and linux seems appropriate.

@cyriltovena cyriltovena added component/docs help wanted We would love help on these issues. Please come help us! keepalive An issue or PR that will be kept alive and never marked as stale. labels May 21, 2020
@rlex
Copy link
Contributor

rlex commented May 21, 2020

Just in case, i have ansible role here which i use for running simple one-node loki server: https://github.com/rlex/ansible-role-loki
There is also promtail role:
https://github.com/patrickjahns/ansible-role-promtail

@Daniel15
Copy link

Daniel15 commented May 21, 2020

@rlex Your Ansible role looks really good and is a good indication at what would be good to include in the docs:

  • A systemd unit. Ideally contained in the tar.gz file download so I could just mv loki.service /etc/systemd/system/loki.service && systemctl daemon-reload
  • A minimal config documented somewhere. The bare minimum configuration required for Loki to start, without any unnecessary boilerplate.

The docs should mention that a separate user should be created, for security reasons.

It would be really nice to have a Debian package for Loki so I could simply apt install loki and get a working installation that's configured correctly.

@sreyasvpariyath
Copy link

I followed this.
https://sbcode.net/grafana/install-loki-service/
And this
https://sbcode.net/grafana/install-promtail-service/

@Daniel15
Copy link

I followed this.
sbcode.net/grafana/install-loki-service

One major issue with that guide is that Loki ends up running as root. You should add User=loki to the systemd unit, and add a user called loki, for example by doing:

adduser --system loki --group --home /var/local/loki/

The other thing I'm curious about is that config-loki.yml file. It's very large. I wonder if all of those config items are needed, or if Loki has some defaults that can be omitted. That's some thing the Loki docs don't really clarify at the moment.

@slim-bean slim-bean removed the keepalive An issue or PR that will be kept alive and never marked as stale. label Oct 8, 2020
cyriltovena pushed a commit to cyriltovena/loki that referenced this issue Jun 11, 2021
…afana#2103)

* delete series api and purger to purge data requested for deletion

delete_store manages delete requests and purge plan records in stores
purger builds delete plans(delete requests sharded by day) and executes them paralelly
only one requests per user would be in execution phase at a time
delete requests gets picked up for deletion after they get older by more than a day

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* moved delete store creation from initStore to initPurger, which is the only component that needs it

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* implemented new methods in MockStorage for writing tests

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* removed DeleteClient and using IndexClient in DeleteStore

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* refactored some code, added some tests for chunk store and purger

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* add some tests and fixed some issues found during tests

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* changes suggested in PR review

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* rebased and fixed conflicts

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* updated route for delete handler to look same as prometheus

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* added test for purger restarts and fixed some issues

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* suggested changes from PR review and fixed linter, tests

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* fixed panic in modules when stopping purger

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* changes suggested from PR review

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* config changes suggested in PR review

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* changes suggested from PR review

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* updated config doc

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* updated changelog

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* some changes suggested from PR review

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* made init in Purger public to call it from modules to fail early

Signed-off-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>
@NINNiT
Copy link

NINNiT commented Sep 17, 2021

Here's a shell script we are using to install and update loki as a system service on Ubuntu/Debian systems. An official apt package would be really nice though!

## Loki Installation Script
## Author: NINNiT

# Installation Variables (change this to your liking)
LOKI_VERSION_TAG="v2.3.0"
LOKI_BINARY_PATH=/usr/local/bin
LOKI_CONFIG_PATH=/etc/loki

# color variables
GREEN_COLOR="\033[0;32m"
NC="\033[0m"

printf "${GREEN_COLOR}Installing dependencies...${NC}\n"
apt install wget unzip

# download binary archive
printf "${GREEN_COLOR}Downloading binary...${NC}\n"
wget https://github.com/grafana/loki/releases/download/${LOKI_VERSION_TAG}/loki-linux-amd64.zip

# download configuration file
printf "${GREEN_COLOR}Downloading configuration...${NC}\n"
wget https://raw.githubusercontent.com/grafana/loki/${LOKI_VERSION_TAG}/cmd/loki/loki-local-config.yaml

# unzip
printf "${GREEN_COLOR}Unzipping...${NC}\n"
unzip loki-linux-amd64.zip

# set exec permissions and move binary
printf "${GREEN_COLOR}Setting permissions...${NC}\n"
chmod +x loki-linux-amd64

printf "${GREEN_COLOR}Installing binary to ${LOKI_BINARY_PATH}...${NC}\n"
cp loki-linux-amd64 ${LOKI_BINARY_PATH}/loki

# installing config
printf "${GREEN_COLOR}Checking if a config already exists in ${LOKI_CONFIG_PATH}... ${NC}\n"
mkdir -p ${LOKI_CONFIG_PATH}
if test -f "${LOKI_CONFIG_PATH}/config.yaml"; then
    echo "${GREEN_COLOR}Configuration found, keeping old config... ${NC}\n"
    echo "${GREEN_COLOR}Installing new config to ${LOKI_CONFIG_PATH}/config-${LOKI_VERSION_TAG}.yaml... ${NC}\n"
    cp loki-local-config.yaml ${LOKI_CONFIG_PATH}/config-${LOKI_VERSION_TAG}.yaml
else
    echo "${GREEN_COLOR}No configuration found... ${NC}\n"
    echo "${GREEN_COLOR}Installing new config to ${LOKI_CONFIG_PATH}/config.yaml... ${NC}\n"
    cp loki-local-config.yaml ${LOKI_CONFIG_PATH}/config.yaml
fi

# create loki user
printf "${GREEN_COLOR}Creating loki user...${NC}\n"
useradd --system loki

# move systemd service file
printf "${GREEN_COLOR}Moving service file...${NC}\n"
cp loki.service /etc/systemd/system/

# reload daemons
printf "${GREEN_COLOR}Reload daemons...${NC}\n"
systemctl daemon-reload

# cleanup
printf "${GREEN_COLOR}Cleaning up...${NC}\n"
rm loki-linux-amd64*
rm loki-local-config.yaml*

And the systemd service file (keep this in the same directory as the installation script):

[Unit]
Description=Loki service
After=network.target

[Service]
Type=simple
User=loki
ExecStart=/usr/local/bin/loki -config.file /etc/loki/config.yaml

[Install]
WantedBy=multi-user.target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We would love help on these issues. Please come help us!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants