How to change the date format of a time series axis in Grafana

You'd have though it would be an easy enough tweak to be able to change the the formatting of your time series axis in Grafana, but the only option in your visualisation settings is to change that of the hover over pop-up.

It does seem odd on the face of it, but once you see the solution it all makes sense - because of the nature of the dynamics scale of the times series both when the the visualisation is scaled and when the observation period is altered, Grafana needs to have multiple options at hand.

As such (and annoyingly) the date format options are set at a global level and can be found/added/adjusted in your settings file. I have a linux bare metal install so I'll make my changes in the following settings file:

/etc/grafana/grafana.ini

find the [date_formats] section and you'll be able to see the changes I made:

[date_formats]
# For information on what formatting patterns that are supported https://momentjs.com/docs/#/displaying/

# Default system date format used in time range picker and other places where full time is displayed
;full_date = YYYY-MM-DD HH:mm:ss

# Used by graph and other places where we only show small intervals
;interval_second = HH:mm:ss
;interval_minute = HH:mm
;interval_hour = MM/DD HH:mm
interval_hour = D-MMM
;interval_day = MM/DD
interval_day = D-MMM
;interval_month = YYYY-MM
;interval_year = YYYY

All you need to do is to edit the formats as required then save and restart the server by running the following command:

sudo systemctl restart grafana-server

If you have a docker install, you'll need to change this in your docker-compose.yml file, should be something like this:

grafana:
        image: grafana/grafana
        container_name: grafana
        restart: always
        environment:
            - interval_hour = D-MMM
            ...

then restart your docker instance

Tags : grafana date format linux docker

Subscribe to newsletter

Search Posts

Back to top