appscope
appscope copied to clipboard
For Cloud: Watch entries become an additive list
Notes from the Cloud operations team:
I learned something about scope.yml syntax. We had this in our config: event: watch: - type: file name: /opt/cribl/log/.* value: .* - type: file name: /opt/cribl_data/cribl_volume_dir/log/.* value: .*
That doesn't work, but this does: event: watch: - type: file name: (/opt/cribl/log/.)|(/opt/cribl_data/cribl_volume_dir/log/.) value: .*
It seems that having 2 file watches in the list causes the first one to be ignored. In our second attempt to the best/most correct way to accomplish what we want?
I really hate YAML, but one of the benefits in can provide is increasing the composability of a configuration.
In the schema for the file, watch is a list, "watch": [] if we were doing JSON. When I see a list, I assume I can put things in it without constraint. If I'm only allowed to have 1 item of type: file in my list, do I really have a list? Or do I actually have a map with type as the key?
Adding a new path to be monitored is a great example of where composability of a configuration file is important. Think about the difference is "change cost"/risk of editing an existing regular expression that controls what files are watched verses simply adding a new configuration object to a list of things that should be monitored.
The latter allows for additive changes to the configuration and lowers the risk of breaking anything that is currently working.
Thanks for attending my TED Talk on Configuration Syntax Preferences
There is valid concern around the performance impact of using multiple regexes. A suggestion is to internally concatenate all regexes, with an OR | separator ; so that the regex lookup will return results indexed by capture group.

The pseudo code for handling the results might look something like this:
regexes = ["(\/opt\/cribl\/log\/.*)", "(\/opt\/cribl_data\/cribl_volume_dir\/log\/.*)"]
values = ["foo", "bar"]
if (len(values) != len(regexes))
error
groups = regexlookup(concatenated regexes)
for (i = 0 , i < len(groups); i++)
search groups[i] looking for values[i]
put in queue