cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Scheduled Purging and Archiving of Data

SaranKarthick
16-Pearl

Scheduled Purging and Archiving of Data

Hi Developers,

 

I have a use case where i have to purge sensor data for a certain time period as well as have to take backup of the same data before its purged.

 

I have gone through the community and support portal and got an idea on the following activities which will be automated through a Scheduler at the end of each day. 
How to programmatically take backup of Data

Best Practices on purging

 

One challenge i see here is that the service have to purge the data only after it gets a confirmation that the same have been taken backup. 

 

So when i run the API for taking backup of data i get a message stating as given below. But it doesn't really give the actual status of the backup activity (like the deployment status available for the SCM module of the TWX Utilities). I have to manually check it up in the logs.

 

Data Export submitted for processing. Please check the log for completion status of Task-<some number>

 

I want to know if there is a better way to know about the actual status of the task or I can consider that the data export will be successful if I get the above response from the invoked export API.

 

Thanks and Regards,

Saran

1 ACCEPTED SOLUTION

Accepted Solutions

You don't need to build any custom extension, just Javascript Server Side Scripting feature on ThingWorx, to query the log you have:

 

Logs["ApplicationLog"].QueryLogEntries({
	maxItems: undefined /* NUMBER */,
	searchExpression: undefined /* STRING */,
	fromLogLevel: undefined /* STRING */,
	instance: undefined /* STRING */,
	endDate: undefined /* DATETIME */,
	origin: undefined /* STRING */,
	thread: undefined /* STRING */,
	ascendingSearch: undefined /* BOOLEAN */,
	oldestFirst: undefined /* BOOLEAN */,
	toLogLevel: undefined /* STRING */,
	user: undefined /* USERNAME */,
	sortFieldName: undefined /* STRING */,
	startDate: undefined /* DATETIME */
});

View solution in original post

5 REPLIES 5

Not nice, but you can keep quering for a while for the message on the log on an automated way, log it's accessible trough scripting.

Hi @CarlesColl,

 

Thanks for the suggestion. I was also seeing if I can do that with any existing extensions or services but it seems i may need to create a custom extension with the file reading capability and also to fetch the files from the logs folder.

 

Do let me know if there is any extension available for my use case.

Regards,

Saran

Saran

You don't need to build any custom extension, just Javascript Server Side Scripting feature on ThingWorx, to query the log you have:

 

Logs["ApplicationLog"].QueryLogEntries({
	maxItems: undefined /* NUMBER */,
	searchExpression: undefined /* STRING */,
	fromLogLevel: undefined /* STRING */,
	instance: undefined /* STRING */,
	endDate: undefined /* DATETIME */,
	origin: undefined /* STRING */,
	thread: undefined /* STRING */,
	ascendingSearch: undefined /* BOOLEAN */,
	oldestFirst: undefined /* BOOLEAN */,
	toLogLevel: undefined /* STRING */,
	user: undefined /* USERNAME */,
	sortFieldName: undefined /* STRING */,
	startDate: undefined /* DATETIME */
});

Thanks @CarlesColl  for the workaround.

 

Its surprising that this kind of Scripting feature in TWX was available. Is there any articles which lists such kind of hidden features? If so pls do let me know. It would be really helpful.

 

 

Regards,

Saran

I don't know if it's hidden, it's just there, you have the objects on the platform and you just need to look at which services offer.

Top Tags