Relevance to retrieve property values for a given computer

I am looking at using the API to do a spot check to return the values of one or more properties within an analysis. I want to feed the computer name into the URL so that only values for that computer name are returned.

As an example, this query returns the desired results for all machines however it hits a memory limit and crashes. How can I limit this query to only return results for one computer?

https://BesServer:52311/api/query?relevance=((values+of+it,+name+of+computer+of+it)+of+results+of+it,+names+of+it+)+of+properties+of+bes+analysis+whose+(name+of+it+is+%22AnalysisName%22)

I have tried a few things like the following:
https:/BesServer:52311/api/query?relevance=((values+of+it,+name+of+computer+whose+name+of+it+as+string+as+uppercase+equals+%22ComputerName%22)+of+results+of+it,+names+of+it)+of+properties+of+bes+analysis+whose+(name+of+it+is+%22AnalysisName%22)

but getting ā€œItā€ used outside of ā€œwhoseā€ clause.

Any ideas what I need to change to get this working?

Firstly, it is easier to develop and debug the session relevance and then plug it into the API call. I use the session relevance tester, but other options are available.

You should read this Efficient Session Relevance Query for Computer Properties and the other threads linked from it to get hints on retrieving the information you want in an efficient manner.

1 Like

Thanks - Iā€™ve read through the links you provided and also attempted to use the BigFix Session Relevance Tester. Itā€™s configured but only seems to return ā€œError: This expression could not be parsedā€.

Unfortunately the information has not helped me. Iā€™ve written relevance before to evaluate actions but never to retrieve data from an analysis like this. Iā€™d prefer to get the data directly from the API but my second option would be to get web reports to dump the data into a flat file on a network share. I will then pick that up and load it into a dataframe/datagrid and find what Iā€™m looking for.

How can I fix the relevance above to retrieve the information for one computer, not all the computers in the site?

I have an analysis with two properties, I would like to retrieve the value of one or both of those properties, for one computer only for which I would parse the computer name into the relevance which will form the API call URL.

Also, putting in my relevance above which work with the API gives Error: Singular expression refers to nonexistent object when I run it through the session relevance tester.

Pardon my ignorance - I work with 2 or 3 different programming language, 2 enterprise MDM solutions, multiple REST APIs and other enterprise applications, I donā€™t have the capacity to be a BigFix guru.

I also get a lot of this from the API when trying to work this out

Plural

When using the Session Relevance Tester, or the /webreports?page=QNA page, you donā€™t URL-encode the query. The URL-encoding is usually handled by the scripting language or programming tool (even CURL with the --data-urlencode option), you only need to do the URL-encoding when you are using the browser address bar to send a query.

Your un-encoded query to start with is then

((values of it, name of computer of it) of results of it, names of it ) of properties of bes analysis whose (name of it is "AnalysisName")

You can get the ā€œSingular Expression refers to nonexistent objectā€ because you refer to the singular ā€œname of computer of itā€. In some cases this query might retrieve a computer that has not reported itā€™s computer name and would throw the error. You can avoid that by using the plural 'names of computers of it (which discards the whole result row for a missing computer name), or use the pipe operator ā€˜|ā€™ to replace the value where an error is thrown, ie

((values of it, name of computer of it | "Name not reported") of results of it, names of it ) of properties of bes analysis whose (name of it is "AnalysisName")

You may also filter to only the computers you want by using a whose() clause on the 'bes property results objects

((values of it, name of computer of it | "Name not reported") of results whose (name of computer of it = "My computer name") of it, names of it ) of properties of bes analysis whose (name of it is "AnalysisName")

That should get the results you want, but it can still be made more efficient. For each of these properties, this query loops through every result before filtering down to the computer in which you are interested. For a lot of properties with a lot of results, that can get pretty slow. Think of it as a SQL query, where you can get great efficiency gains by filtering as early as possible before performing a JOIN. The blog post on ā€œefficient property retrievalā€ posted earlier is a great resource.

By building a set of the BES Properties and a set of the BES Computers we want, first, we can look specifically for the results between that computer for that property, instead of looping through the results for every computer. We could look for a single computer instead of building a set of BES Computers in this case (since there should only be one element to the set), but I like this pattern because it allows flexibility in changing from one computer, to a computer group, or computername patterns, and is easier to modify.

(value of it, name of computer of it | "ComputerName not reported", name of property of it) of (results (elements of item 0 of it, elements of item 1 of it)) of (set of bes computers whose (name of it = "MyComputerName"), set of properties of bes analysis whose (name of it is "BES Component Versions"))
1 Like

I really appreciate your response to this Jason. The following worked perfectly:

https://BesServer:52311/api/query?relevance=((values+of+it,+name+of+computer+of+it+|+ā€œName+not+reportedā€)+of+results+whose+(name+of+computer+of+it+=+ā€œCOMPUTER_NAMEā€)+of+it,+names+of+it+)+of+properties+of+bes+analysis+whose+(name+of+it+is+ā€œANALYSIS_NAMEā€)

There are only 10 properties and the query returns in less than a second.
Iā€™ll now work on writing some code around the API call to parse the information thatā€™s returned.

Once again, thank you very much for your response.

2 Likes