Created
December 15, 2022 08:38
-
-
Save linxlunx/27c633e40a64e4c10e307e668fd41130 to your computer and use it in GitHub Desktop.
Promtail config and docker run
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
docker run -it --rm --name containerName -p 80:80 --log-driver json-file --log-opt tag="{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}" imageName:imageTag |
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_address: 0.0.0.0 | |
http_listen_port: 9080 | |
positions: | |
filename: /tmp/positions.yaml | |
clients: | |
- url: http://user:pwd@loki-host:loki-port/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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment