This message originated from Cribl Community Slack.
Click here to view the original link.
I can't figure out how to use an environment variable that has been set in collector script running a python script.
I have tried prefixing the environment variable with $, using just the variable name as set, using envVar., c.Vars. as well as a few other ways. Why isn't this documented somewhere? A screenshot of my env variables and their use in the python script are provided in the graphic below.
Links for this message:
image.png
Solved
Python Script Fails To Access Environment Variable Set In Collector Script
Best answer by Jon Rust
If you were using bash (or similar shell) you could reference them with $VARNAME. Since you're using python, you'll need some extra work. I think the os module is needed?
import os
somename = os.environ.get("MY_ENV_VAR","default_value_here_in_case_undefined")
print(somename)
Edit: cleaned up the python callEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.
