-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExecStartPre and EnvironmentFile settings to system unit file #157
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I don't see anything wrong with adding this I wonder if it's perhaps too niche to be special variables?
Perhaps it would be more useful to add a variable grafana_agent_service_extra
which accepts arbitrary options to the systemd unit?
I think that's a great idea. I was also considering setting |
Add grafana_agent_service_extra
I've updated the implementation. To ensure the functionality aligns with our expectations, I defined the following variables and tested the behavior:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I propose adding the capability to configure ExecStartPre and EnvironmentFile in the system unit file. This enhancement allows us to dynamically define variables before running the Grafana Agent, enabling their use in config.yaml.
For example, this change makes it possible to fetch EC2 tags and use them as labels for metrics.
Below is an example script that retrieves the instance ID, queries for the project tag associated with that EC2 instance, and writes it to an environment file. This tag is then used as an external label in metrics configuration.
This environment variable is then referenced in the config.yaml for the Grafana Agent as shown below: