Add caching option to get_env_var() #914
Labels
type: feature
A value-adding code addition that introduce new functionality.
vrl: stdlib
Changes to the standard library
A note for the community
Use Cases
During metric processing, we started using Vector VRL's get_env_var() to pull environment variables and use them as feature flags. Unfortunately, we observed a significant spike in CPU and vector utilization when we used the following configuration:
This was applied to every metric. Now, we have decided to add this transformation only to the metrics that really need it (around 30% of all processed metrics), and we were able to save about 2-3 Kubernetes vCPUs (a drop from ~10 vCPUs to 7-8 vCPUs). Transform change was deployed around 13:15.

The problem started increasing when we added more than two environment variable checks.
Attempted Solutions
As I mentioned, we are currently trying to minimize the use of environment variable checks. Now, we are also experimenting with data enrichment. During container startup, we will render an enrichment table and add the data as extra tags during metric remapping.
Proposal
Is there any chance to support environment variable caching with a TTL? When using remap to check for very static environment variables like ENV and VERSION, which do not change during runtime, we could set a TTL to avoid querying the system each time we set the same variable. Reference.
References
No response
Version
0.37.0
The text was updated successfully, but these errors were encountered: