appoptics / appoptics-agent-docker

The AppOptics agent is now the SolarWinds Snap Agent! VISIT HERE: https://github.com/solarwinds/solarwinds-snap-agent-docker for the latest agent and updates.
https://github.com/solarwinds/solarwinds-snap-agent-docker
Apache License 2.0
4 stars 0 forks source link

Allow override of hostname as an environment variable #6

Closed cmrust closed 6 years ago

cmrust commented 6 years ago

When sending Host Agent metrics back to AppOptics they are tagged with the hostname from the container the agent is running in, rather than the actual hostname of the Node that they reflect.

In /opt/appoptics/etc/config.yaml we have the value hostname_alias to override the hostname being sent to AppOptics for Host Agent metrics.

It would be nice, if as an alternative to: plugins.publisher.publisher-appoptics.all.hostname_alias

We could instead apply hostname_alias with an environment variable such as APPOPTICS_HOSTNAME_ALIAS.

We can easily get the NODE_NAME in Kubernetes and set it as an environment variable, but there is not an easy way to get it into the config file for each pod.

As a workaround we could use an initContainer to read this ENV variable and manipulate the config before launching the AppOptics agent, but this is clunky, in my opinion.

alexouzounis commented 6 years ago

We should take a more holistic approach here. A common method is wrapping the agent start with an init script like runAgent.sh which can have things like if ${KUBERNETES} == true then sed the hostname in the config, turn on various plugins etc etc

cmrust commented 6 years ago

Good idea, I've introduced an init script in PR https://github.com/appoptics/kube-ao/pull/9