How to set environment variables globally in metric beats

(Karthick Tgi) #1

How to set environment variables globally in metric beats.

For example,
In metric beat folder inside the mysql.yml file defaultlly its hard coded like
hosts: ["root:root@tcp(localhost:3306)/"]
username and password are root & root port-3306

Now i set username and password are globally inside the metricbeat . i can access this through in environemnt property file.

If you have any idea please share with us.

(Jaime Soriano) #2

Hi @karthick_tgi,

You can use environment variables in the configuration, take a look to the documentation page about this:

In your case you can modify the mysql.yml host entry to something like this:

    hosts: ['${MYSQL_USER}:${MYSQL_PASSWORD}@tcp(localhost:3306)/']

(Karthick Tgi) #3

Dear @jsoriano

Thanks for your quick reply.
Yes, as you mentioned we can achieve.

Our requirement is:
#1. Need to use 2 properties like below.

#2 From yaml/yml file need to access the MySql Host, Username and Password values from properties based on the env.

Please let me know if it is possible or not.
If possible then how can we achieve.


(Jaime Soriano) #4

Sorry, it is not possible to load environment variables from files using only metricbeat. For that you'd have to rely on the scripts or service managers you use to configure and start metricbeat.

(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.