Speeding up API and session relevance queries

I’m querying BigFix using the API and session relevance, but the results are taking about 1 minute to retrieve. We have about 15k endpoints (between desktops and servers) and I’m wondering if there is a way to optimize my query or if it’s just that slow.

Here is a perl script I use with the RelevanceRequest.pm file provided by IBM that takes about 55 seconds to complete:

#!/usr/bin/perl
use lib '/var/www/cgi-bin/libs';
use RelevanceRequest;

my $relRequest = new RelevanceRequest('http://my.bigfix.server/webreports', 'apiuser', 'apipass');

my $query = '(name of computer of it,values of it) of results from (bes properties whose (name of it = "IP Address")) of members of bes computer groups whose (id of it = 494)';
# my $query = '(name of it, ((concatenation " : " of values of it as string | "") of results from (bes properties whose (name of it = "IP Address")) of it)) of members of bes computer groups whose (name of it = "UNIX_COMPUTERS")';

my @computerNames = $relRequest->evalRel($query) ;

print join("\n" ,@computerNames );

print "\n";

I also have a bash script that uses the api/query?relevance=… and it also takes about the same amount of time to return results.

#!/bin/bash

ApiUrl=https://my.bigfix.server:52311/api/query

DirtyRelevance='(name of computer of it,values of it) of results from (bes properties whose (name of it = "IP Address")) of members of bes computer groups whose (id of it = 494)'
CleanRelevance=$(python -c "import urllib; print urllib.quote('''$DirtyRelevance''')")

curl -s --insecure --basic --user apiuser:apipass -G --data "relevance=$CleanRelevance" $ApiUrl

So, does anyone see any way to possibly optimize this relevance to return the results in a more timely fashion or see anything I’m just outright doing wrong?

The form that you are using is this:

result from <bes property> of <bes computer>: bes property result

Please try these instead:

result <( bes property, bes computer )>: bes property result
result <( bes computer, bes property )>: bes property result

So your statement will look like this:

(name of computer of it, values of it) of results (
    bes properties whose (name of it = "IP Address"),
    members of bes computer groups whose (id of it = 494)
) 

If “IP Address” is unique and you don’t have duplicate properties with the same name, also try this to see if it is even faster:

(name of computer of it, values of it) of results (
    bes property "IP Address",
    members of bes computer groups whose (id of it = 494)
) 
1 Like

So, this is absolutely amazing. My query went from around 1+ minutes to less than 5 seconds.

I’m still trying to sort out exactly how the grouping/ordering of the relevance changes the processing, but I just wanted to say thanks @leewei for this.

1 Like

Read here: The way Session Relevance statements (WebReports) are written matters

And here: The way Session Relevance statements are written matters (Part 2) Computer Names

The way the original query was written involved much more processing.

You can actually use something like this even if there are duplicate properties with the same name. See here: https://bigfix.me/relevance/details/3004748

bes properties "Last Check" whose("Intel vPro Audit - Windows" = unique value of names of source analyses of it)

Related: