Agent not picking up SENSU_CONFIG_FILE on initial start


I’m just doing a bit of a spike on Sensu-go. I’ve tried 6.0.0 and 6.1.0 both installed on AWS EC2 CentOS7.

I want to start the agent as a daemon so can’t use sensu-agent start -c /etc/sensu-go/agent.yml.

Is it possible to still use the agent.yml to configure? when I add the SENSU_CONFIG_FILE="/etc/sensu-go/agent.yml" to /etc/sysconfig/sensu-agent it isn’t being picked up?

I know sysconfig is reading the agent env variables as I’ve put SENSU_BACKEND_URL in there and that is being read fine.



1 Like

Hi there! Does the agent entity already exist? If so, could you try deleting the agent entity (via sensuctl or the web UI) and try again?

Sensu 6.0 introduced a change to agent entity management where agent.yml is only used for the agent entity initial configuration, and subsequent changes are managed via the API (or API clients like the CLI or web UI). So if the agent entity already exists, it could be that your agent is picking up SENSU_CONFIG_FILE but ignoring updates to certain fields.

I hope this helps!

Hi calebhailey,

The agent.yml file is created before the agent is started (using puppet for current install).

I can add and remove flags from /etc/sysconfig/sensu-agent, after the agent has started, such as name, namespace, etc. and once the service is restarted those changes are picked up.

None of the variables that are in agent.yml ever get picked up. So if I don’t define namespace in /etc/sysconfig/sensu-agent but do in /etc/sensu-go/agent.yml and start or restart, the agent goes back to to default.

Hope this explains better.

By default, the sensu-agent service reads configuration from the /etc/sensu/agent.yml file. And because that file path is specified using the -c switch, it probably overrides whatever value environment variable has.

Is there any specia reason that prevents you using the default /etc/sensu/agent.yml location for your configuration?

The only reason is were planning on running this side-by-side with classic Sensu. So to keep things separate would like to have a separate path.

Huh, it seems things changed since I last looked at the service file. There is no -c switch there anymore (at least in 6.1.0). So things should work if you place the proper environment variables. I will investigate this a bit more here while I am digging through this.

What you can do in the mean time is update the service file itself. Search for the ExecStart=/usr/sbin/sensu-agent start line in the /usr/lib/systemd/system/sensu-agent.service file and update it as needed.

1 Like

Looks like configuration file flag is treated differently from all other configuration flags and cannot be set via the environment variable ( So I guess the only option right now if you want to use custom configuration file is to modify the service file as I shown above.

1 Like


Thanks for the help, this seems a bit hacky to me!! I wonder if the will be fixed in later releases.

You will probably need to file a bug about this because I did not find an existing one that would address your situation.