-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat: Add Loki to collect container logs #266
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
version: '2.1' | ||
|
||
x-logging: &default-logging | ||
options: | ||
tag: "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}" | ||
|
||
networks: | ||
monitor-net: | ||
driver: bridge | ||
|
@@ -30,6 +34,7 @@ services: | |
- monitor-net | ||
labels: | ||
org.label-schema.group: "monitoring" | ||
logging: *default-logging | ||
|
||
alertmanager: | ||
image: prom/alertmanager:v0.24.0 | ||
|
@@ -46,6 +51,7 @@ services: | |
- monitor-net | ||
labels: | ||
org.label-schema.group: "monitoring" | ||
logging: *default-logging | ||
|
||
nodeexporter: | ||
image: prom/node-exporter:v1.3.1 | ||
|
@@ -66,6 +72,7 @@ services: | |
- monitor-net | ||
labels: | ||
org.label-schema.group: "monitoring" | ||
logging: *default-logging | ||
|
||
cadvisor: | ||
image: gcr.io/cadvisor/cadvisor:v0.44.0 | ||
|
@@ -86,6 +93,7 @@ services: | |
- monitor-net | ||
labels: | ||
org.label-schema.group: "monitoring" | ||
logging: *default-logging | ||
|
||
grafana: | ||
image: grafana/grafana:9.0.5 | ||
|
@@ -105,6 +113,7 @@ services: | |
- monitor-net | ||
labels: | ||
org.label-schema.group: "monitoring" | ||
logging: *default-logging | ||
|
||
pushgateway: | ||
image: prom/pushgateway:v1.4.3 | ||
|
@@ -116,6 +125,29 @@ services: | |
- monitor-net | ||
labels: | ||
org.label-schema.group: "monitoring" | ||
logging: *default-logging | ||
|
||
loki: | ||
image: grafana/loki:2.6.0 | ||
expose: | ||
- 3100 | ||
volumes: | ||
- ./loki:/etc/loki | ||
command: -config.file=/etc/loki/loki-config.yaml | ||
networks: | ||
- monitor-net | ||
logging: *default-logging | ||
|
||
promtail: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing restart: unless-stopped |
||
image: grafana/promtail:2.6.0 | ||
volumes: | ||
- /var/lib/docker/containers:/var/lib/docker/containers:ro | ||
- /var/log:/var/log:ro | ||
- ./loki:/etc/promtail | ||
command: -config.file=/etc/promtail/promtail-config.yml | ||
networks: | ||
- monitor-net | ||
logging: *default-logging | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probablly this needs the monitoring label so it shows up with the other monitoring services in grafana? ((im adding this to my setup, don't have any authority here but thanks 👍 )) |
||
|
||
caddy: | ||
image: caddy:2.3.0 | ||
|
@@ -125,6 +157,7 @@ services: | |
- "9090:9090" | ||
- "9093:9093" | ||
- "9091:9091" | ||
- "3100:3100" | ||
volumes: | ||
- ./caddy:/etc/caddy | ||
environment: | ||
|
@@ -136,3 +169,4 @@ services: | |
- monitor-net | ||
labels: | ||
org.label-schema.group: "monitoring" | ||
logging: *default-logging |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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-10-24 | ||
store: boltdb-shipper | ||
object_store: filesystem | ||
schema: v11 | ||
index: | ||
prefix: index_ | ||
period: 24h | ||
|
||
limits_config: | ||
ingestion_rate_mb: 1024 | ||
ingestion_burst_size_mb: 1024 | ||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
server: | ||
http_listen_port: 9080 | ||
grpc_listen_port: 0 | ||
|
||
positions: | ||
filename: /tmp/positions.yaml | ||
|
||
clients: | ||
# replace "loki" with server address for external hosts | ||
- url: http://loki:3100/loki/api/v1/push | ||
|
||
scrape_configs: | ||
- job_name: system | ||
static_configs: | ||
- targets: | ||
- localhost | ||
labels: | ||
job: varlogs | ||
__path__: /var/log/*log | ||
|
||
- job_name: containers | ||
static_configs: | ||
- targets: | ||
- localhost | ||
labels: | ||
job: containerlogs | ||
__path__: /var/lib/docker/containers/*/*log | ||
|
||
pipeline_stages: | ||
- json: | ||
expressions: | ||
output: log | ||
stream: stream | ||
timestamp: time | ||
attrs: | ||
- json: | ||
expressions: | ||
tag: | ||
source: attrs | ||
- regex: | ||
expression: (?P<image_name>(?:[^|]*[^|])).(?P<container_name>(?:[^|]*[^|])).(?P<image_id>(?:[^|]*[^|])).(?P<container_id>(?:[^|]*[^|])) | ||
source: tag | ||
- timestamp: | ||
format: RFC3339Nano | ||
source: time | ||
- labels: | ||
tag: | ||
stream: | ||
image_name: | ||
container_name: | ||
image_id: | ||
container_id: | ||
- output: | ||
source: output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouln't the extension by yml