I have these metrics in prometheus tsdb(output from curling the exporter)
# HELP custom_test_metric A test metric with a past timestamp
# TYPE custom_test_metric gauge
custom_test_metric{step="step1"} 42.0 1741899227000
custom_test_metric{step="step2"} 45.0 1741899230000
custom_test_metric{step="step3"} 48.0 1741899827000
As you can see I added timestamps into each metrics. The reason I am doing this is: my data generation is not always a fix interval. For a 15 second scrape interval, I may generate 1, 3, or 10 values, each is guarantee to have a unique timestamp. So in my exporter/collector, I just keep on using label stepN for the Nth value.
I’d like to show them in one timeseries in grafana, instead of n, since they are actually the same one metric (with no labels). The timestamp is guaranteed to be unique for each of these metric. Something like without the step label, like this:
custom_test_metric{} 42.0 1741899227000
custom_test_metric{} 45.0 1741899230000
custom_test_metric{} 48.0 1741899827000
Is this doable? If it is, then my prometheus scrape interval does not need to be related/dependent on the how fast the data is collected. That will be a big win since one scrape job may collect different metric at dramatically different intervals.
Background: for each prometheus scrape interval, I may have more than one value. So in the collector, I added step label for each metric. But they are really the same metric (with same set label value). I can’t just give a small scrape interval since the data generation is not at fixed interval. So I create the above step1/step2/step3/step… label with timestamp and hopefully grafana can combine them and show them as one timeseries, using something like transform. Is this doable?
I tried prometheus re-write/relabel rules but could not make it work.
Thank you!