Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for admin API is no good for deleting metrics #5567

Closed
kaytrance opened this issue May 15, 2019 · 8 comments · Fixed by #7875
Closed

Documentation for admin API is no good for deleting metrics #5567

kaytrance opened this issue May 15, 2019 · 8 comments · Fixed by #7875

Comments

@kaytrance
Copy link

kaytrance commented May 15, 2019

Documentation must specify what unix timestamp format must be used to avoid total data loss (as it happened in my case).

Documentation just say

end=<rfc3339 | unix_timestamp>: End timestamp. Optional and defaults to maximum possible time.

In my case I have specified timestamp of 2019-05-13 17:00 as 1557756000000, but apparently it needs to be without last 3 digits (so in seconds, not in milliseconds).

In result my data was totally wiped out using this query:

/api/v1/admin/tsdb/delete_series?end=1557756000000&match[]=up{job="test"}

Suggestion:

  1. modify documentation and add that unix timestamp must be in form of seconds;
  2. add check in prometheus to validate unix timestamp (by length, for example), return "not accepted" if unix timestamp was in incorrect form.
@brian-brazil
Copy link
Contributor

Unix timestamps are in seconds generally, as is everything else in the API as documented on the page.

1557756000000 is also a perfectly valid unix timestamp.

@kaytrance
Copy link
Author

yes, it is valued, but in my case it caused all data to be wiped out because, probably, prometheus expected it to be in seconds and since it was in milliseconds it converted it to something quite far in future, and together with end parameter supplied it deleted everything until this date, meaning everything I had. So this leaves a possibility of very unpleasant situation, and I was thinking it would be a good idea to create a issue that could save other people for potential data loss.

@dannyk81
Copy link

dannyk81 commented May 15, 2019

@kaytrance

1557756000000 (or 1557756000 in seconds format) is Monday, May 13, 2019 14:00:00 (GMT/UTC) and not 17:00:00

Prometheus uses UTC times, so perhaps you had more data deleted due not accounting for TZ differences?

I always use milliseconds and never had an issue.

@brian-brazil
Copy link
Contributor

Looking at the docs, where we document the semantics of unix_timestamp we don't actually use the string unix_timestamp so it'd harder to find than it should be. Similarly with rfc3339.

@Harkishen-Singh
Copy link
Contributor

Prometheus uses UTC times, so perhaps you had more data deleted due not accounting for TZ differences?

I guess, he means to say that all the data got deleted due to a large end value.

Unix timestamps are in seconds generally, as is everything else in the API as documented on the page.

I do agree with what @brian-brazil said, but I think we can have add check in prometheus to validate unix timestamp as a sanitary check.

@brian-brazil
Copy link
Contributor

I think we can have add check in prometheus to validate unix timestamp as a sanitary check.

I don't see how that'd help here, the timestamp was valid.

@roidelapluie
Copy link
Member

roidelapluie commented Sep 1, 2020 via email

@Harkishen-Singh
Copy link
Contributor

We could refuse timestamps higher than 10000000000

that's what I meant as a sanitary check.

@prometheus prometheus locked as resolved and limited conversation to collaborators Nov 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants