Does anyone know if there’s a lightweight way to q...
# general
r
Does anyone know if there’s a lightweight way to query host metadata from, say, a YAML file on a host or something similar?
An example could be metadata about a host that is generated at provisioning time, and written to a file on the host somewhere, that we could query as a table?
g
r
intriguing
thanks for the suggestion!
f
@Ryan If you do not want to deal with an extension you could simply write the metadata to a plist and use the built-in
plist
table
If you need it to be multi-platform you can create an augeas lens and ship that lens to your devices.
r
Ah that’s a nice one to know too, though these are Linux machines, not Mac.
f
Another multi-platform option is encode the data in a sqlite db and then create an ATC for that DB file
👍 1
r
Do you have any examples of an Augeas lens?
f
The ATC is probably the most simple option that is multi-platform
r
ah yeah, just reading about that now
very interesting!
thanks!
f
r
haha yes that’s the one I was reading 😄
f
😜 You beat me to it!
Good luck, let me know if you have any questions.
r
heheh
thanks, yeah this looks very powerful/flexible
d
If you are just targeting Linux, you could write out the info you need to a sysctl parameter at deployment and then query it with the https://osquery.io/schema/5.0.1/#system_controls table
To be clear, havent tried it myself but I would think it should work
s
Or use a directory with cleverly named files as a rudimentary key/value store.
👍 1
There are some ways you can get pretty clever
2
m
Environment variables also work to stash and retrieve stuff but might not be great if you have a lot of stuff
r
Environment variables? Do you have an example of that approach?
m
Yup I put some values in environment variables and I have queries like:
Copy code
Windows: SELECT value FROM default_environment WHERE variable LIKE "%environment_variable_name_here%" LIMIT 1
Copy code
Ubuntu/Centos/Darwin: SELECT value FROM process_envs WHERE key LIKE "%environment_variable_name_here%" LIMIT 1
So I can set these environment variables on any device and fetch them with a query, if you control the metadata you would write it to envars instead of a file and fetch like that easy enough, but I don't know if there is size limits or what.
This allows me to tag my hosts with like a company id and such that I can query. I then put the company name in a decorator query so I know which company the host belongs to for every query it responds to.
r
Ok, sounds interesting!
When you talk about decorator queries, that’s the same as creating a label in Fleet interface or via Fleetctl right?
m
@Ryan nah labels in fleet return groups of hosts. A decorator query in osquery is a query that executes with every single query so for every query in my case it returns username, hostname and company name fetched from the envvar and it includes that with every single query executed
r
ahhh right, gotcha @Mystery Incorporated that’s very handy actually 🙂
👍 1