$util.insights.get Returns "No Value"

I am inserting a custom value when a synthetic check is run. When I query it using NRQL like below,

FROM SyntheticCheck SELECT latest(custom.metricname) WHERE monitorName = “MonitorName”

It is showing the latest value. But when I use $util.insights.get(“metricname”) in a synthetic script it returns a null value. I can see “No Value” rows when I execute below NRQL also,

FROM SyntheticCheck SELECT custom.metricname WHERE monitorName = “MonitorName”

Is there anyway to retrieve the actual latest value instead of a Null value using $util.insights.get(“metricname”) ?

You are setting and getting the same value within a synthetic?

Yeah, I’m getting the old(previous value) 1st and then setting the new value afterwards in the synthetics script. setting part is working fine. when getting it is returning “Null”(No value) most of the time.

Maybe someone else can correct me, but if you are setting and getting this value at runtime you need to use the key name. But if you are doing this maybe it simply makes sense to keep your value in a variable of the script and then set it at completion?

1 Like

Yeah, that is what I am doing currently. My issue is, there are empty values for the same key which automatically added. So when I get the value, most of the time it is getting Null value.

You are sort of mixing things in your first post. If you are setting and getting values in the synthetic those values are not going to be available to insights until the end of the synthetic check run.

If within the synthetic run you set a metric with a key value pair and then try to get the value you just set using the key you used previously it should return the value.

1 Like

Sorry if I am not clear on this. Below is what I’m actually trying to achieve,
I need to set a new value to a custom variable from the synthetic script. Then I need to get the old value of that custom variable from insight(I do not want the new value here, I need the value which was set in the previous execution of the synthetic script).

As you explained in the second part, I’m trying to do that. But New Relic is returning me null values. The reason for that is I can see “No Value” fields in insight when I query the custom variable data, but I’m not setting such kind of this from synthetic script, but those are added automatically.

Sorry, still not clear really. Let me see if I understand.

On each run of your synthetic you fetch an attribute value from the most recent previous run of the same synthetic. You do this using an insights query. Within the script you are then storing this in the custom attribute straight away and then somewhere along the execution of the synthetic you then update that custom attribute again or maybe you try to compare or something?

ok, don’t do that maybe :slight_smile:

Make sure your insights query is working. If you don’t set a time range, use latest or have multiple sites or expect to fetch the data with very little time between runs you may have a problem.

Personally, I would not use the custom attribute of the check as a variable storage during the run. I’d only set it at the end of the run or only once.

1 Like

When I set a custom metric to insight using a synthetic script browser, it is creating a new column with the name of the custom metric key in SyntheticChecks table. Since I’m only setting that value in one synthetic script, other synthetic scripts are setting that metric as ‘No Value’ in SyntheticChecks table. That is why I can see ‘No Value’ fields using insight query and $util.insights.get method. So it is not possible to use get method in this case.

What I did is, I’m setting the value using $util.insights.set() method but I’m using API calls in Scripted browser to query insight data. This way I can specifically query the data for the correct monitor name and it will not return any Null or No Values.

So be to be clear if you want a value from a previous run you can use api calls to get that from insights. If within a script you set an attribute value that value is not posted to insights until your check is complete. It is not available in insights during the run.