Beats (Metricbeat) config not accepting environment variables


#1

Hi,
We are using Env Vars in our metricbeat.yml file but they are not getting picked up when restarting the service. Metricbeat 5.1.1.

This is basically the same question as answered here:

But...we are exporting the Env Var just before restarting the service and doing this under root (same user that metricbeat service is running under).

fields:
   field1: ${THEFIELD}```

```sudo su
export THEFIELD=thevalue
service metricbeat restart```


>Exiting: error unpacking config data: missing field accessing 'fields.field1' (source:'/etc/metricbeat/metricbeat.yml')
   ...fail!

Any ideas?

(Steffen Siering) #2

is the service command really picking up environment variables? Looks like service is actually dropping environment variables when starting daemons.


#3

Thanks Steffen you are right. I misunderstood the behaviour of the service command. The metricbeat doc states

After changing the value of an environment variable, you need to restart Metricbeat to pick up the new value.

What is best practice for restarting Metricbeat if we cannot use the service command?


(Steffen Siering) #4

I wouldn't use an environment variable here. The problem with service startup is, is your environment variable already available by init-process (most likely not).

Either update your config file or the startup script.

See google


(system) #5

This topic was automatically closed after 21 days. New replies are no longer allowed.