Last run of metricbeat module

Hello!

I'm developing a metricbeat module for a database. I would like to fetch backup information from the database. I don't want to fetch all backup information each time the module runs. Just the information which is new.

Is there a way to get the configured interval of the metricbeat module?

Thank you!

The configured period is available to the metricset through the ModuleConfig (e.g. ms.Module().Config().Period).

You could store in memory the time of the last fetch and use that in your query so that you fetch only information newer than that last fetch time.

Thank you!
I was already thinking of storing the last execution time in a variable. But when my module was down for some time and it comes up again I would miss the last backup(s) because they are older than the now - period.

This would not be a big deal. The only problem is that a false alert like "backup missing" would be cleared after up to 24h.

To avoid this situation I'll code something like this: If the module comes up and lastExec is nil then I fetch the latest backup. Else, fetch backups which are newer then now - period.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.