ES password containing comma can't be passed as environment variable

I'm passing the password as environment variable to heartbeat.yml on ES 7.16.1 as follows:

heartbeat.yml:

output:
  elasticsearch:
    password: '${ELASTICSEARCH_PASSWORD}'

When using ELASTICSEARCH_PASSWORD="foo,bar" the value is parsed as an object instead of a string (I assume due to the comma being treated as separator?) and throws an error Exiting: error initializing publisher: can not convert 'object' into 'string' accessing 'output.elasticsearch.password' (source:'/app/heartbeat.yml'). However, the same configuration works fine when no comma is used.

Interestingly enough, when I use the following configuration with a hardcoded password containing a comma it works just fine:

output:
  elasticsearch:
    password: 'foo,bar'

How can I tell the config to treat the comma as a literal comma?

Hi @BitPatty,

Thank you for your first post and welcome to the community!

An environment variable containing a , makes the value as list (a complex value). Please see.

You can go around this by wrapping your env var's value in escaped double quotes so that the parser treats it as a string e.g.

ELASTICSEARCH_PASSWORD='"foo,bar"'
2 Likes