Hi all,
I’m using loki 1.5.0 + promtail 1.5.0 + grafana 7.0.0 with three docker containers.
All worked fine for normal log files (var/log/… or apache2).
I found this interesting URL:
But when I tried to extract labels via regex out of the apache2 logs I’m getting promtail errors like
promtail_1 | Unable to parse config: /etc/promtail/docker-config.yaml: yaml: line 24: did not find expected key
promtail_1 | Unable to parse config: /etc/promtail/docker-config.yaml: yaml: line 26: mapping values are not allowed in this context
That’s my promtail-config.yaml
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
url: http://loki:3100/loki/api/v1/push
# regex-example
# https://grafana.com/blog/2020/04/21/how-labels-in-loki-can-make-log-queries-faster-and-easier/
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
env: demo
__path__: /var/log/*log
- job_name: system (I ALSO SKIPPED THIS LINE)
pipeline_stages:
- regex:
expression: "^(?P<ip>\\S+) (?P<identd>\\S+) (?P<user>\\S+) \\[(?P<timestamp>[\\w:/]+\\s[+\\-]\\d{4})\\] \"(?P<action>\\S+)\\s?(?P<path>\\S+)?\\s?(?P<protocol>\\S+)?\" (?P<status_code>\\d{3}|-) (?P<size>\\d+|-)\\s?\"?(?P<referer>[^\"]*)\"?\\s?\"?(?P<useragent>[^\"]*)?\"?$"
- labels:
action:
status_code:
static_configs:
- targets:
- localhost
labels:
job: apache
env: dev
__path__: /var/log/apache2/access_log
I also tried ways like this:
pipeline_stages:
- match:
selector: ‘{job=“apache”}’
stages:
- regex:
expression: "above regex expression
- labels:
…
Perhaps anybody has an idea how to fix this?
Thanks, Uwe