One of the concepts you will find repeated throughout Foglight is “scope”. You will find mention of scope when scripting, in rule definitions, rule conditions, even derived metrics. But what is scope?
Generally speaking, scope means “the object we’re currently working with” in rule conditions you may see statements like “scope.get(“name”)is tells Foglight to go and get the property “name” from the object we’ve given to it to work with. That use of scope is fairly straight forward, but how does Foglight know what the scoping object is? Ladies and Gentleman, I give you my ridiculous metaphor for scope:
Foglight Consultant Configuring Rules
I know, I’ve had too many espresso’s, but bear with me, this really does make sense. Go and look at the definition of any rule in Foglight and you will see a scoping query at the bottom of the screen. These usually take a form similar to SQL syntax, for example to get all windows system information from a host called “Lee-has-lost-it” the scoping query might read:
Windows_system where monitoredHost.name=’Lee-has-lost-it’
This query is used by the rules engine to find any data that needs to be evaluated against the rule, if it passes the test then it gets to the next stage (the rule conditions) and we can use queries like scope.get to get data from our windows_system table.
That explanation took alot of words, so when I’m teaching a class, I usually stand up, regress to a childlike state and explain it like this:
Agents send in data to Foglight, once there the rules engine grabs it and sees what rules are relevant, if the blocks of data fall through the holes they are within scope for that rule, and our conditions can be evaluated (these are inside of the box, and can’t be seen).
Although a little clumsy (and not the best mental model for scope for every sitation) I find it sometimes helps to ask people new to Foglight “what blocks are in the box right now?” when they are struggling to find out where to get data from. Of course it usually helps if I explain this toybox idea to them first, I learned that the hard way…
There are a few different metaphors for scope out there in the field, although not all of them give you a prime excuse for visiting toys ‘r’ us, but I’d love to hear any more anyone else has heard, what do you use for your mental model of scope?