Hi everyone!
I have my own metrics that looks like:
my_metric{id="object1",date="2021-10-11T22:55:54Z" } 1
my_metric{id="object2",date="2021-10-11T22:20:00Z" } 4
I want to make a graph with label ‘date’ by X-axis and metric value by Y-axis. There should be value points for different IDs.
In other words, I want to change the default timeline to my new one.
Are there some ideas how to do it or should I change my metrics?
Thank you
Are you using Prometheus @mazzybig ? Please specify datasource.
One gotcha I can see here is that Prometheus labels are strings, so your timestamp, date
, would need to change its data type to work as a time
field
Yes, I’m using Prometheus. I create my own metrics using bash-script that saves them to prom-file for node-exporter.
your timestamp, date
, would need to change its data type to work as a time
field
I couldn’t get this point. Can you please explain what should I do?
As I said earlier, I can create my own metrics in any format. So now I’m looking for a better approach.
so you are using the textfile collector that ships with node-exporter ? Whenever Prometheus scrapes that file, it will add a timestamp to the scraped metrics. What is the pre-existing timestamp and how / where does it come from?
Yes, exactly
I get them from third-party API. These are the dates and times of some kind of events. Moreover, several events with different times may be written in one text file.
So, I need to visualize these events on a timeline.
@mazzybig yes, if I understand correctly, then you’ve run up against a known limitation with Prometheus. It just wasn’t designed to ingest time-series data where the timestamp is a label. See this issue comment and the related blog post for workarounds:
opened 06:22PM - 27 Jul 21 UTC
area/units
needs investigation
<!--
Please use this template to create your bug report. By providing as much i… nfo as possible you help us understand the issue, reproduce it and resolve it for you quicker. Therefor take a couple of extra minutes to make sure you have provided all info needed.
PROTIP: record your screen and attach it as a gif to showcase the issue.
- Questions should be posted to: https://localhost:3000
- Use query inspector to troubleshoot issues: https://bit.ly/2XNF6YS
- How to record and attach gif: https://bit.ly/2Mi8T6K
-->
**What happened**:
In a query to Prometheus that returns only a straight metric, I have two labels that include timestamps. When I attempt to display these timestamps in a table, I am unable to set the unit to any type of date format. All six options cause the values to be displayed as "NaN".
**What you expected to happen**:
The timestamps should be correctly displayed as a date, as they would if the returned metric value was a timestamp.
**How to reproduce it (as minimally and precisely as possible)**:
The following is an example of the metric being scraped by Prometheus:
`my_uptime_metric{expires_at="1607137229000",launched_at="1607086829683",node_label="Launch_179"} 20322007.078515`
Create a table panel querying `my_uptime_metric` only. Create a unit override for either the `expires_at` or `launched_at` field ("Fields with Name") and select any of the "Date & Time" types.
**Anything else we need to know?**:
I have a suspicion that the NaN result may be due to the timestamp values being expressed as a string instead of a numeric type. This data is being exposed to Prometheus through the node_exporter utility's textfile collector feature, and while the file node_exporter is reading from has the timestamps as a numeric format, it is applying the quotes to the timestamps.
**Environment**:
- Grafana version: 8.0.3
- Data source type & version: Promtheus 2.4.3
- OS Grafana is installed on: Docker Alpine Image
- User OS & Browser: Windows 10, Chrome 92
- Grafana plugins: grafana-clock-panel, flant-statusmap-panel
- Others:

Thank you!
It makes sense
1 Like
Hey have you got anyway to do that? (Custom time stamp on x axis)
system
Closed
October 13, 2022, 3:09pm
9
This topic was automatically closed after 365 days. New replies are no longer allowed.