How to reference field value from Environment plugin?


(Jimmy Kang) #1

Hi Guys.

I am on logstash 1.5 and I'm trying to use environment plugin and then pass that field value to mongo as part of the URI for the password. This is mainly to mask the password so that it is not in plaintext in logstash.conf

filter {

	environment {
		add_field_from_env => {
			"mongopwd" => "mpwd"
		}
	}
}

This is my environment plugin setup. I have confirmed that mongopwd field is now referencing mpwd, the environment variable we set. So now mongopwd = "mypassword".

In output for mongodb I am trying to get the value of this field but the combinations i have tried all are not working.

		mongodb {
    		collection => "mydbcollection"
   	 		database => "mydb"
   	 		uri => "mongodb://user:%{mongopwd}@mymongodb"
		}

I have tried ${mongopwd}, mongopwd, [mongopwd] and none are working.

Is my syntax for referencing wrong or am I missing a step?


(Magnus Bäck) #2

Unfortunately the uri option isn't subject to %{fieldname} expansions. One reason could be that fields are event-specific and you don't want to risk reinitializing the connection for each event.


(Jimmy Kang) #3

Is there any way on logstash 1.5 for masking the password then?


(Magnus Bäck) #4

None that I can think of.


(system) #5

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