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

Add option to fetch timestamp from JSON #97

Closed
wants to merge 1 commit into from

Conversation

fatpat
Copy link

@fatpat fatpat commented May 5, 2021

This fixes #80

@fatpat fatpat force-pushed the add_timestamp branch 3 times, most recently from 699bbfe to 9c265cf Compare May 5, 2021 11:05
This fixes prometheus-community#80

Signed-off-by: Jérôme LOYET <822436+fatpat@users.noreply.github.com>
@roidelapluie
Copy link

This seems a good idea, however I would prefer to have a fixed format rather than guessing it from a third party library.

@fatpat
Copy link
Author

fatpat commented Jun 14, 2021

This seems a good idea, however I would prefer to have a fixed format rather than guessing it from a third party library.

OK I'll check

@roidelapluie
Copy link

The idea would be to use func Parse(layout, value string) (Time, error) where layout would be a config option.

@rustycl0ck
Copy link
Member

Also update the Readme and the example configs for reference.

And link to this section explaining the behavior that when time series are missed for more than 5 minutes, they just "disappear" from graphs, (so that users understand the expected behavior when the scrapes are successful, but metrics are still missing from prometheus):

If no sample is found (by default) 5 minutes before a sampling timestamp, no value is returned for that time series at this point in time. This effectively means that time series "disappear" from graphs at times where their latest collected sample is older than 5 minutes or after they are marked stale.

Staleness will not be marked for time series that have timestamps included in their scrapes. Only the 5 minute threshold will be applied in that case.

@rustycl0ck
Copy link
Member

I don't really know how prometheus handles time series with timestamps from exporters. But one of the concerns I initially had when I saw this PR the first time, was that just by looking at Prometheus is it possible for a user know if the target is up or not?

Does prometheus actually somehow show that the last scrape was at time 10 seconds ago, but the actual data collected was with a timestamp of 4 minutes ago. Because if that is not possible, then prometehus can never reliably tell me about the up status of the target.

Would be great if @roidelapluie you an explanation or a link to some blog/doc explaining this. I found this but this is not targeted at timeseries with timestamps, just for missed scrapes which then get marked as stale.

I had put off reviewing this PR for a day when I would actually be able to test this behavior and understand the consequences, but I think that might still take a few weeks before I can afford to do that.

@roidelapluie
Copy link

I expect the timestamp to be exported as a metric, not to be set on metrics. I did not review the PR yet, just scanned it very quickly. We should not set timestamps on metrics

@rustycl0ck
Copy link
Member

I expect the timestamp to be exported as a metric, not to be set on metrics.

Ah yes, in that case all would be fine. Exporting the timestamp as a metric (probably with unix epoch time as the value) would be fine. Although on initial thought I can't think how such a metric might actually be useful. But I'll let @fatpat decide if this is useful to them or not.

@roidelapluie
Copy link

Oh, indeed, the current implentation exposes a metric with a timestamp, which is something we should not do I think.

cc @SuperQ do you agree?

@SuperQ
Copy link
Contributor

SuperQ commented Jun 14, 2021

@roidelapluie Agreed, it should not expose with a timestamp.

@rustycl0ck rustycl0ck closed this Oct 2, 2021
janphkre added a commit to janphkre/json_exporter that referenced this pull request Jul 11, 2022
based on prometheus-community#97 and prometheus-community#80 this provides the posibility to use a metric that has a unix style timestamp as the timestamp of the scraped metric
janphkre added a commit to janphkre/json_exporter that referenced this pull request Jul 11, 2022
based on prometheus-community#97 and prometheus-community#80 this provides the posibility to use a metric that has a unix style timestamp as the timestamp of the scraped metric

When deserializing objects we need to take the key json path into account as well like we would do for all the values as well. This allows collections to be defined still with each entry having a separate timestamp (e.g. list of time-stamped log messages).

Update examples for timestamp

Update Readme about staleness for custom timestamps
janphkre added a commit to janphkre/json_exporter that referenced this pull request Jul 11, 2022
based on prometheus-community#97 and prometheus-community#80 this provides the posibility to use a metric that has a unix style timestamp as the timestamp of the scraped metric

When deserializing objects we need to take the key json path into account as well like we would do for all the values as well. This allows collections to be defined still with each entry having a separate timestamp (e.g. list of time-stamped log messages).

Update examples for timestamp

Update Readme about staleness for custom timestamps

Signed-off-by: Jan Phillip Kretzschmar <janphkre@gmx.de>
janphkre added a commit to janphkre/json_exporter that referenced this pull request Jul 11, 2022
based on prometheus-community#97 and prometheus-community#80 this provides the posibility to use a metric that has a unix style timestamp as the timestamp of the scraped metric

When deserializing objects we need to take the key json path into account as well like we would do for all the values as well. This allows collections to be defined still with each entry having a separate timestamp (e.g. list of time-stamped log messages).

Update examples for timestamp

Update Readme about staleness for custom timestamps

Signed-off-by: Jan Phillip Kretzschmar <janphkre@gmx.de>
janphkre added a commit to janphkre/json_exporter that referenced this pull request Jul 11, 2022
based on prometheus-community#97 and prometheus-community#80 this provides the posibility to use a metric that has a unix style timestamp as the timestamp of the scraped metric

When deserializing objects we need to take the key json path into account as well like we would do for all the values as well. This allows collections to be defined still with each entry having a separate timestamp (e.g. list of time-stamped log messages).

Update examples for timestamp

Update Readme about staleness for custom timestamps

Signed-off-by: Jan Phillip Kretzschmar <janphkre@gmx.de>
SuperQ added a commit that referenced this pull request Aug 28, 2022
* Pick timestamp from metric

based on #97 and #80 this provides the posibility to use a metric that has a unix style timestamp as the timestamp of the scraped metric

When deserializing objects we need to take the key json path into account as well like we would do for all the values as well. This allows collections to be defined still with each entry having a separate timestamp (e.g. list of time-stamped log messages).

Update examples for timestamp

Update Readme about staleness for custom timestamps

Signed-off-by: Jan Phillip Kretzschmar <janphkre@gmx.de>
Signed-off-by: Ben Kochie <superq@gmail.com>
Co-authored-by: Ben Kochie <superq@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using timestamp from api as timestamp in promehteous metric
4 participants