Multiple builds on same graph using elapsed time - "Values must be in ascending order" error

I’m monitoring build processes via Prometheus metrics and need to create a dashboard that compares multiple builds on the same graph using relative elapsed time in seconds instead of absolute timestamps.
Current Setup:

  • Prometheus metrics structure:

build_cpu_percent{job="build",project="web-app",build_id="build-123"} 116 build_memory_megabytes{job="build",project="web-app",build_id="build-123"} 1891 build_elapsed_seconds{job="build",project="web-app",build_id="build-123"} 23

  • Data pattern: Each build has its own timeline where build_elapsed_seconds starts from 0 and increases during the build

  • Goal: Create graphs like this where X-axis shows “Start Time (seconds)” instead of wall-clock time

Current Issues:

  1. “Values must be in ascending order” error when trying to use build_elapsed_seconds as X-axis

  2. Multiple builds create conflicting timelines:

    • Build A: elapsed_seconds = 555, 585, 615

    • Build B: elapsed_seconds = 18, 48, 78

    • Grafana sees: 18 → 48 → 78 → 555 → 585 → 615 (not ascending)

Currently my data looks like this (after some transformation on the data)

and i want to display something like this
where each color of dotted lines represent a build-id CPU usage