Nrql querys is not update in my nerdlet personalized

I am creating a custom nerdlet in which every so often it must call a function that executes an nrql, well in the first load everything works fine but when making a new call of the aforementioned function the result obtained is not updated with the data that is find in the moment

What could be the problem?

Hey there! The preferred way to do that is within the render() method of your component using pollInterval in <NrqlQuery>.

For example, to update every 2000 milliseconds you could do something like:

<NrqlQuery pollInterval={2000} query={...} accountId={...}>
  {({data, loading}) => {
    return <>...</>

Hey! thanks for you answer in my case particulary i need consume nrqlquery in form of api something how this


Lew’s approach is the best really for that component.

But if you must do it this way then you might need to manage the polling yourself with a setInterval(). You would need to store the output of the query into state and wire it up to the component that relies on it so that it hydrates when the data changes.

Something like this perhaps:

this.nowAndThen = setInterval(() => {
    const myResult = await NrqlQuery.query(...)
    this.setState({ data:myResult })

If you do setup an interval make sure to tear it down when unmounting the component:

componentWillUnmount() {

Its probably not the best, but this approach worked for me here to auto-cycle pages based on a timer.

1 Like

Hey @jbuchanan2, thanks for you suggestion but regrettable its not work :frowning: because so i am trying consume api
in the interval that you mencionated but nrql api no update data

Hey @jgaona

Perhaps we’re missing something obvious here but the latest screenshot is the same screenshot as the first time.

In James’s example he’s providing a frequency to execute NrqlQuery.query on an interval. Did you attempt this code? If so where did it not function as desired.

When you say “because I am trying to consume api”. I assume that each internal you consume the information and do something interesting with it. What is it you’re trying to achieve in this interval that doesn’t result in success with James’s example?

Hey @acuffe, ups sorry maybe I did not understand so that explain step by step:

1.I have the next interval in my nerdlet personalized
2. this call the next function
3. this function returns first time certain data, which comes in the form like:
4. Here coming the problem, when call the function in the interval again past X time the function me returns the equal data that is to say which comes in the form like:
This means that it is not bringing me the current data if it does not stay in the first result
I hope I have given to understand thank you for the help you can give me
pda: I am secure that data change for verify with query builder

Ok so can I correctly state

Refresh functionality actually do retry the query after 60 seconds but the main issue is an identical result set?

If that’s the case would it be possible to share the NRQL query? If it’s not something you want to share publicly that’s no problem you can send my user a private message. I’d like to get a quick link to your account and the NRQL query so I can see the resultset that returns.

If new data is constantly flowing and 1 minute has passed it shouldn’t be an identical count but I don’t want to assume without seeing the NRQL.

What happend if I dont set a poll interval?
I think it polls data every 60000 miliseconds (1 minute) I am right ?
My query has SINCE today with no poll interval, and in the response, the chart metadata has refresh_interval:60000.
In my response I have no data, because actually I dont have any data in that time range. I am not really sure if it polls every 60000 miliseconds because I have no data or if it does because I didnt set a poll interval.


Also I have the same problem that jgaona asks, if there is any solution with Nrql.query, I would like to know

Great questions @dpena going to tag @acuffe on this to see if they can offer some insight on this…

Indeed 60s is the default which you can over-ride with the pollInterval

<NrqlQuery pollInterval={2000}   accountId={1}   query="SELECT count(*) FROM `Synthetics` SINCE 1 DAY AGO TIMESERIES AUTO FACET jobType" >

If you’re using Nrql.query the pollInterval may not operate in the same way as you’re not controlling it in the provided component but @jbuchanan2 gave a great example of how to control it.

Ironically in this scenario for @jgaona we connected and he shared his codebase and I couldn’t replicate the no refresh. I always got the minimum of 60 seconds. So was working great for me. Myself and James trialed with that code the setInterval approach and it worked and we had it refreshing every 10 seconds but we found that it seemed to be cached at 60 second intervals. Which would make sense atypically because majority of agents collect at 60 second intervals unless modified so it’s a performant cache level. We decided the simplest solution if we wanted every 30 seconds to update was to use a cache buster.

Generate a random number and then in your NRQL query state

WHERE attribute != ‘randomNumber’

Since the attribute we chose isn’t typically an integer, it can never make the random number meaning the query is unique each time, therefore no cache. So declaratively can use pollInterval but imperatively as NrqlQuery.query the pollInterval won’t be useful and setInterval allows you to control the times the query is ran by the app to a more often frequency if needed.

Does that help in any way?


Thank you so much for your complete answer.
I have now a better understanding of what is going on with polls intervals.
I decided to change my Nrql.query and start using NrqlQuery components instead.

Thanks for your time!

1 Like

@dpena :slight_smile: Happy to have helped in a small way. I hope you can achieve everything you need