Cant' connect points in Time series from Prometheus

Hello there,
I have a panel configured as a Time Series that queries Prometheus, returning values in milliseconds, sampled every 5 minutes. However, I can’t find a way to connect the data points with lines, as you can see in the first image. The only line is between two samples that coincidentally have the same value (duration in milliseconds).

The only way I’ve found is to change the Format (in query options) from Time series to Table, but this removes all the labels from the Prometheus metric (see second image), which I need.

Does anyone have any suggestions? Thank you very much.

what does the raw data look like

Here they are:

You are saving duration as a label, which doesn’t look good to me. Are you sure that you want that?
That’s causing that each point is independend = timeserie with just one point.

1 Like

Thanks for your reply. I have another metric where I have duration as label and either 0 (failed) or 1 (passed) as value. For example:

pw_test{actualStatus=‘failed’, attachmentsCount=‘1’, duration=‘13845’, expectedStatus=‘passed’, id=‘41d3fd2474a19feb00a1-a457fc1c3babe5308781’, location=“tests/login. spec.ts:14:5‘, parallelIndex=’0‘, retryCount=’0‘, stepsCount=’14‘, suite=’login.spec.ts‘, title=’Login‘, workerIndex=’0”}

pw_test{actualStatus=‘failed’, attachmentsCount=‘1’, duration=‘17174’, expectedStatus=‘passed’, id=‘41d3fd2474a19feb00a1-a457fc1c3babe5308781’, location=“tests/login. spec.ts:14:5‘, parallelIndex=’0‘, retryCount=’0‘, stepsCount=’10‘, suite=’login.spec.ts‘, title=’Login‘, workerIndex=’0”}

But in this case, how can I use the duration as a Y-axis value?

You have wrong data model. Don’t store values (read as a numbers) in labels. You will a have a lot of problems with that.

2 Likes

to @jangaraj 's point

metric name : 
  cpu_usage_seconds_total
labels: 
 instance="host1", core="0"
timestamp:
 2025-02-27T10:00:00Z
value:
  1200

you can have many instance labels and cores for each instance. etc

Sorry, I misunderstood your first answer. In the first metric I posted (the one used in my panel, in the two images at the beginning), duration is both a label and the value of the metric itself, as you can see:

Do you want just connect those point (and you don’t care about other issues, which you may have in the future thanks to bad data model) or do you want to make it right?

1 Like

For now, I would just like to connect these points without the labels ‘disappearing’ from the legend (see difference below), so that I can regex and intercept in overrides the label “actualStatus” and change the colour of the points depending on its value.

[same query same config, just switching from Time Series to Table in Query options"]
Points disconnected, correct legend with all labels:

Points connected, label not there

So use aggregation, which will create a single time series. For example (not copy&paste - add what you need and fix syntax issues):

max(pw_test_duration{...}) by (id)