# Agent not picking up SENSU\_CONFIG\_FILE on initial start

**URL:** <https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096>\
**Category:** Sensu Go\
**Created:** [October 19, 2020, 2:01pm UTC](https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096 "2020-10-19T14:01:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon71](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/simon71/32/481_2.png) [@simon71](https://discourse.sensu.io/u/simon71)\
**Post date:** [October 19, 2020, 2:01pm UTC](https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096/1 "2020-10-19T14:01:37Z")

</div>

Hi,

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.

Thanks

Simon

---

<div class="post-metadata">

**Author:** ![calebhailey](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/calebhailey/32/46_2.png) [@calebhailey](https://discourse.sensu.io/u/calebhailey)\
**Post date:** [October 19, 2020, 2:44pm UTC](https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096/2 "2020-10-19T14:44:02Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![simon71](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/simon71/32/481_2.png) [@simon71](https://discourse.sensu.io/u/simon71)\
**Post date:** [October 19, 2020, 2:56pm UTC](https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096/3 "2020-10-19T14:56:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tadeboro](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/tadeboro/32/428_2.png) [@tadeboro](https://discourse.sensu.io/u/tadeboro)\
**Post date:** [October 19, 2020, 4:57pm UTC](https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096/4 "2020-10-19T16:57:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![simon71](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/simon71/32/481_2.png) [@simon71](https://discourse.sensu.io/u/simon71)\
**Post date:** [October 19, 2020, 5:28pm UTC](https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096/5 "2020-10-19T17:28:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tadeboro](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/tadeboro/32/428_2.png) [@tadeboro](https://discourse.sensu.io/u/tadeboro)\
**Post date:** [October 19, 2020, 5:38pm UTC](https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096/6 "2020-10-19T17:38:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tadeboro](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/tadeboro/32/428_2.png) [@tadeboro](https://discourse.sensu.io/u/tadeboro)\
**Post date:** [October 19, 2020, 5:52pm UTC](https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096/7 "2020-10-19T17:52:50Z")

</div>

Looks like configuration file flag is treated differently from all other configuration flags and cannot be set via the environment variable ([https://github.com/sensu/sensu-go/blob/793a91af381d0cfe99d8e85510f7cd5c99c36fe7/agent/cmd/start.go#L220](https://github.com/sensu/sensu-go/blob/793a91af381d0cfe99d8e85510f7cd5c99c36fe7/agent/cmd/start.go#L220)). 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.

---

<div class="post-metadata">

**Author:** ![simon71](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/simon71/32/481_2.png) [@simon71](https://discourse.sensu.io/u/simon71)\
**Post date:** [October 19, 2020, 6:52pm UTC](https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096/8 "2020-10-19T18:52:38Z")

</div>

tadeboro,

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

---

<div class="post-metadata">

**Author:** ![tadeboro](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/tadeboro/32/428_2.png) [@tadeboro](https://discourse.sensu.io/u/tadeboro)\
**Post date:** [October 19, 2020, 7:37pm UTC](https://discourse.sensu.io/t/agent-not-picking-up-sensu-config-file-on-initial-start/2096/9 "2020-10-19T19:37:43Z")

</div>

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