Last active
December 16, 2023 10:21
-
-
Save abhisekp/7b6246d250edef2d01e3c8caf4d05f14 to your computer and use it in GitHub Desktop.
Setup Portainer + Loki + Promtail + Grafana
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check https://docs.portainer.io/start/install-ce/server/docker/linux | |
# SSL: https://docs.portainer.io/advanced/ssl | |
docker volume create portainer_data | |
docker run -d -p 8000:8000 -p 9443:9443 -v ~/certs:/certs --name portainer --restart=always \ | |
-v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest \ | |
--tlsverify --tlscacert /certs/rootCA.pem --tlscert /certs/local_example.pem --tlskey /certs/local_example-key.pem --http-disabled --logo "https://avatars.githubusercontent.com/u/1029200?v=4" | |
# Help | |
docker run --rm -p 8000:8000 -p 9443:9443 -v ~/certs:/certs -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest --help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Video https://www.youtube.com/watch?v=eJtrxj9U_P8 | |
# Check https://grafana.com/docs/loki/latest/installation/docker/ | |
# Change /data/loki to any other directory where you store the downloaded config files. | |
# Create volumes for loki and grafana | |
docker volume create loki_data | |
docker volume create grafana_config | |
docker volume create grafana_logs | |
docker volume create grafana-storage | |
wget https://raw.githubusercontent.com/grafana/loki/v2.8.0/cmd/loki/loki-local-config.yaml -O loki-config.yaml | |
wget https://raw.githubusercontent.com/grafana/loki/v2.8.0/clients/cmd/promtail/promtail-docker-config.yaml -O promtail-config.yaml | |
# Change the "loki" network to "localhost" | |
#### COMPLETE ABOVE #### | |
docker run --restart=always --name loki --user "$(id -u)" -d -v loki_data:/loki -v /data/loki:/mnt/config -p 3100:3100 grafana/loki:2.8.0 -config.file=/mnt/config/loki-config.yaml | |
docker run --restart=always --name promtail --user "$(id -u)" -d -v /data/loki:/mnt/config -v /var/log:/var/log --link loki grafana/promtail:2.8.0 -config.file=/mnt/config/promtail-config.yaml | |
##### | |
# Check https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/ | |
docker run --restart=always -d -p 3000:3000 -v grafana_config:/etc/grafana -v grafana_logs:/var/log/grafana -v grafana-storage:/var/lib/grafana --user "$(id -u)" --name=grafana grafana/grafana-oss | |
# While adding Loki Datasource, use the internal IP provided by docker bridge network e.g. http://172.17.0.2:3100/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auth_enabled: false | |
server: | |
http_listen_port: 3100 | |
grpc_listen_port: 9096 | |
common: | |
instance_addr: 127.0.0.1 | |
path_prefix: /tmp/loki | |
storage: | |
filesystem: | |
chunks_directory: /tmp/loki/chunks | |
rules_directory: /tmp/loki/rules | |
replication_factor: 1 | |
ring: | |
kvstore: | |
store: inmemory | |
query_range: | |
results_cache: | |
cache: | |
embedded_cache: | |
enabled: true | |
max_size_mb: 100 | |
schema_config: | |
configs: | |
- from: 2020-10-24 | |
store: boltdb-shipper | |
object_store: filesystem | |
schema: v11 | |
index: | |
prefix: index_ | |
period: 24h | |
ruler: | |
alertmanager_url: http://localhost:9093 | |
# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration | |
# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/ | |
# | |
# Statistics help us better understand how Loki is used, and they show us performance | |
# levels for most users. This helps us prioritize features and documentation. | |
# For more information on what's sent, look at | |
# https://github.com/grafana/loki/blob/main/pkg/usagestats/stats.go | |
# Refer to the buildReport method to see what goes into a report. | |
# | |
# If you would like to disable reporting, uncomment the following lines: | |
#analytics: | |
# reporting_enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server: | |
http_listen_port: 9080 | |
grpc_listen_port: 0 | |
positions: | |
filename: /tmp/positions.yaml | |
clients: | |
- url: http://localhost:3100/loki/api/v1/push | |
scrape_configs: | |
- job_name: system | |
static_configs: | |
- targets: | |
- localhost | |
labels: | |
job: varlogs | |
__path__: /var/log/*log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment