Search code examples
javautcgrafanaprometheus

Custom time stamp for time series collected with Prometheus in java


I have a java application which uses the Prometheus library in order to collect metrics during execution. Later I link the Prometheus server to Grafana in order to visualize those metrics. I was wondering if it is possible to make Grafana show a custom X axis for those metrics? The usual X axis is in local time. Can I make it show data with timestamps in GPS / UTC time? Is it possible? If it is, what would it require? An additional metric parameter that holds the timestamps?

I declare the metric variable like this:

private static Counter someCounter = Counter.build()
            .name("someCounter_name").help("information counter").labelNames("SomeLable").register();

And add data like this:

someCounter.labels("test").inc();

Any help would be appreciated. Thank you.


Solution

  • This is something to handle in Grafana. If you look at the dashboard (not panel) settings, under General there's a Timezone drop-down that allows you to select UTC rather than browser local time.