-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
--client.external-labels=hostname=host1
does not work
#636
Comments
@daixiang0 someone just suggest me to use exiternal-labels in #634. So what should I use for that use case (want to quickly add different host labels for multiple hosts)? |
Just give a quick ask:
Do not think a good way to show different hostname in local mode, but in k8s, you can use
But i saw in the latest scrape confg:
|
@daixiang0 This requirement is mainly from non k8s env. Say, if I need to install promtail in lots of VMs, and I need to have their hostname as one of the labels or default labels. I checked the code, hostname's already in s.hostname (https://github.com/grafana/loki/blob/master/pkg/promtail/targets/filetargetmanager.go#L213), just not add into labels like However slim-bean suggested me to use external_labels to fulfill my original requirements, which I found it's not working at all. Moreover, after debug the code, I found the |
This config can work for local mode, please note that since you run at local, for each vm you need to run a promtail. need to dig to find the issue about external_labels. |
I know this can work, but not efficient in deploying for different hostname for different vms. need something like |
--client.external-labels=hostname=host1
does not work
@mizeng it will work if you use the single client config. Either by providing a We can't parse a set of label set via command line, so using a single client if your only option. |
@Kuqd could you share one example with both command line start up and the promtail config? |
@mizeng the clients config is as below:
you can set in config, that works for me. We can't parse common flag via command line if specify configfile at same time. |
@daixiang0 then how can I fulfill the requirement? paas variable to label? #634 |
never mind. Finally I figure it out.
|
@daixiang0 I need to query the logs by the hostname (with something like |
@minhdanh just need add --client.external-labels=hostname=${hostname} then do query. If still question, better to open a new issue to track it. |
Does not work in 1.5.0 (hostname or HOSTNAME are empty). |
This worked for me with v1.5:
Config:
|
Note: if not running under Kubernetes, the hostname should be specified as: ./promtail --client.external-labels=hostname=$(hostname) ... Notice the braces: regular, not curly. |
Hi, i'm also trying to use client.external-label throught Terraform but could not manage to make it work. Regarding vales.yaml, i try like below
Not sure if it should be something like
What would be best option here ? |
I found it much easier to take advantage of systemd's trusted journal fields, among which is scrape_configs:
- job_name: journal
journal:
max_age: 12h
labels:
job: systemd-journal
relabel_configs:
- source_labels: ["__journal__systemd_unit"]
target_label: "unit"
- source_labels: ["__journal__hostname"]
target_label: "hostname" |
Describe the bug
looks like ClientConfig and ClientConfigs are mis-used for promtail Config. The Command line configs including ExternalLabels are in ClientConfig, however Promtail only used ClientConfigs.
This will cause something like
./promtail --config.file=./docker-config.yaml --client.external-labels=hostname=host1
does not work. The external-labels is missing.To Reproduce
Steps to reproduce the behavior:
./promtail --config.file=./docker-config.yaml --client.external-labels=hostname=host1
Expected behavior
The label "hostname=host1" should show up in Loki.
Environment:
Screenshots, promtail config, or terminal output
If applicable, add any output to help explain your problem.
The text was updated successfully, but these errors were encountered: