Reputation: 79
I try to configure a promtail that tails a log where different servers write. I'd like to define a static label for loki called "hostname" where hostname is a value taken from the log line.
scrape_configs:
- job_name: drupal
static_configs:
- labels:
job: "drupal"
tag: PREFIX-whatever
hostname:
__path__: /var/log/mylog/promtail-drupal.log
log line is in json format and has this key, value pair.
I've tried many things, including relabel, but it doesnt work, promtail just sent it empty to loki. Is there a way to to that? (I know from loki doc that we should avoid having too much possibility for a static label.)
Upvotes: 0
Views: 3682
Reputation: 22511
Try the following:
scrape_configs:
- job_name: drupal
static_configs:
- json
expressions:
hostname: hostname
- labels:
job: "drupal"
tag: PREFIX-whatever
hostname:
__path__: /var/log/mylog/promtail-drupal.log
More info at Loki documentation here and here.
Upvotes: 2