Search code examples
datelabelprometheusgrafana

How to get the recent date value of one label from Prometheus and show it on Grafana


I am working on Grafana. For one metric, I would like to visualize the recent date value of one label from Prometheus.

exp:

metric_processed_date{"process_date"="23-03-2023 14:35:25","job":"j1"}
metric_processed_date{"process_date"="20-02-2023 14:35:25","job":"j1"}

I would like to visualize the date "23-03-2023 14:35:25"


Solution

  • I am using a table Panel.

    I found a solution for this problem:

    I used a simple query metric_processed_date{job="my-job"} and applied some transformation:

    On options:

    • Format: Table
    • Type: instant

    On Transform:

    1. Organize fields - to keep only process_date label
    2. Function Reduce / Calculations First*
    3. Organize fields - again, to hide Field column
    4. Convert Field Type - to change the format of date

    Thank you !