Hi, first post so apologies before I start.
So ideally I’m trying to delete the host and its associated data where it hasn’t updated any of its metrics in the last 7 days. (null values basically or no value is used)
This comes about when a server fails and is then re-built automatically in the AWS ASG
I can probably do this manually by using the delete command on the server name after interrogating the grafana graphs and seeing the server hasn’t updated any of it’s metrics over the last 7-8 days eg:
DELETE FROM "systems" WHERE "host" = 'server_name'
However this “server_name” is spread across a number of measurements of which “system” is but one, cpu, disk, diskio and processes are others!
To do this manually I would need to enter all these measurement_name values where the host value is present…I can find these by doing this command:
show tag values with key = “host”
Then I can use each name in my measurement_name below:
DROP SERIES FROM <measurement_name[,measurement_name]> WHERE <tag_key>='<tag_value>'
I have since realised that the field I should use to determine the trigger point would be time.
For example instead of using the trigger as a null value, I should be using the trigger point as a calculation between the last timestamp and the current time. If that is greater than 7 days then I should delete it!
However I don’t know the syntax to do a comparison to determine the current system time versus the last timestamp entry of the data as a “where” operator.
So in conclusion then, how do I:
- Find and delete all the data linked to that non-updating server as well as the server itself from the database
- Specify a “condition” reflecting that it hasn’t updated the time metric for more than 7 days
- Potentially write an automated task to do this for me.
Any assistance or even a solution is and will be gratefully appreciated. Thank you all so far much in advance.