Hi,
I have installed the Grafana Agent in static mode in a linux machine and was configured for both metrics and logs monitoring. For logs monitoring, the following configuration is being used.
logs:
global:
clients:
- url: 'http://<loki_ip>:3100/loki/api/v1/push'
external_labels:
hostname: ${HOSTNAME}
configs:
- name: default
positions:
filename: /tmp/positions.yaml
scrape_configs:
- job_name: monitor_var_logs
static_configs:
- targets: [localhost]
labels:
job: var_logs
__path__: /var/log/*log
- job_name: monitor_messages
static_configs:
- targets: [localhost]
labels:
job: messages
__path__: /var/log/messages
I am not interested in hardcoding the hostname of the server as external label in Grafana Agent Configuration so I have added an external label with key value pair as mentioned for hostname.
The ${HOSTNAME} should reflect with the actual hostname of the server in Grafana Loki. However, it is displaying the same way (${HOSTNAME}) in Grafana Loki which is the same as in the Grafana Agent Configuration file. When I execute the bash command with the same echo ${HOSTNAME}
, I can see the hostname of the server.
In addition, I did tried with multiple predefined OS variables like $(hostname), $HOSTNAME, $(HOSTNAME), hostname
but nothing seems to be working. There are multiple servers I need to do the same configuration once this issue is fixed.
Can anyone help me to fix this issue ?